updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / apcupsd-cli / apcupsd
blob3cd5c9dc85fdd23406d07f9d769fd5c67eb316c3
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 PID=`pidof -o %PPID /sbin/apcupsd`
7 case "$1" in
8 start)
9 stat_busy "Starting APCUPSD Daemon"
10 rm -f /etc/apcupsd/powerfail
11 rm -f /etc/nologin
12 [ -z "$PID" ] && /sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
13 if [ $? -gt 0 ]; then
14 stat_fail
15 else
16 PID=`pidof -o %PPID /sbin/apcupsd`
17 echo $PID > /var/run/apcupsd.pid
18 add_daemon apcupsd
19 stat_done
22 stop)
23 stat_busy "Stopping APCUPSD Daemon"
24 [ ! -z "$PID" ] && kill $PID &> /dev/null
25 if [ $? -gt 0 ]; then
26 stat_fail
27 else
28 rm /var/run/apcupsd.pid
29 rm_daemon apcupsd
30 stat_done
33 restart)
34 $0 stop
35 sleep 2
36 $0 start
38 status)
39 /sbin/apcaccess status
42 echo "usage: $0 {start|stop|restart|status}"
43 esac
44 exit 0