2 # Save mysql server configuration options
4 require './mysql-lib.pl';
5 $access{'perms'} == 1 || &error($text{'cnf_ecannot'});
6 &error_setup($text{'cnf_err'});
9 # Get the mysqld section
10 &lock_file($config{'my_cnf'});
11 $conf = &get_mysql_config();
12 ($mysqld) = grep { $_->{'name'} eq 'mysqld' } @$conf;
13 $mysqld || &error($text{'cnf_emysqld'});
15 # Parse mysql server inputs
16 if ($in{'port_def'}) {
17 &save_directive($conf, $mysqld, "port", [ ]);
20 $in{'port'} =~ /^\d+$/ && $in{'port'} > 0 && $in{'port'} < 65536 ||
21 &error($text{'cnf_eport'});
22 &save_directive($conf, $mysqld, "port", [ $in{'port'} ]);
25 if ($in{'bind_def'}) {
26 &save_directive($conf, $mysqld, "bind-address", [ ]);
29 &check_ipaddress($in{'bind'}) ||
30 &error($text{'cnf_ebind'});
31 &save_directive($conf, $mysqld, "bind-address", [ $in{'bind'} ]);
34 if ($in{'socket_def'}) {
35 &save_directive($conf, $mysqld, "socket", [ ]);
38 $in{'socket'} =~ /^\/\S+$/ ||
39 &error($text{'cnf_esocket'});
40 &save_directive($conf, $mysqld, "socket", [ $in{'socket'} ]);
43 if ($in{'datadir_def'}) {
44 &save_directive($conf, $mysqld, "datadir", [ ]);
47 -d $in{'datadir'} || &error($text{'cnf_edatadir'});
48 &save_directive($conf, $mysqld, "datadir", [ $in{'datadir'} ]);
51 &save_directive($conf, $mysqld, "default-storage-engine",
52 $in{'stor'} ? [ $in{'stor'} ] : [ ]);
54 $fpt = &find_value("innodb_file_per_table", $mems);
55 if ($fpt || $in{'fpt'}) {
56 &save_directive($conf, $mysqld, "innodb_file_per_table",
60 &save_directive($conf, $mysqld, "skip-locking",
61 $in{'skip-locking'} ? [ "" ] : [ ]);
63 &save_directive($conf, $mysqld, "big-tables",
64 $in{'big-tables'} ? [ "" ] : [ ]);
67 %vars = &parse_set_variables(&find_value("set-variable", $mems));
68 foreach $w (@mysql_set_variables, @mysql_number_variables) {
73 $in{$w} =~ /^\d+$/ || &error($text{"cnf_e".$w});
74 $vars{$w} = $in{$w}.$in{$w."_units"};
78 foreach $v (keys %vars) {
79 push(@sets, $v."=".$vars{$v});
81 &save_directive($conf, $mysqld, "set-variable", \@sets);
84 &flush_file_lines($config{'my_cnf'});
85 &unlock_file($config{'my_cnf'});
86 if ($in{'restart'} && &is_mysql_running() > 0) {
88 $err = &start_mysql();
89 &error($err) if ($err);