summaryrefslogtreecommitdiff
blob: 24d09fbc7116017f8546d2614ffed61a583ade75 (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
#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

extra_commands="reload"

DHCP_PROBE_BINARY="/usr/sbin/dhcp_probe"
DHCP_PROBE_CONFIG="/etc/dhcp_probe.cf"
DHCP_PROBE_PIDFILE="/var/run/${SVCNAME}.pid"
DHCP_PROBE_INTERFACE="${SVCNAME#*.}"

depend() {
	use logger
	need net
}

checkconfig() {
	if [ ! -e ${DHCP_PROBE_CONFIG} ]; then
		eerror "You need an ${DHCP_PROBE_CONFIG} to run dhcp_probe."
		eerror "A sample file is available in /usr/share/doc/dhcp_probe*"
		return 1
	elif [ ${SVCNAME} = dhcp_probe ]; then
		eerror "Do not run this script directly! Instead, create symbolic links like so:"
		eerror " # cd /etc/init.d"
		eerror " # ln -s dhcp_probe dhcp_probe.[INTERFACE_NAME]"
		eerror "for each interface that should be monitored"
		return 1
	fi
}

start() {
	checkconfig
	ebegin "Starting ${SVCNAME}"
	${DHCP_PROBE_BINARY} ${DHCP_PROBE_OPTIONS} -p ${DHCP_PROBE_PIDFILE} ${DHCP_PROBE_INTERFACE}
	eend ${?}
}

stop() {
	if [ "${RC_CMD}" = "restart" ] ; then
		checkconfig || return 1
	fi
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --signal 9 \
		--pidfile ${DHCP_PROBE_PIDFILE}
	eend ${?}
}