#! /bin/sh
#
# $NetBSD: apcupsd,v 1.2 2000/10/07 16:19:17 mason Exp $
#
# PROVIDE: apcupsd
# REQUIRE: DAEMON

name="apcupsd"
command="@@PREFIX@@/sbin/powersc"
pidfile="/var/run/${name}.pid"

cmd=${1:-start}

case ${cmd} in
start)
	if [ -x ${command} ]; then
		echo "Starting ${name}."
		${command} INIT
	fi
	;;
stop)
	if [ -f ${pidfile} ]; then
		pid=`head 1 ${pidfile}`
		echo "Stopping ${name}."
		${command} STOP
	fi
	;;
restart)
	if [ -x ${command} ]; then
		echo "Restarting ${name}."
		${command} RESTARTME
	fi
	;;
status)
	if [ -f ${pidfile} ]; then
		pid=`head -1 ${pidfile}`
		echo "${name} is running as pid ${pid}."
	else
		echo "${name} is not running."
	fi
	;;
esac
exit 0
