#!/bin/sh
#
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
#
# chkconfig: 345 85 15
# description: Mysql deamon start/stop script.
#
# Usually this is put in /etc/init.d (at least on machines SYSV R4
# based systems) and linked to /etc/rc3.d/S99mysql. When this is done
# the mysql server will be started when the machine is started.

# Source function library.
. /etc/rc.d/init.d/functions

PATH=/sbin:/usr/bin:/usr/sbin:/bin
basedir=/
bindir=/usr/bin
export PATH

mode=$1

# The following test may be removed if mysqld isn't to be run as root.
if test ! -w /
then
  echo "$0: this script must be run as root ... fatal error"
  exit 1
fi

# Safeguard (relative paths, core dumps..)
cd $basedir

case "$mode" in
 start)
       if test -x $bindir/safe_mysqld
       then
         # -l means start with log.
         $bindir/safe_mysqld -l &
       else
         echo "Can't execute $bindir/safe_mysqld"
       fi
       ;;
 stop)
       $bindir/mysqladmin shutdown
       ;;
 status)
       status mysqld
       ;;
 restart)
       $0 stop
       $0 start
       ;;
  *)
    echo "Usage: mysql {start|stop|status|restart}"
    exit 1
    ;;
esac
