3cd8a4
#! /bin/sh
3cd8a4
#
3cd8a4
# watchdog - a watchdog daemon
3cd8a4
#
3cd8a4
# chkconfig: - 27 46
3cd8a4
# description: A watchdog daemon
3cd8a4
#
3cd8a4
# rc file author: Marc Merlin <marcsoft@merlins.org>
3cd8a4
#                 Henning P. Schmiedehausen <hps@tanstaafl.de>
3cd8a4
#                 Richard W.M. Jones <rjones@redhat.com>
3cd8a4
3cd8a4
# Source function library.
3cd8a4
. /etc/rc.d/init.d/functions
3cd8a4
3cd8a4
[ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0
3cd8a4
3cd8a4
VERBOSE="no"
3cd8a4
if [ -f /etc/sysconfig/watchdog ]; then
3cd8a4
    . /etc/sysconfig/watchdog
3cd8a4
fi
3cd8a4
3cd8a4
RETVAL=0
3cd8a4
prog=watchdog
3cd8a4
pidfile=/var/run/watchdog.pid
3cd8a4
lockfile=/var/lock/subsys/watchdog
3cd8a4
3cd8a4
start() {
3cd8a4
3cd8a4
	echo -n $"Starting $prog: "
3cd8a4
	if [ -n "$(pidofproc $prog)" ]; then
3cd8a4
		echo -n $"$prog: already running"
3cd8a4
		echo_failure
3cd8a4
		echo
3cd8a4
		return 1
3cd8a4
	fi
3cd8a4
	if [ "$VERBOSE" = "yes" ]; then
3cd8a4
	    daemon /usr/sbin/${prog} -v
3cd8a4
	else
3cd8a4
	    daemon /usr/sbin/${prog}
3cd8a4
        fi
3cd8a4
	RETVAL=$?
3cd8a4
	echo
3cd8a4
	[ $RETVAL -eq 0 ] && touch $lockfile
3cd8a4
	[ $RETVAL -eq 0 ] && echo_success
3cd8a4
	[ $RETVAL -ne 0 ] && echo_failure
3cd8a4
	return $RETVAL
3cd8a4
}
3cd8a4
3cd8a4
stop() {
3cd8a4
	echo -n "Stopping $prog: "
3cd8a4
	# We are forcing it to _only_ use -TERM as killproc could use
3cd8a4
	# -KILL which would result in BMC timer not being set properly 
3cd8a4
	# and reboot the box.
3cd8a4
	killproc $prog -TERM
3cd8a4
	RETVAL=$?
3cd8a4
	echo
3cd8a4
	[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
3cd8a4
	return $RETVAL
3cd8a4
}
3cd8a4
3cd8a4
restart() {
3cd8a4
  	stop
3cd8a4
	sleep 6
3cd8a4
	start
3cd8a4
}	
3cd8a4
3cd8a4
case "$1" in
3cd8a4
  start)
3cd8a4
  	start
3cd8a4
	;;
3cd8a4
  stop)
3cd8a4
  	stop
3cd8a4
	;;
3cd8a4
  reload|restart)
3cd8a4
  	restart
3cd8a4
	;;
3cd8a4
  condrestart)
3cd8a4
    if [ -f $lockfile ]; then
3cd8a4
	restart
3cd8a4
    fi
3cd8a4
    ;;
3cd8a4
  status)
3cd8a4
	status $prog
3cd8a4
	RETVAL=$?
3cd8a4
	;;
3cd8a4
  *)
3cd8a4
	echo $"Usage: $0 {start|stop|restart|status|condrestart}"
3cd8a4
	exit 1
3cd8a4
esac
3cd8a4
3cd8a4
exit $RETVAL