File: apcupsd.init

package info (click to toggle)
apcupsd 3.12.4-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 41,116 kB
  • ctags: 6,199
  • sloc: ansic: 42,488; sh: 8,031; cpp: 3,740; makefile: 1,897; perl: 1,723; tcl: 368; php: 107; sed: 93
file content (65 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /bin/sh
#
# apcupsd
#     Start the APC UPS daemon to monitor power status.
#

DAEMON=/sbin/apcupsd
CONFIG=/etc/default/apcupsd

test -x $DAEMON || exit 0

test -e $CONFIG || exit 0

set -e

. $CONFIG

if [ $ISCONFIGURED = no ]
then
	echo -n "Please check your configuration "
	echo    " ISCONFIGURED in /etc/default/apcupsd"
	exit 0
fi

case "$1" in
	start)
		echo -n "Starting APC UPS power management: "
		rm -f /etc/apcupsd/powerfail
    		if [ "`pidof apcupsd`" = "" ]
    		then
        		start-stop-daemon --start --quiet --exec $DAEMON 
        		echo "apcupsd."
    		else
        		echo ""
        		echo "A copy of the daemon is still running.  If you just stopped it,"
        		echo "please wait about 5 seconds for it to shut down."
        		exit 0
    		fi
  	;;
  	stop)
    		echo -n "Stopping APC UPS power management: "
    		#start-stop-daemon --stop --quiet --exec $DAEMON
    		echo "apcupsd." 
		start-stop-daemon --stop --oknodo --pidfile /var/run/apcupsd.pid || echo "Not Running." 
		rm -f /var/run/apcupsd.pid
		echo ""

  	;;
  	restart|force-reload)
    		echo -n "Restarting APC UPS power management: "
		$0 stop
    		sleep 10
		$0 start
  	;;
  	status)
    		#/sbin/apcaccess status
    		$APCACCESS status
  	;;
  	*)
    		echo "Usage: /etc/init.d/apcupsd {start|stop|restart|force-reload|status}" >&2
    		exit 1
  	;;
esac

exit 0