]> git.pld-linux.org Git - packages/apcupsd.git/blame - apcupsd.init
- adapterized (sorted %verify attrs)
[packages/apcupsd.git] / apcupsd.init
CommitLineData
f39891c4
AA
1#! /bin/sh
2#
e5732d56 3# apcupsd This shell script takes care of starting and stopping
4# the apcupsd UPS monitoring daemon.
f39891c4 5#
e5732d56 6# chkconfig: 2345 60 99
7# description: apcupsd monitors power and takes action if necessary
f39891c4
AA
8
9# Source function library
10. /etc/rc.d/init.d/functions
11
12# Get network config
13. /etc/sysconfig/network
14
15# Check that networking is up.
16if is_yes "${NETWORKING}"; then
17 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
18 msg_network_down "UPS monitoring"
19 exit 1
20 fi
21else
22 exit 0
23fi
24
771e0039
SP
25# Get service config
26if [ -f /etc/sysconfig/apcupsd ]; then
27 . /etc/sysconfig/apcupsd
28fi
29
f39891c4
AA
30RETVAL=0
31# See how we were called.
32case "$1" in
33 start)
34 rm -f /etc/apcupsd/powerfail
35 # Check if the service is already running?
36 if [ ! -f /var/lock/subsys/apcupsd ]; then
ac6aa522 37 msg_starting "APC UPS monitoring"
771e0039 38 daemon $SERVICE_RUN_NICE_LEVEL /usr/sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
f39891c4
AA
39 RETVAL=$?
40 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd
41 else
42 msg_already_running "APC UPS monitoring"
43 fi
44 ;;
45 stop)
46 if [ -f /var/lock/subsys/apcupsd ]; then
47 msg_stopping "APC UPS monitoring"
48 killproc apcupsd
49 rm -f /var/lock/subsys/apcupsd
50 else
51 msg_not_running "APC UPS monitoring"
52 fi
53 ;;
d9cc3596 54 restart|force-reload)
f39891c4 55 $0 stop
e5732d56 56 $0 start
f39891c4
AA
57 ;;
58 powerdown)
59 if [ -f /etc/apcupsd/powerfail ]; then
60 show "Switching the power off"
61 /etc/apcupsd/apccontrol killpower
62 sleep 60
63 fail
64 fi
65 ;;
66 status)
67 /usr/sbin/apcaccess status
68 ;;
69 *)
d9cc3596 70 msg_usage "$0 {start|stop|restart|force-reload|status|powerdown}"
f39891c4
AA
71 exit 3
72esac
73
74exit $RETVAL
This page took 0.034575 seconds and 4 git commands to generate.