#!/bin/sh
#
# pwrstatd    This shell script takes care of starting and stopping
#             standalone pwrstatd.
#
# chkconfig: 2345 99 99
# description: PowerPanel for Linux is a software program that monitors 
#              the status of your CyberPower Systems UPS.
# processname: pwrstatd
# config: /etc/pwrstatd.conf
# /etc/init.d/pwrstatd symbolic link /usr/sbin/pwrstatd

PWRSTATD_BIN=/usr/sbin/pwrstatd
test -x $PWRSTATD_BIN || { echo "$PWRSTATD_BIN not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

. /etc/rc.status

rc_reset

VERSION="1.3.3"

case "$1" in
    start)
	echo -n "Starting pwrstatd $VERSION"
	/sbin/startproc -l /var/log/pwrstatd.log $PWRSTATD_BIN
	rc_status -v
	;;
    stop)
	echo -n "Shutting down pwrstatd $VERSION"
	/sbin/killproc -TERM $PWRSTATD_BIN
	rc_status -v
        ;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    force-reload)
	echo -n "Reload service pwrstatd $VERSION"
	/sbin/killproc -HUP $PWRSTATD_BIN
	rc_status -v
	;;
    reload)
	echo -n "Reload service pwrstatd $VERSION"
	/sbin/killproc -HUP $PWRSTATD_BIN
	rc_status -v
	;;
    status)
	echo -n "Checking for service pwrstatd $VERSION"
	/sbin/checkproc $PWRSTATD_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|force-reload|reload}"
	exit 1
	;;
esac

rc_exit
