wok-backports view mariadb/stuff/etc/init.d/mysql @ rev 29

Add: mariadb
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Mon Jun 02 00:29:22 2014 +0200 (2014-06-02)
parents
children
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 case "$1" in
19 start)
20 if active_pidfile $PIDFILE mysqld ; then
21 echo "$NAME already running."
22 exit 1
23 fi
24 if [ ! -d /var/lib/mysql/mysql ]; then
25 echo "Initializing $DESC: "
26 rm -rf /var/lib/mysql/* 2> /dev/null
27 mysql_install_db --user=mysql --datadir=/var/lib/mysql
28 fi
29 echo -n "Starting $DESC: $NAME... "
30 $DAEMON $OPTIONS > /dev/null &
31 status
32 sleep 2
33 for i in /etc/mysql.d/* ; do
34 [ -x $i ] || continue
35 echo -n "Running $i..."
36 $i
37 status
38 done
39 ;;
40 stop)
41 if ! active_pidfile $PIDFILE mysqld ; then
42 echo "$NAME is not running."
43 exit 1
44 fi
45 echo -n "Stopping $DESC: $NAME... "
46 kill `cat $PIDFILE`> /dev/null
47 status
48 sleep 2
49 ;;
50 restart)
51 if ! active_pidfile $PIDFILE mysqld ; then
52 echo "$NAME is not running."
53 exit 1
54 fi
55 echo -n "Restarting $DESC: $NAME... "
56 kill `cat $PIDFILE`
57 sleep 2
58 $DAEMON $OPTIONS &
59 status
60 sleep 2
61 ;;
62 *)
63 echo ""
64 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
65 echo ""
66 exit 1
67 ;;
68 esac
70 exit 0