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

Create some /var/run/<dir> in /etc/init.d/<daemon> scritps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 18 20:24:07 2014 +0000 (2014-05-18)
parents d4a8ce10c154
children 7f188676b59c
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
pascal@16681 18 if [ ! -d /var/lib/mysql ]; then
pascal@16681 19 mkdir -p /var/lib/mysql
pascal@16681 20 chown mysql.mysql /var/lib/mysql
pascal@16681 21 fi
erjo@13054 22 case "$1" in
erjo@13054 23 start)
erjo@13054 24 if active_pidfile $PIDFILE mysqld ; then
erjo@13054 25 echo "$NAME already running."
erjo@13054 26 exit 1
erjo@13054 27 fi
erjo@13054 28 if [ ! -d /var/lib/mysql/mysql ]; then
erjo@13054 29 echo "Initializing $DESC: "
erjo@13054 30 rm -rf /var/lib/mysql/* 2> /dev/null
erjo@13054 31 mysql_install_db --user=mysql --datadir=/var/lib/mysql
erjo@13054 32 fi
erjo@13054 33 echo -n "Starting $DESC: $NAME... "
erjo@13054 34 $DAEMON $OPTIONS > /dev/null &
erjo@13054 35 status
erjo@13054 36 sleep 2
erjo@13054 37 for i in /etc/mysql.d/* ; do
erjo@13054 38 [ -x $i ] || continue
erjo@13054 39 echo -n "Running $i..."
erjo@13054 40 $i
erjo@13054 41 status
erjo@13054 42 done
erjo@13054 43 ;;
erjo@13054 44 stop)
erjo@13054 45 if ! active_pidfile $PIDFILE mysqld ; then
erjo@13054 46 echo "$NAME is not running."
erjo@13054 47 exit 1
erjo@13054 48 fi
erjo@13054 49 echo -n "Stopping $DESC: $NAME... "
erjo@13054 50 kill `cat $PIDFILE`> /dev/null
erjo@13054 51 status
erjo@13054 52 sleep 2
erjo@13054 53 ;;
erjo@13054 54 restart)
erjo@13054 55 if ! active_pidfile $PIDFILE mysqld ; then
erjo@13054 56 echo "$NAME is not running."
erjo@13054 57 exit 1
erjo@13054 58 fi
erjo@13054 59 echo -n "Restarting $DESC: $NAME... "
erjo@13054 60 kill `cat $PIDFILE`
erjo@13054 61 sleep 2
erjo@13054 62 $DAEMON $OPTIONS &
erjo@13054 63 status
erjo@13054 64 sleep 2
erjo@13054 65 ;;
erjo@13054 66 *)
erjo@13054 67 echo ""
erjo@13054 68 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
erjo@13054 69 echo ""
erjo@13054 70 exit 1
erjo@13054 71 ;;
erjo@13054 72 esac
erjo@13054 73
erjo@13054 74 exit 0