List:Commits« Previous MessageNext Message »
From:Monty Taylor Date:March 22 2007 6:47am
Subject:bk commit into 5.0 tree (mtaylor:1.2407) BUG#27367
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of mtaylor. When mtaylor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-03-21 22:47:48-07:00, mtaylor@qualinost.(none) +1 -0
  BUG#27367 mysql.server should be LSB init script compliant
  Also made mysql.server work on Debian and Ubuntu systems in the spirit 
  of LSB compliance.

  support-files/mysql.server.sh@stripped, 2007-03-21 22:47:46-07:00, mtaylor@qualinost.(none)
+61 -15
    BUG#27367 Added functions to shadow extra functions needed for Debian.
    Made the entire script use the new functions. 
    Return success on stopping a stopped server per LSB spec.
    Made reload report success or failure. 
    Removed an unndeeded explicit exit 0 for consistency with the rest of the file.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mtaylor
# Host:	qualinost.(none)
# Root:	/home/mtaylor/src/mysql-5.0-initstatus

--- 1.56/support-files/mysql.server.sh	2007-03-21 22:47:53 -07:00
+++ 1.57/support-files/mysql.server.sh	2007-03-21 22:47:53 -07:00
@@ -99,6 +99,10 @@
   {
     echo " ERROR! $@"
   }
+  log_warning_msg()
+  {
+    echo " WARNING! $@"
+  }
 fi
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
@@ -117,6 +121,32 @@
     *)       echo_n=   echo_c='\c' ;;
 esac
 
+is_defined()
+{
+  declare -F | grep -q $1
+  return $?
+}
+# These are LSB extensions used by Debian, but we want to play nice everywhere
+if ! is_defined log_progress_msg ; then 
+  log_progress_msg()
+  {
+    echo $echo_n "$1$echo_c"
+  }
+fi 
+if ! is_defined log_end_msg ; then 
+  log_end_msg()
+  {
+    # Don't actually want to do anything if the system doesn't have this
+    end_msg=$1
+  }
+fi 
+if ! is_defined log_daemon_msg ; then 
+  log_daemon_msg()
+  {
+    echo $echo_n "$1"
+  }
+fi
+
 parse_server_arguments() {
   for arg do
     case "$arg" in
@@ -162,16 +192,14 @@
         test ! -s $pid_file && i='' && break
         ;;
       *)
-        echo "wait_for_pid () usage: wait_for_pid created|removed"
-        exit 1
+        log_failure_msg "wait_for_pid () usage: wait_for_pid created|removed"
         ;;
     esac
-    echo $echo_n ".$echo_c"
+    log_progress_msg "."
     i=`expr $i + 1`
   done
 
   if test -z "$i" ; then
-    log_success_msg
     return 0
   else
     log_failure_msg
@@ -277,13 +305,14 @@
       manager=$sbindir/mysqlmanager
     fi
 
-    echo $echo_n "Starting MySQL"
+    log_daemon_msg "Starting MySQL" "mysqld"
     if test -x $manager -a "$use_mysqld_safe" = "0"
     then
       if test -n "$other_args"
       then
+        log_end_msg 1
         log_failure_msg "MySQL manager does not support options '$other_args'"
-        exit 1
+	exit 2
       fi
       # Give extra arguments to mysqld with the my.cnf file. This script may
       # be overwritten at next upgrade.
@@ -295,7 +324,7 @@
       then
         touch /var/lock/subsys/mysqlmanager
       fi
-      exit $return_value
+      log_end_msg $return_value
     elif test -x $bindir/mysqld_safe
     then
       # Give extra arguments to mysqld with the my.cnf file. This script
@@ -309,9 +338,11 @@
       then
         touch /var/lock/subsys/mysql
       fi
-      exit $return_value
+      log_end_msg $return_value
     else
+      log_end_msg 1
       log_failure_msg "Couldn't find MySQL manager or server"
+      exit 1
     fi
     ;;
 
@@ -322,6 +353,8 @@
     # The RedHat / SuSE lock directory to remove
     lock_dir=/var/lock/subsys/mysqlmanager
 
+    log_daemon_msg "Shutting down MySQL" "mysqld"
+
     # If the manager pid_file doesn't exist, try the server's
     if test ! -s "$pid_file"
     then
@@ -331,8 +364,8 @@
 
     if test -s "$pid_file"
     then
-      mysqlmanager_pid=`cat $pid_file`
-      echo $echo_n "Shutting down MySQL"
+
+      read mysqlmanager_pid < $pid_file 
       kill $mysqlmanager_pid
       # mysqlmanager should remove the pid_file when it exits, so wait for it.
       wait_for_pid removed; return_value=$?
@@ -342,16 +375,19 @@
       then
         rm -f $lock_dir
       fi
+      log_end_msg $return_value
       exit $return_value
-    else
-      log_failure_msg "MySQL manager or server PID file could not be found!"
     fi
+    # Stopping a server that isn't running is considered a success
+    # But we can warn about it anyway
+    log_end_msg 0
+    log_warning_msg "MySQL manager or server PID file could not be found!"
     ;;
 
   'restart')
     # Stop the service and regardless of whether it was
     # running or not, start it again.
-    if $0 stop  $other_args; then
+    if $0 stop $other_args; then
       $0 start $other_args
     else
       log_failure_msg "Failed to stop running server, so refusing to try to start."
@@ -361,10 +397,17 @@
 
   'reload'|'force-reload')
     if test -s "$server_pid_file" ; then
+      log_daemon_msg "Reloading MySQL" 
       read mysqld_pid <  $server_pid_file
-      kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
+      if kill -HUP $mysqld_pid ; then 
+        log_end_msg 0
+      else 
+        log_end_msg 1
+        exit 1
+      fi
       touch $server_pid_file
     else
+      log_end_msg 1
       log_failure_msg "MySQL PID file could not be found!"
       exit 1
     fi
@@ -375,8 +418,8 @@
       read mysqld_pid < $server_pid_file
       if kill -0 $mysqld_pid 2>/dev/null ; then 
         log_success_msg "MySQL running ($mysqld_pid)"
-        exit 0
       else
+	log_end_msg 1
         log_failure_msg "MySQL is not running, but PID file exists"
         exit 1
       fi
@@ -390,12 +433,15 @@
           lockfile=/var/lock/subsys/mysql
         fi 
         if test -f $lockfile ; then 
+	  log_end_msg 1
           log_failure_msg "MySQL is not running, but lock exists"
           exit 2
         fi 
+        log_end_msg 1
         log_failure_msg "MySQL is not running"
         exit 3
       else
+	log_end_msg 1
         log_failure_msg "MySQL is running but PID file could not be found"
         exit 4
       fi
Thread
bk commit into 5.0 tree (mtaylor:1.2407) BUG#27367Monty Taylor22 Mar