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