]> git.pld-linux.org Git - packages/mysql.git/blob - mysql.init
- rewrited but still need more work (for handling some command line mysqld
[packages/mysql.git] / mysql.init
1 #!/bin/sh
2 #
3 # mysql         A very fast and reliable SQL database engine
4 #
5 # chkconfig:    2345 90 90
6 #
7 # description:  A very fast and reliable SQL database engine.
8 #
9 # pidfile:      /var/state/mysql/mysqld.pid
10
11 # Source function library
12 . /etc/rc.d/init.d/functions
13
14 # Get network config
15 . /etc/sysconfig/network
16
17 # Get service config
18 [ -f /etc/sysconfig/mysql ] && . /etc/sysconfig/mysql
19
20 # Check that networking is up.
21 if [ "${NETWORKING}" = "no" ]; then
22         echo "WARNING: Networking is down. Mysql service can't be runed."
23         exit 1
24 fi
25
26 case "$mode" in
27         # Check if the service is already running?
28         if [ ! -f /var/lock/subsys/mysql ]; then
29                 show Starting mysql
30                 busy
31                 su mysql -c '/usr/bin/msqld
32                 touch /var/lock/subsys/mysql
33                 deltext
34                 ok
35         else
36                 echo "Mysql already is running"
37         fi
38         touch /var/lock/subsys/mysql
39         ;;
40   stop)
41         show Stopping mysql service
42         killproc postmaster
43         sleep 2
44         rm -f /var/state/mysql/mysqld.pid
45         rm -f /var/lock/subsys/mysql
46         ;;
47   status)
48         status postmaster
49         ;;
50   restart|reload)
51         $0 stop
52         $0 start
53         ;;
54   *)
55         echo "Usage: mysql {start|stop|status|restart|reload}"
56         exit 1
57   'start')
58
59     if test -x $bindir/safe_mysqld
60     then
61       # Give extra arguments to mysqld with the my.cnf file. This script may
62       # be overwritten at next upgrade.
63       $bindir/safe_mysqld --user=$mysql_daemon_user --pid-file=$pid_file --datadir=$datadir &
64     else
65       echo "Can't execute $bindir/safe_mysqld"
66     fi
67     ;;
68
69   'stop')
70     # Stop daemon. We use a signal here to avoid having to know the
71     # root password.
72     if test -f "$pid_file"
73     then
74       mysqld_pid=`cat $pid_file`
75       echo "Killing mysqld with pid $mysqld_pid"
76       kill $mysqld_pid
77       # mysqld should remove the pid_file when it exits.
78     else
79       echo "No mysqld pid file found. Looked for $pid_file."
80     fi
81     ;;
82
83   *)
84     # usage
85     echo "usage: $0 start|stop"
86     exit 1
87     ;;
88 esac
This page took 0.057119 seconds and 4 git commands to generate.