updated on Thu Jan 19 00:16:31 UTC 2012
[aur-mirror.git] / mysql51 / mysqld
blob1ac88a7cc02d76ab196bd16cc1445ee89d0f3f71
1 #!/bin/bash
3 # general config
4 . /etc/rc.conf
5 . /etc/rc.d/functions
7 getPID() {
8 echo $(pgrep -u mysql mysqld 2>/dev/null);
11 case "$1" in
12 start)
13 stat_busy "Starting MySQL Server"
14 [ ! -d /var/run/mysqld ] && install -d -g mysql -o mysql /var/run/mysqld &>/dev/null
15 if [ -z "$(getPID)" ]; then
16 /usr/bin/mysqld_safe --user=mysql &>/dev/null &
17 if [ $? -gt 0 ]; then
18 stat_fail
19 exit 1
20 else
21 timeo=30
22 while [ $timeo -gt 0 ]; do
23 response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
24 echo "$response" | grep -q "mysqld is alive" && break
25 sleep 1
26 let timeo=${timeo}-1
27 done
28 if [ $timeo -eq 0 ]; then
29 stat_fail
30 exit 1
31 else
32 echo $(getPID) > /var/run/mysqld/mysqld.pid
33 add_daemon mysqld
34 stat_done
37 else
38 stat_fail
39 exit 1
43 stop)
44 stat_busy "Stopping MySQL Server"
45 if [ ! -z "$(getPID)" ]; then
46 timeo=30
47 kill $(getPID) &> /dev/null
48 if [ $? -gt 0 ]; then
49 stat_fail
50 exit 1
52 while [ ! -z "$(getPID)" -a $timeo -gt 0 ]; do
53 sleep 1
54 let timeo=${timeo}-1
55 done
56 if [ -z "$(getPID)" ]; then
57 rm -f /var/run/mysqld/mysqld.pid &>/dev/null
58 rm_daemon mysqld
59 stat_done
60 else
61 stat_fail
62 exit 1
64 else
65 stat_fail
66 exit 1
70 restart)
71 $0 stop
72 $0 start
75 echo "usage: $0 {start|stop|restart}"
76 esac
77 exit 0