summaryrefslogtreecommitdiff
blob: 93438209e1f1092af1747b0857118978acaf232b (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
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Default to "lo" for the interface, so that the init script will work
# out-of-the-box.
: ${ARPWATCH_IFACE:=lo}

ARPWATCH_DATAFILE="/var/lib/arpwatch/${RC_SVCNAME}.dat"

command="/usr/sbin/arpwatch"
pidfile="/run/${RC_SVCNAME}.pid"
command_args="
	-i ${ARPWATCH_IFACE}
	-f ${ARPWATCH_DATAFILE}
	-P ${pidfile}
	${ARPWATCH_OPTS}
"

depend() {
	if [ -f "/proc/net/vlan/${ARPWATCH_IFACE}" ]; then
		_if=$(grep -i "device" /proc/net/vlan/${ARPWATCH_IFACE} |awk '{print $2;}')
	else
		_if=${ARPWATCH_IFACE}
	fi
	need "net.${_if}"
}

start_pre() {
	# The "arpwatch" user must be a member of the "arpwatch" group for
	# this to work.
	checkpath --file --owner root:arpwatch --mode 0660 "${ARPWATCH_DATAFILE}"
}