summaryrefslogtreecommitdiff
path: root/support-files
diff options
context:
space:
mode:
authorunknown <lenz@mysql.com>2005-03-15 12:23:14 +0100
committerunknown <lenz@mysql.com>2005-03-15 12:23:14 +0100
commit39005884b546d9a250dd4d7be113882b292b7146 (patch)
tree4dc7b11b72e87a7daef7f6f9fa620f0d4bcbc3c1 /support-files
parent90697f2467fda156d9a939738e443200a090884f (diff)
downloadmariadb-git-39005884b546d9a250dd4d7be113882b292b7146.tar.gz
Applied some changes to the mysql.server init script that are already shipped as an additional patch
in the 4.1.10a RPMs for SLES9/RHEL3: - small improvement: use LSB functions to display startup success and failure, if available. Fall back to more primitive builtin functions otherwise. - joined two pieces of code performing the same functionality into one "wait_for_pid" function - added a "reload" function (LSB requirement) support-files/mysql.server.sh: - small improvement: use LSB functions to display startup success and failure, if available. Fall back to builtin functions otherwise. - joined two pieces of code performing the same functionality into one "wait_for_pid" function - added a "reload" function (LSB requirement)
Diffstat (limited to 'support-files')
-rw-r--r--support-files/mysql.server.sh61
1 files changed, 44 insertions, 17 deletions
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 849f913bf6c..4283af919a5 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -54,6 +54,17 @@ else
bindir="$basedir/bin"
fi
+#
+# 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
+ alias log_success_msg="echo \ SUCCESS! "
+ alias log_failure_msg="echo \ ERROR! "
+fi
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
export PATH
@@ -75,6 +86,20 @@ parse_arguments() {
done
}
+wait_for_pid () {
+ for((i=0; i<35; i++)); do
+ sleep 1
+ test -s $pid_file && i='' && break
+ echo $echo_n ".$echo_c"
+ done
+
+ if test -z "$i" ; then
+ log_success_msg
+ else
+ log_failure_msg
+ fi
+}
+
# Get arguments from the my.cnf file,
# groups [mysqld] [mysql_server] and [mysql.server]
if test -x ./bin/my_print_defaults
@@ -151,14 +176,17 @@ case "$mode" in
then
# Give extra arguments to mysqld with the my.cnf file. This script may
# be overwritten at next upgrade.
+ echo $echo_n "Starting MySQL"
$bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file >/dev/null 2>&1 &
+ wait_for_pid
+
# Make lock for RedHat / SuSE
if test -w /var/lock/subsys
then
touch /var/lock/subsys/mysql
fi
else
- echo "Can't execute $bindir/mysqld_safe from dir $basedir"
+ log_failure_msg "Can't execute $bindir/mysqld_safe"
fi
;;
@@ -168,29 +196,18 @@ case "$mode" in
if test -s "$pid_file"
then
mysqld_pid=`cat $pid_file`
- echo "Killing mysqld with pid $mysqld_pid"
+ echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
# mysqld should remove the pid_file when it exits, so wait for it.
+ wait_for_pid
- sleep 1
- while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
- do
- [ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".$echo_c"
- flags=a$flags
- sleep 1
- done
- if [ -s $pid_file ]
- then echo " gave up waiting!"
- elif [ -n "$flags" ]
- then echo " done"
- fi
# delete lock for RedHat / SuSE
if test -f /var/lock/subsys/mysql
then
rm -f /var/lock/subsys/mysql
fi
else
- echo "No mysqld pid file found. Looked for $pid_file."
+ log_failure_msg "MySQL PID file could not be found!"
fi
;;
@@ -199,11 +216,21 @@ case "$mode" in
# running or not, start it again.
$0 stop
$0 start
- ;;
+ ;;
+
+ 'reload')
+ if test -s "$pid_file" ; then
+ mysqld_pid=`cat $pid_file`
+ kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
+ touch $pid_file
+ else
+ log_failure_msg "MySQL PID file could not be found!"
+ fi
+ ;;
*)
# usage
- echo "Usage: $0 start|stop|restart"
+ echo "Usage: $0 start|stop|restart|reload"
exit 1
;;
esac