UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / platforms / darwin / apcupsd.in
blobd47517f3d3d925068bac5f12cd9402b73e47c1be
1 #!/bin/sh
3 # apcupsd This shell script takes care of starting and stopping
4 # the apcupsd UPS monitoring daemon.
6 # Written by Adam Kropelin <akropel1@rochester.rr.com>
7 # Based on work by Ingo Nowak <nowak@koellernowak.de>
9 . /etc/rc.common
11 APCPID=@PIDDIR@/apcupsd.pid
12 APCLOCK=@PIDDIR@/apcupsd.lock
14 StartService()
16 ConsoleMessage "Starting UPS monitoring"
17 rm -f @PWRFAILDIR@/powerfail
18 rm -f @nologdir@/nologin
19 @sbindir@/apcupsd -f @sysconfdir@/apcupsd.conf || exit 0
20 touch $APCLOCK
23 StopService()
25 ConsoleMessage "Shutting down UPS monitoring"
26 if [ -f ${APCPID} ]; then
27 kill `cat ${APCPID}` || exit 0
28 rm -f ${APCPID}
30 rm -f $APCLOCK
33 RestartService()
35 StopService
36 sleep 15
37 StartService
40 # Typically we'd just use RunService from /etc/rc.common here, but rumor
41 # has it Mac OS 10.1.x and earlier do not have that function so we'll
42 # implement it ourselves.
43 case $1 in
44 start)
45 StartService
47 stop)
48 StopService
50 restart)
51 RestartService
54 echo "$0: unknown argument: $1"
56 esac