#!/bin/sh # mysql # Source functions library source /etc/rc.d/init.d/functions log_script_name "$0 $*" pid_file=/srv/mysql/`/bin/hostname`.pid mysql_start() { if [ -f "$pid_file" ]; then if /bin/ps p `cat $pid_file` | grep mysqld >/dev/null; then # Warning, running... return ${EXIT_CODE_WARNING} else rm -f $pid_file if [ -f $pid_file ]; then return ${EXIT_CODE_FAILURE} fi fi fi /usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null & return $? } mysql_stop() { if [ -s "$pid_file" ]; then kill `cat $pid_file` sleep 1 while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ] do [ -z "$flags" ] flags=a$flags sleep 1 done if [ -s $pid_file ]; then return ${EXIT_CODE_FAILURE} fi return 0 else # print_status warning not_running return ${EXIT_CODE_WARNING} fi } case "$1" in start) cmd_run_log_box_warn "MySQL start" mysql_start ;; stop) cmd_run_log_box_warn "MySQL stop" mysql_stop ;; reload) cmd_run_log_box_warn "MySQL reload" reloadproc mysqld ;; restart) $0 stop sleep 1 $0 start ;; status) statusproc mysqld ;; *) echo "Usage: $0 {start|stop|reload|restart|status}" exit ${EXIT_CODE_FAILURE} ;; esac exit $?