Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 5183cb97850ab34770e23cc9d644e0d0 > files > 1

watchdog-5.6-2mdv2010.0.i586.rpm

#! /bin/sh
#
# chkconfig: - 27 46
# description: A software watchdog
#
# rc file author: Marc Merlin <marcsoft@merlins.org>
#                 Henning P. Schmiedehausen <hps@tanstaafl.de>

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0

VERBOSE="no"
if [ -f /etc/sysconfig/watchdog ]; then
    . /etc/sysconfig/watchdog
fi

RETVAL=0
prog=watchdog
pidfile=/var/run/watchdog.pid
lockfile=/var/lock/subsys/watchdog

start() {

	gprintf "Starting %s: " "$prog"
	if [ -n "$(pidofproc $prog)" ]; then
		gprintf "%s: already running" "$prog"
		echo_failure
		echo
		return 1
	fi
	if [ "$VERBOSE" = "yes" ]; then
	    daemon /usr/sbin/${prog} -v
	else
	    daemon /usr/sbin/${prog}
        fi
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $lockfile
	[ $RETVAL -eq 0 ] && echo_success
	[ $RETVAL -ne 0 ] && echo_failure
	echo
	return $RETVAL
}

stop() {
	gprintf "Stopping %s: " "$prog"
	# We are forcing it to _only_ use -TERM as killproc could use
	# -KILL which would result in BMC timer not being set properly 
	# and reboot the box.
	killproc $prog -TERM
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
	return $RETVAL
}

restart() {
  	stop
	sleep 6
	start
}	

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  reload|restart)
  	restart
	;;
  condrestart)
    if [ -f $lockfile ]; then
		restart
    fi
    ;;
  status)
	status $prog
	RETVAL=$?
	;;
  *)
	gprintf "Usage: %s {start|stop|restart|status|condrestart}\n" "$0"
	exit 1
esac