wok annotate mariadb/stuff/etc/init.d/mysql @ rev 13054

Add: mariadb
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed Jun 20 15:35:34 2012 +0200 (2012-06-20)
parents
children 0d8a1a3edc72
rev   line source
erjo@13054 1 #!/bin/sh
erjo@13054 2 # /etc/init.d/mysql : Start, stop and restart MySQL server on SliTaz, at
erjo@13054 3 # boot time or with the command line.
erjo@13054 4 #
erjo@13054 5 # To start MySQL server at boot time, just put mysql in the $RUN_DAEMONS
erjo@13054 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
erjo@13054 7 #
erjo@13054 8 . /etc/init.d/rc.functions
erjo@13054 9 . /etc/daemons.conf
erjo@13054 10
erjo@13054 11 NAME=Mysql
erjo@13054 12 DESC="MySQL server"
erjo@13054 13 DAEMON=/usr/bin/mysqld_safe
erjo@13054 14 OPTIONS=$MYSQL_OPTIONS
erjo@13054 15 PIDFILE=/var/run/mysqld/mysql.pid
erjo@13054 16 [ -n "$OPTIONS" ] || OPTIONS="--pid-file=$PIDFILE --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock"
erjo@13054 17
erjo@13054 18 case "$1" in
erjo@13054 19 start)
erjo@13054 20 if active_pidfile $PIDFILE mysqld ; then
erjo@13054 21 echo "$NAME already running."
erjo@13054 22 exit 1
erjo@13054 23 fi
erjo@13054 24 if [ ! -d /var/lib/mysql/mysql ]; then
erjo@13054 25 echo "Initializing $DESC: "
erjo@13054 26 rm -rf /var/lib/mysql/* 2> /dev/null
erjo@13054 27 mysql_install_db --user=mysql --datadir=/var/lib/mysql
erjo@13054 28 fi
erjo@13054 29 echo -n "Starting $DESC: $NAME... "
erjo@13054 30 $DAEMON $OPTIONS > /dev/null &
erjo@13054 31 status
erjo@13054 32 sleep 2
erjo@13054 33 for i in /etc/mysql.d/* ; do
erjo@13054 34 [ -x $i ] || continue
erjo@13054 35 echo -n "Running $i..."
erjo@13054 36 $i
erjo@13054 37 status
erjo@13054 38 done
erjo@13054 39 ;;
erjo@13054 40 stop)
erjo@13054 41 if ! active_pidfile $PIDFILE mysqld ; then
erjo@13054 42 echo "$NAME is not running."
erjo@13054 43 exit 1
erjo@13054 44 fi
erjo@13054 45 echo -n "Stopping $DESC: $NAME... "
erjo@13054 46 kill `cat $PIDFILE`> /dev/null
erjo@13054 47 status
erjo@13054 48 sleep 2
erjo@13054 49 ;;
erjo@13054 50 restart)
erjo@13054 51 if ! active_pidfile $PIDFILE mysqld ; then
erjo@13054 52 echo "$NAME is not running."
erjo@13054 53 exit 1
erjo@13054 54 fi
erjo@13054 55 echo -n "Restarting $DESC: $NAME... "
erjo@13054 56 kill `cat $PIDFILE`
erjo@13054 57 sleep 2
erjo@13054 58 $DAEMON $OPTIONS &
erjo@13054 59 status
erjo@13054 60 sleep 2
erjo@13054 61 ;;
erjo@13054 62 *)
erjo@13054 63 echo ""
erjo@13054 64 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
erjo@13054 65 echo ""
erjo@13054 66 exit 1
erjo@13054 67 ;;
erjo@13054 68 esac
erjo@13054 69
erjo@13054 70 exit 0