blob: 923d6b98ad2e26f9d4f81c40b4b885f7293e0e2e (
plain)
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
# $FreeBSD$
# startup scripts for APCUPSD.
if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
echo "$0: Cannot determine the PREFIX" >&2
exit 1
fi
# If there is a global system configuration file, suck it in.
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
apcupsd_enable=${apcupsd_enable:-YES}
apcupsd_program=${apcupsd_program:-${PREFIX}/sbin/apcupsd}
apcupsd_flags=${apcupsd_flags:-"--kill-on-powerfail"}
apcupsd_pidfile=${apcupsd_pidfile:-/var/run/apcupsd.pid}
apcupsd_lockfile=${apcupsd_pidfile:-/var/spool/lock/apcupsd.lock}
case $1 in
start)
case "${apcupsd_enable}" in
[Yy][Ee][Ss])
rm -f /var/run/powerfail
rm -f /var/run/nologin
if [ -f ${apcupsd_program} ]; then
echo -n " apcupsd"
${apcupsd_program} ${apcupsd_flags} || return=" Failed."
touch ${apcupsd_lockfile}
fi
;;
esac
;;
stop)
if [ -f ${apcupsd_pidfile} ]; then
PID=`cat ${apcupsd_pidfile}`
kill -KILL $PID || return=" Failed."
rm -f ${apcupsd_pidfile}
# some slaves won't die
killall apcupsd
else
return=" Failed."
fi
;;
restart)
$0 stop
$0 start;
;;
status)
${PREFIX}/sbin/apcaccess status
;;
*)
echo "usage: $0 {start|stop|restart|status}" 1>&2
;;
esac
exit 0;
|