Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 91117ef1a9653edd6a912d3a095f594d > files > 15

mysql-5.0.84-0.1mdv2009.0.src.rpm

--- support-files/mysql.server.sh	2009-01-29 22:45:52.000000000 +0100
+++ support-files/mysql.server.sh.oden	2009-04-20 13:10:01.000000000 +0200
@@ -9,15 +9,15 @@
 # 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
 ### BEGIN INIT INFO
-# Provides: mysql
+# Provides: mysqld
 # Required-Start: $local_fs $network $remote_fs
-# Should-Start: ypbind nscd ldap ntpd xntpd
+# Should-Start: ypbind ldap ntpd
 # Required-Stop: $local_fs $network $remote_fs
 # Default-Start:  2 3 4 5
 # Default-Stop: 0 1 6
@@ -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
@@ -291,6 +297,35 @@
     # Safeguard (relative paths, core dumps..)
     cd $basedir
 
+    # Install a new database if $datadir/mysql is empty.
+    if [ `ls -1A $datadir/mysql|wc -l` == "0" ]; then
+
+	echo "Initializing MySQL database: "
+	TMPDIR=/var/tmp $bindir/mysql_install_db
+	chown -R $user:$user "$datadir"
+	chmod 0711 "$datadir"
+    fi
+
+    # Remove stale pidfiles.
+    if [ -z "`/sbin/pidof mysqlmanager`" ] && [ -e $pid_file ]; then
+      echo $echo_n "Removing stale pid file (mysqlmanager)."
+      rm -f $pid_file
+      echo
+    fi
+
+    if [ -z "`/sbin/pidof mysqld`" ] && [ -e $server_pid_file ]; then
+      echo $echo_n "Removing stale pid file (mysqld)."
+      rm -f $server_pid_file
+      echo
+    fi
+
+    # 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
@@ -300,23 +335,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 --default-mysqld-path=@sbindir@/mysqld --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
@@ -325,16 +360,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 ($manager) or server ($bindir/mysqld_safe)"
+      log_failure_msg "Couldn't find MySQL manager ($manager) or server ($bindir/mysqld_safe)"; echo
     fi
     ;;
 
@@ -342,28 +377,28 @@
     # 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 "$mysqlmanager_pid"; return_value=$?
+      wait_for_pid removed "$mysqlmanager_pid"; return_value=$?; echo
 
-      # delete lock for RedHat / SuSE
+      # delete lock for Mandriva Linux
       if test -f $lock_dir
       then
-        rm -f $lock_dir
+        rm -f $lock_dir /var/lock/subsys/mysqld
       fi
       exit $return_value
     else
@@ -386,9 +421,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
     ;;
@@ -410,7 +445,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"