5 # Check if MySQL is enabled in OMD. If not terminate.
8 if [ "$CONFIG_MYSQL" != on
] ; then
12 MYSQLD_PID
=tmp
/run
/mysqld
/mysqld.pid
15 ## Checks if there is a server running and if so if it is accessible.
17 # check_alive insists on a pingable server
18 # check_dead also fails if there is a lost mysqld in the process list
20 # Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
22 ping_output
=`mysqladmin --defaults-file=$MYSQL_CNF ping 2>&1`; ping_alive
=$
(( ! $?
))
25 if [ -f "$MYSQLD_PID" ] && ps
`cat $MYSQLD_PID` >/dev
/null
2>&1; then ps_alive
=1; fi
27 if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
28 [ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
31 if [ "$2" = "warn" ]; then
32 echo -e "$ps_alive processes alive and 'mysqladmin --defaults-file=$MYSQL_CNF ping' resulted in\n$ping_output\n"
39 if mysqld_status check_alive nowarn
; then
40 echo -n "already running. "
43 mysqld_safe
--defaults-file=$MYSQL_CNF >/dev
/null
2>&1 &
45 while mysqld_status check_dead nowarn
; do
46 if [ $i = '10' ]; then
59 if mysqld_status check_dead nowarn
; then
60 echo -n 'Not running. '
64 mysqladmin
--defaults-file=$MYSQL_CNF shutdown
66 # wait until really stopped
68 while ! mysqld_status check_dead nowarn
; do
69 if [ $i = '10' ]; then
82 if [ ! -e ~
/var
/mysql
/mysql
] ; then
83 echo "first start of MySQL, creating initial database..."
84 mysql_install_db
--defaults-file=$MYSQL_CNF > $OMD_ROOT/var
/log
/omd.log
2>&1
86 echo "failed: please have a look at $OMD_ROOT/var/log/omd.log"
87 echo "and http://omdistro.org/wiki/omd/FAQ"
96 echo -n "Starting MySQL... "
98 if mysql_wait_start
; then
100 __init_hook
$0 $1 post
0
104 __init_hook
$0 $1 post
1
109 echo -n "Stopping MySQL... "
110 if mysql_wait_stop
; then
112 __init_hook
$0 $1 post
0
116 __init_hook
$0 $1 post
1
128 if mysqld_status check_alive nowarn
; then
129 echo "$(mysqladmin version)"
131 echo "MySQL is stopped."
136 echo "Usage: $0 {start|stop|restart|reload|status}"