--- support-files/mysql.server.sh 2007-07-04 15:06:33.000000000 +0200 +++ support-files/mysql.server.sh.oden 2007-09-28 12:40:00.000000000 +0200 @@ -9,17 +9,17 @@ # When this is done the mysql server will be started when the machine is # started and shut down when the systems goes down. -# Comments to support chkconfig on RedHat Linux -# chkconfig: 2345 64 36 +# Comments to support chkconfig on Mandriva Linux +# chkconfig: - 11 90 # description: A very fast and reliable SQL database engine. # Comments to support LSB init script conventions ### BEGIN INIT INFO # Provides: mysql # Required-Start: $local_fs $network $remote_fs -# Should-Start: ypbind nscd ldap ntpd xntpd +# Should-Start: ypbind nscd ldap ntpd # Required-Stop: $local_fs $network $remote_fs -# Default-Start: 2 3 4 5 +# Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop MySQL # Description: MySQL is a very fast and reliable SQL database engine. @@ -40,6 +40,9 @@ # If you want to affect other MySQL variables, you should make your changes # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. +# Source function library. +. /etc/rc.d/init.d/functions + # If you change base dir, you must also change datadir. These may get # overwritten by settings in the MySQL configuration files. @@ -58,7 +61,7 @@ # Set some defaults pid_file= server_pid_file= -use_mysqld_safe=1 +use_mysqld_safe=0 user=@MYSQLD_USER@ if test -z "$basedir" then @@ -101,6 +104,9 @@ } fi +# Source mysql configuration. +[ -f /etc/sysconfig/mysqld ] && . /etc/sysconfig/mysqld + PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin export PATH @@ -121,12 +127,12 @@ for arg do case "$arg" in --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` - bindir="$basedir/bin" + bindir="@bindir@" if test -z "$datadir_set"; then - datadir="$basedir/data" + datadir="@localstatedir@" fi - sbindir="$basedir/sbin" - libexecdir="$basedir/libexec" + sbindir="@sbindir@" + libexecdir="@libexecdir@" ;; --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` datadir_set=1 @@ -268,6 +274,13 @@ # Safeguard (relative paths, core dumps..) cd $basedir + # Don't start several instances. + if test -f $pid_file -a -f $server_pid_file; then + echo $echo_n "MySQL is allready running: " + success; echo + exit 1 + fi + manager=$bindir/mysqlmanager if test -x $libexecdir/mysqlmanager then @@ -277,23 +290,23 @@ manager=$sbindir/mysqlmanager fi - echo $echo_n "Starting MySQL" + echo $echo_n "Starting MySQL: " if test -x $manager -a "$use_mysqld_safe" = "0" then if test -n "$other_args" then - log_failure_msg "MySQL manager does not support options '$other_args'" + log_failure_msg "MySQL manager does not support options '$other_args'"; echo exit 1 fi # Give extra arguments to mysqld with the my.cnf file. This script may # be overwritten at next upgrade. - $manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 & - wait_for_pid created $!; return_value=$? + $manager --user=$user --run-as-service --pid-file=$pid_file >/dev/null 2>&1 & + wait_for_pid created $!; return_value=$?; echo - # Make lock for RedHat / SuSE + # Make lock for Mandriva Linux if test -w /var/lock/subsys then - touch /var/lock/subsys/mysqlmanager + touch /var/lock/subsys/mysqlmanager /var/lock/subsys/mysqld fi exit $return_value elif test -x $bindir/mysqld_safe @@ -302,16 +315,16 @@ # may be overwritten at next upgrade. pid_file=$server_pid_file $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 & - wait_for_pid created $!; return_value=$? + wait_for_pid created $!; return_value=$?; echo - # Make lock for RedHat / SuSE + # Make lock for Mandriva Linux if test -w /var/lock/subsys then - touch /var/lock/subsys/mysql + touch /var/lock/subsys/mysqld fi exit $return_value else - log_failure_msg "Couldn't find MySQL manager or server" + log_failure_msg "Couldn't find MySQL manager or server"; echo fi ;; @@ -319,32 +332,32 @@ # Stop daemon. We use a signal here to avoid having to know the # root password. - # The RedHat / SuSE lock directory to remove + # The Mandriva Linux lock directory to remove lock_dir=/var/lock/subsys/mysqlmanager # If the manager pid_file doesn't exist, try the server's if test ! -s "$pid_file" then pid_file=$server_pid_file - lock_dir=/var/lock/subsys/mysql + lock_dir=/var/lock/subsys/mysqld fi if test -s "$pid_file" then mysqlmanager_pid=`cat $pid_file` - echo $echo_n "Shutting down MySQL" + echo $echo_n "Shutting down MySQL: " kill $mysqlmanager_pid # mysqlmanager should remove the pid_file when it exits, so wait for it. - wait_for_pid removed; return_value=$? + wait_for_pid removed; return_value=$?; echo # delete lock for RedHat / SuSE if test -f $lock_dir then - rm -f $lock_dir + rm -f $lock_dir /var/lock/subsys/mysqld fi exit $return_value else - log_failure_msg "MySQL manager or server PID file could not be found!" + log_failure_msg "MySQL manager or server PID file could not be found!"; echo fi ;; @@ -363,9 +376,9 @@ if test -s "$server_pid_file" ; then read mysqld_pid < $server_pid_file kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" - touch $server_pid_file + touch $server_pid_file; echo else - log_failure_msg "MySQL PID file could not be found!" + log_failure_msg "MySQL PID file could not be found!"; echo exit 1 fi ;; @@ -387,7 +400,7 @@ if test "$use_mysqld_safe" = "0" ; then lockfile=/var/lock/subsys/mysqlmanager else - lockfile=/var/lock/subsys/mysql + lockfile=/var/lock/subsys/mysqld fi if test -f $lockfile ; then log_failure_msg "MySQL is not running, but lock exists"