[package] add mysql-server (#7384)
[openwrt/svn-archive/archive.git] / libs / mysql / files / mysqld.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2010 OpenWrt.org
3 START=95
4 STOP=10
5
6
7 PID=/var/run/mysqld.pid
8 CMD=/usr/bin/mysqld
9
10 start() {
11 DATADIR=`grep datadir /etc/my.cnf | cut -f 2 -d =`
12 if [ ! -d $DATADIR ]; then
13 echo "Error: datadir in /etc/my.cnf ($DATADIR) doesn't exist"
14 return 1
15 elif [ ! -f $DATADIR/mysql/tables_priv.MYD ]; then
16 echo "Error: I didn't detect a privileges table, you might need to run mysql_install_db --force to initialize the system tables"
17 return 1
18 else
19 start-stop-daemon -x $CMD -p $PID -b -m -S
20 fi
21 }
22
23 stop() {
24 echo -n "Stopping Mysqld..."
25 start-stop-daemon -x $CMD -p $PID -K
26 ret=$?
27 if [ -f "$PID" ]; then
28 rm "$PID"
29 fi
30 return ${ret}
31 }
32
33