#! /bin/sh
#
# This file was automatically customized by debmake on Thu, 12 Dec 1996 21:31:08 -0800
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Debian by Christoph Lameter <clameter@debian.org>

# Uncomment and modify the following line to point to the ups serial device.
#PORT="/dev/ttyS3"
# Then comment out this line
echo "/etc/init.d/ups: Port not configured!";exit 0

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

FLAGS="defaults 50"

test -f $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting ups monitor: upsd"
    start-stop-daemon --start --quiet --exec $DAEMON -- $PORT
    echo .
    ;;
  stop)
    echo -n "Stoping ups monitor: upsd"
    start-stop-daemon --stop --quiet --exec $DAEMON
    echo .
    ;;
  restart|force-reload)
    echo -n "Restarting ups monitor: upsd"
    start-stop-daemon --stop --quiet --exec $DAEMON
    start-stop-daemon --start --quiet --exec $DAEMON -- $PORT
    echo .
    ;;
  poweroff)
    upsd -i-1 $PORT
    case "$?" in
      101 | 102)
	sleep 60
	upsd -k $PORT
        ;;
      *)
        ;;
    esac
    ;;
  *)
    echo "Usage: /etc/init.d/$0 {start|stop|poweroff}"
    exit 1
    ;;
esac

exit 0
