#! /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 1

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

# The following value is extracted by debstd to figure out how to generate
# the postinst script. Edit the field to change the way the script is
# registered through update-rc.d (see the manpage for update-rc.d!)
# NO_RESTART_ON_UPGRADE
FLAGS="defaults 50"

test -f $DAEMON || exit 0

case "$1" in
  start)
    start-stop-daemon --start --verbose --exec $DAEMON -- $PORT
    ;;
  stop)
    start-stop-daemon --stop --verbose --exec $DAEMON
    ;;
  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
