From 0f484ebae601f3c4a02c2eca17c9b9f88d4c5f88 Mon Sep 17 00:00:00 2001 From: "jani@a80-186-24-72.elisa-laajakaista.fi" <> Date: Tue, 6 Apr 2004 17:57:32 +0300 Subject: Fixed a problem with mysqld_multi log file. The default is now datadir/mysqld_multi.log, if doesn't exists or is not writable, then /var/log/mysqld_multi.log, if does not exists or is not writable, then /tmp/mysqld_multi.log, but only in case the file does not yet exists in /tmp. Otherwise log will be disabled, unless user explicitely sets it with an option. --- scripts/mysqld_multi.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'scripts/mysqld_multi.sh') diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 3165a01362c..a4f2b18fda8 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -4,12 +4,12 @@ use Getopt::Long; use POSIX qw(strftime); $|=1; -$VER="2.5"; +$VER="2.6"; $opt_config_file = undef(); $opt_example = 0; $opt_help = 0; -$opt_log = "/tmp/mysqld_multi.log"; +$opt_log = ""; $opt_mysqladmin = "@bindir@/mysqladmin"; $opt_mysqld = "@libexecdir@/mysqld"; $opt_no_log = 0; @@ -18,6 +18,9 @@ $opt_tcp_ip = 0; $opt_user = "root"; $opt_version = 0; +my $my_print_defaults_exists= 1; +my $logdir= undef(); + my ($mysqld, $mysqladmin, $groupids, $homedir, $my_progname); $homedir = $ENV{HOME}; @@ -42,7 +45,9 @@ sub main print "Please make sure you have this command available and\n"; print "in your path. The command is available from the latest\n"; print "MySQL distribution.\n"; + $my_print_defaults_exists= 0; } + init_log(); my @defops = `my_print_defaults mysqld_multi`; chop @defops; splice @ARGV, 0, 0, @defops; @@ -112,6 +117,56 @@ sub main } } +#### +#### Init log file. Check for appropriate place for log file, in the following +#### order my_print_defaults mysqld datadir, @datadir@, /var/log, /tmp +#### + +sub init_log +{ + if ($my_print_defaults_exists) + { + @mysqld_opts= `my_print_defaults mysqld`; + chomp @mysqld_opts; + foreach my $opt (@mysqld_opts) + { + if ($opt =~ m/^\-\-datadir[=](.*)/) + { + if (-d "$1" && -w "$1") + { + $logdir= $1; + } + } + } + } + if (!defined($logdir)) + { + $logdir= "@datadir@" if (-d "@datadir@" && -w "@datadir@"); + } + if (!defined($logdir)) + { + $logdir= "/var/log" if (-d "/var/log" && -w "/var/log"); + } + if (!defined($logdir)) + { + if (-d "/tmp" && -w "/tmp" && ! -e "/tmp/mysqld_multi.log") + { + $logdir= "/tmp"; + } + } + if (!defined($logdir)) + { + # We still couldn't get a default log file in place. Log file + # will be disabled unless user sets it with an option + + $opt_no_log= 1; + } + else + { + $opt_log= "$logdir/mysqld_multi.log"; + } +} + #### #### Report living and not running MySQL servers #### -- cgit v1.2.1