#!/bin/bash
#
# 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

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

[ -x /usr/sbin/pwrstatd ] || exit 0

PWRSTATD_BIN=/usr/sbin/pwrstatd
PROG="pwrstatd"
VERSION="1.3.3"
RETVAL=0

start() {
        # Start daemons.
        echo -n $"Starting $PROG"
		  #daemon $PWRSTATD_BIN &
	     $PWRSTATD_BIN &
		  RETVAL=$?
		  echo
		  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROG	     
        return $RETVAL
}

stop() {
        # Stop daemons.
        echo -n $"Shutting down $PROG"
        killproc $PROG
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
        return $RETVAL
}


# See how we were called.
case "$1" in
  start)
		  echo -n "Starting $PROG $VERSION "
		  echo
        start		  
        ;;
  stop)
  		  echo -n "Shutting down $PROG $VERSION "
		  echo
        stop
        ;;
  restart|reload)
		  echo -n "Reloading $PROG $VERSION "
		  echo
        stop
        start
        RETVAL=$?
	 ;;
  status)
		  echo -n "Status $PROG $VERSION "
		  echo
        status $PROG
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
esac

exit $RETVAL
