wok-stable view mysql/stuff/etc/init.d/mysql @ rev 1147

mysql: init database in /etc/init.d/mysql, not post_install
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jul 26 13:40:35 2008 +0000 (2008-07-26)
parents 91e8a40cf500
children 49b2e5444f68
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 [ -f $PIDFILE ] ; 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 &
31 status
32 sleep 2
33 ;;
34 stop)
35 if [ ! -f $PIDFILE ] ; then
36 echo "$NAME is not running."
37 exit 1
38 fi
39 echo -n "Stopping $DESC: $NAME... "
40 kill `cat $PIDFILE`
41 status
42 sleep 2
43 ;;
44 restart)
45 if [ ! -f $PIDFILE ] ; then
46 echo "$NAME is not running."
47 exit 1
48 fi
49 echo -n "Restarting $DESC: $NAME... "
50 kill `cat $PIDFILE`
51 sleep 2
52 $DAEMON $OPTIONS &
53 status
54 sleep 2
55 ;;
56 *)
57 echo ""
58 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
59 echo ""
60 exit 1
61 ;;
62 esac
64 exit 0