Sophie

Sophie

distrib > Mandriva > cs4.0 > i586 > by-pkgid > a00d0f1300d0d6796729cd82518482f4 > files > 9

MySQL-5.0.24-1mdv2007.0.src.rpm

--- support-files/mysql.server.sh	2006-07-11 11:38:34.000000000 +0200
+++ support-files/mysql.server.sh.oden	2006-07-11 11:38:42.000000000 +0200
@@ -9,8 +9,8 @@
 # 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: 2345 11 90
 # description: A very fast and reliable SQL database engine.
 
 # Comments to support LSB init script conventions
@@ -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.
 
@@ -51,7 +54,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
@@ -77,22 +80,8 @@
 # *not* set inside of the --basedir= handler.)
 datadir_set=
 
-#
-# Use LSB init script functions for printing messages, if possible
-#
-lsb_functions="/lib/lsb/init-functions"
-if test -f $lsb_functions ; then
-  source $lsb_functions
-else
-  log_success_msg()
-  {
-    echo " SUCCESS! $@"
-  }
-  log_failure_msg()
-  {
-    echo " ERROR! $@"
-  }
-fi
+# Source mysql configuration.
+[ -f /etc/sysconfig/mysqld ] && . /etc/sysconfig/mysqld
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
 export PATH
@@ -114,12 +103,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
@@ -162,9 +151,9 @@
   done
 
   if test -z "$i" ; then
-    log_success_msg
+    success
   else
-    log_failure_msg
+    failure
   fi
 }
 
@@ -257,6 +246,13 @@
   'start')
     # Start daemon
 
+    # 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
@@ -266,20 +262,21 @@
       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'"
+	echo $echo_n "MySQL manager does not support options '$other_args'"
+	failure
         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
+      $manager --user=$user --run-as-service --pid-file=$pid_file >/dev/null 2>&1 &
+      wait_for_pid created && success
 
-      # Make lock for RedHat / SuSE
+      # Make lock for Mandriva Linux
       if test -w /var/lock/subsys
       then
         touch /var/lock/subsys/mysqlmanager
@@ -290,48 +287,50 @@
       # 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
+      wait_for_pid created && success
 
-      # 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
     else
-      log_failure_msg "Couldn't find MySQL manager or server"
+      echo $echo_n "Couldn't find MySQL instance manager or server"
+      failure
     fi
+    echo
     ;;
 
   'stop')
     # 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
+      wait_for_pid removed && success
 
-      # delete lock for RedHat / SuSE
-      if test -f $lock_dir
-      then
-        rm -f $lock_dir
-      fi
+      # cleanup potential stale lock and pid files for Mandriva Linux
+      rm -f /var/lock/subsys/mysqlmanager /var/lock/subsys/mysqld
+      rm -f $pid_file $server_pid_file
     else
-      log_failure_msg "MySQL manager or server PID file could not be found!"
+      echo $echo_n "MySQL manager or server PID file could not be found!"
+      failure
     fi
+    echo
     ;;
 
   'restart')
@@ -344,16 +343,26 @@
   'reload')
     if test -s "$server_pid_file" ; then
       mysqld_pid=`cat $server_pid_file`
-      kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
+      echo $echo_n "Reloading service MySQL: "
+      kill -HUP $mysqld_pid && success
       touch $server_pid_file
     else
-      log_failure_msg "MySQL PID file could not be found!"
+      echo $echo_n "MySQL PID file could not be found!"
+      failure
     fi
+    echo
     ;;
 
+  'status') 
+    if [ $use_mysqld_safe = '0' ]; then
+        status mysqlmanager
+    fi
+        status mysqld
+    ;; 
+
   *)
     # usage
-    echo "Usage: $0  {start|stop|restart|reload}  [ MySQL server options ]"
+    echo "Usage: $0  {start|stop|status|restart|reload}  [ MySQL server options ]"
     exit 1
     ;;
 esac