packages/libs/mysql/files/mysqld.init
jow b8b0482937 [packages] mysql: properly handle quoted datadirs in initscript
git-svn-id: svn://svn.openwrt.org/openwrt/packages@25243 3c298f89-4303-0410-b956-a3cf2f4a3e73
2011-01-29 18:51:47 +00:00

30 lines
762 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2010 OpenWrt.org
START=95
STOP=10
PID=/var/run/mysqld.pid
CMD=/usr/bin/mysqld
start() {
local datadir=$(sed -n -e "s/^[[:space:]]*datadir[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" /etc/my.cnf)
if [ ! -d "$datadir" ]; then
echo "Error: datadir in /etc/my.cnf ($datadir) doesn't exist"
return 1
elif [ ! -f "$datadir/mysql/tables_priv.MYD" ]; then
echo "Error: I didn't detect a privileges table, you might need to run mysql_install_db --force to initialize the system tables"
return 1
else
echo -n "Starting MySQL daemon... "
start-stop-daemon -x $CMD -b -S -- --pid-file=$PID
echo "done"
fi
}
stop() {
echo -n "Stopping MySQL daemon... "
service_kill ${CMD##*/} $PID
echo "done"
}