]> git.pld-linux.org Git - packages/monit.git/blobdiff - monit.init
- 5.2.4
[packages/monit.git] / monit.init
index cf68c820fe214531e28ddeea5cb6238c2aec5415..f21315568ab827f954f1d56f6abef5a94749c3e4 100644 (file)
@@ -2,7 +2,7 @@
 #
 # monit                Monitoring daemon
 #
-# chkconfig:   345 99 1
+# chkconfig:   345 99 01
 # description: Monitoring daemon
 #
 
 # Get service config
 [ -f /etc/sysconfig/monit ] && . /etc/sysconfig/monit
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+checkconfig() {
+       local out
+       out=$(/usr/sbin/monit -c /etc/monitrc -t 2>&1)
+       ret=$?
+       if [ $ret != 0 ]; then
+               echo >&2 "$out"
+               exit 1
+       fi
+}
+
+start() {
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/monit ]; then
+               checkconfig
                msg_starting monit
-               daemon monit -c /etc/monitrc -l syslog -d 60
+               daemon --pidfile /var/run/monit.pid /usr/sbin/monit -c /etc/monitrc -s /var/run/monit.state $OPTIONS
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/monit
        else
                msg_already_running monit
        fi
-       ;;
-  stop)
+}
+
+stop() {
        # Stop daemons.
        if [ -f /var/lock/subsys/monit ]; then
                msg_stopping monit
-               daemon monit -c /etc/monitrc quit
+               busy
+               /usr/sbin/monit -c /etc/monitrc quit
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && ok || fail
                rm -f /var/lock/subsys/monit > /dev/null 2>&1
        else
                msg_not_running monit
        fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
-  status)
-       status monit
-       monit -c /etc/monitrc status
-       exit $?
+  stop)
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
-       exit $?
+       checkconfig
+       stop
+       start
        ;;
   reload|force-reload)
        if [ -f /var/lock/subsys/monit ]; then
+               checkconfig
                msg_reloading monit
-               daemon monit -c /etc/monitrc reload
+               busy
+               /usr/sbin/monit -c /etc/monitrc reload
                RETVAL=$?
+               [ $RETVAL -eq 0 ] && ok || fail
        else
-               msg_not_running monit >&2
+               msg_not_running monit
                exit 7
        fi
        ;;
+  checkconfig)
+       checkconfig
+       echo "Config check OK"
+       ;;
+  status)
+       status monit
+       monit -c /etc/monitrc status
+       exit $?
+       ;;
   *)
-       msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+       msg_usage "$0 {start|stop|restart|reload|force-reload|checkconfig|status}"
        exit 3
 esac
 
This page took 0.077356 seconds and 4 git commands to generate.