#! /bin/sh # # $Id: monit.init.Master,v 1.1 2004/02/12 22:05:45 homyakov Exp $ # # monit Monitors processes and restarts them if they exit # # chkconfig: 345 98 02 # description: monit is a simple daemon process to restart processes if \ # they die. It can also check tcp and udp ports to make sure \ # that they are responding. # processname: monit # pidfile: /var/run/monit.pid # config: /etc/monitrc # Source function library. . /etc/rc.d/init.d/functions [ -r /etc/monitrc ] || exit LOCKFILE=/var/lock/subsys/monit RETVAL=0 start () { echo -n "Starting monit daemon: " daemon monit RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCKFILE return $RETVAL } stop () { echo -n "Stopping monit daemon: " monit quit RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f "$LOCKFILE" sleep 1 # restart slowly return $RETVAL } status () { monit status return $? } restart () { stop start } reload () { echo -n "Reloading monit configuration: " killproc monit -HUP RETVAL=$? echo return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) restart ;; reload) reload ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; *) echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|status}" esac exit $RETVAL