wok-next view mariadb/stuff/etc/init.d/mysql @ rev 19374
Ip dialog (1.3-20160424)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Aug 12 08:42:46 2016 +0200 (2016-08-12) |
parents | 0d8a1a3edc72 |
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="$(_ '%s server' MySQL)"
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 _ '%s is already running.' $NAME
26 exit 1
27 fi
28 if [ ! -d /var/lib/mysql/mysql ]; then
29 action 'Initializing %s...' "$DESC"
30 rm -rf /var/lib/mysql/* 2>/dev/null
31 mysql_install_db --user=mysql --datadir=/var/lib/mysql
32 status
33 fi
34 action 'Starting %s: %s...' "$DESC" $NAME
35 $DAEMON $OPTIONS >/dev/null &
36 status
37 sleep 2
38 for i in /etc/mysql.d/* ; do
39 [ -x $i ] || continue
40 action 'Running %s...' $i
41 $i
42 status
43 done
44 ;;
45 stop)
46 if ! active_pidfile $PIDFILE mysqld ; then
47 _ '%s is not running.' $NAME
48 exit 1
49 fi
50 action 'Stopping %s: %s...' "$DESC" $NAME
51 kill $(cat $PIDFILE) >/dev/null
52 status
53 sleep 2
54 ;;
55 restart)
56 if ! active_pidfile $PIDFILE mysqld ; then
57 _ '%s is not running.' $NAME
58 exit 1
59 fi
60 action 'Restarting %s: %s...' "$DESC" $NAME
61 kill $(cat $PIDFILE)
62 sleep 2
63 $DAEMON $OPTIONS &
64 status
65 sleep 2
66 ;;
67 *)
68 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]"
69 newline
70 exit 1
71 ;;
72 esac
74 exit 0