Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > 720f0ad389e4d8a64778a620389844c1 > files > 14

mysql-cluster-7.1.3-1mdv2010.1.src.rpm

--- support-files/mysql.server.sh	2010-01-29 19:06:40.000000000 +0100
+++ support-files/mysql.server.sh.oden	2010-02-12 15:09:26.757671793 +0100
@@ -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: - 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
@@ -36,7 +36,10 @@
 #   and copy my_print_defaults to /usr/bin
 # - Add the path to the mysql-installation-directory to the basedir variable
 #   below.
-#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
 # 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.
 
@@ -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,34 @@
     # 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-cluster`" ] && [ -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,12 +334,12 @@
       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
@@ -313,13 +347,15 @@
       "$manager" \
         --mysqld-safe-compatible \
         --user="$user" \
+        --run-as-service \
+	--default-mysqld-path=@sbindir@/mysqld \
         --pid-file="$pid_file" >/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/mysqlmanager
+        touch /var/lock/subsys/mysqlmanager /var/lock/subsys/mysqld
       fi
       exit $return_value
     elif test -x $bindir/mysqld_safe
@@ -327,13 +363,13 @@
       # Give extra arguments to mysqld with the my.cnf file. This script
       # 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=$?
+      $bindir/mysqld_safe --datadir=$datadir --mysqld=mysqld --pid-file=$server_pid_file $other_args >/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/mysql
+        touch /var/lock/subsys/mysqld
       fi
       exit $return_value
     else
@@ -345,14 +381,15 @@
     # 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"
@@ -361,23 +398,23 @@
       
       if (kill -0 $mysqlmanager_pid 2>/dev/null)
       then
-        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
       else
         log_failure_msg "MySQL manager or server process #$mysqlmanager_pid is not running!"
         rm $pid_file
       fi
       
-      # 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
-      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
     ;;
 
@@ -396,9 +433,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
     ;;
@@ -420,7 +457,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"