#!/bin/sh
#
# apcupsd      This shell script takes care of starting and stopping
#	       the apcupsd UPS monitoring daemon.
#
# PROVIDE: apcupsd
# REQUIRE: DAEMON
#
DISTVER="11.0"

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="apcupsd"
rcvar=$name
command="/usr/pkg/sbin/${name}"
pidfile="/var/run/${name}.pid"
apclock="/var/run/${name}.lock"
command_args="--kill-on-powerfail"
extra_commands="info"

apcupsd_start_precmd()
{
    rm -f /usr/pkg/etc/apcupsd/powerfail
}

apcupsd_start_postcmd()
{
    touch $apclock
}

apcupsd_stop_postcmd()
{
    rm -f $apclock
}

apcupsd_info()
{
    /usr/pkg/sbin/apcaccess status
}


start_precmd=apcupsd_start_precmd
start_postcmd=apcupsd_start_postcmd
stop_postcmd=apcupsd_stop_postcmd
info_cmd=apcupsd_info

load_rc_config $name
run_rc_command "$1"
