3 # apcupsd This shell script takes care of starting and stopping
4 # the apcupsd UPS monitoring daemon.
6 # chkconfig: 2345 60 99
7 # description: apcupsd monitors power and takes action if necessary
9 # Source function library
10 . /etc/rc.d/init.d/functions
13 . /etc/sysconfig/network
15 # Check that networking is up.
16 if is_yes "${NETWORKING}"; then
17 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
18 msg_network_down "UPS monitoring"
26 if [ -f /etc/sysconfig/apcupsd ]; then
27 . /etc/sysconfig/apcupsd
31 # Check if the service is already running?
32 if [ -f /var/lock/subsys/apcupsd ]; then
33 msg_already_running "APC UPS monitoring"
37 msg_starting "APC UPS monitoring"
38 rm -f /etc/apcupsd/powerfail
39 daemon $SERVICE_RUN_NICE_LEVEL /usr/sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
41 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd
45 if [ ! -f /var/lock/subsys/apcupsd ]; then
46 msg_not_running "APC UPS monitoring"
50 msg_stopping "APC UPS monitoring"
52 rm -f /var/lock/subsys/apcupsd
56 if [ ! -f /var/lock/subsys/apcupsd ]; then
57 msg_not_running "APC UPS monitoring"
67 if [ ! -f /etc/apcupsd/powerfail ]; then
71 show "Switching the power off"
72 /etc/apcupsd/apccontrol killpower
78 # See how we were called.
101 /usr/sbin/apcaccess status
105 msg_usage "$0 {start|stop|restart|try-restart|force-reload|powerdown|status}"