#!/bin/sh

### BEGIN INIT INFO
# Provides:          upsmonitor
# Required-Start:    $network $syslog
# Required-Stop:     $network $syslog
# Should-Start:      $local_fs
# Should-Stop:       $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: UPS Monitor
# Description:       Monitors UPS status, shuts down host if low battery
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/upsmonitor

test -f $DAEMON || exit 0

case "$1" in
  start)
  	echo -n "Starting ups monitor: "
    start-stop-daemon -x $DAEMON --start --verbose --exec $DAEMON &
	echo "upsmonitor."
    ;;
  stop)
  	echo -n "Stopping ups monitor: "
    start-stop-daemon -x $DAEMON --stop --verbose --exec $DAEMON
	echo "upsmonitor."
    ;;
  restart|force-reload)
  	echo -n "Restarting ups monitor: "
    start-stop-daemon -x $DAEMON --stop --verbose --exec $DAEMON
    start-stop-daemon -x $DAEMON --start --verbose --exec $DAEMON &
	echo "upsmonitor."
    ;;
  *)
    echo "Usage: /etc/init.d/$0 {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
