summaryrefslogtreecommitdiff
blob: 6764e335f40a92426b3ebbf2b30bb75771f8afd0 (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
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/apcupsd/files/apcupsd.init.2,v 1.3 2011/08/22 14:27:25 flameeyes Exp $

INSTANCE="${SVCNAME#*.}"
if [ -z "${INSTANCE}" ] || [ "${SVCNAME}" = "apcupsd" ]; then
	INSTANCE="apcupsd"
fi

depend() {
	use net
}

start() {
	rm -f /etc/apcupsd/powerfail

	export SERVICE="${SVCNAME}"

	ebegin "Starting APC UPS daemon"
	start-stop-daemon \
		--start --pidfile "/var/run/${SVCNAME}.pid" \
		--wait 3000 \
		--exec /sbin/apcupsd -- \
		-f "/etc/apcupsd/${INSTANCE}.conf" \
		-P "/var/run/${SVCNAME}.pid"
	eend $?
}

stop() {
	ebegin "Stopping APC UPS daemon"
	start-stop-daemon \
		--stop --pidfile "/var/run/${SVCNAME}.pid" \
            	--retry TERM/5/TERM/5 \
		--exec /sbin/apcupsd
	eend $?
}