aboutsummaryrefslogtreecommitdiffstats
path: root/main/nfdump/nfcapd.initd
blob: 028cf55ee376d3c79abd2c03ef077e566e9662a3 (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
66
67
68
69
#!/sbin/runscript
# Copyright 2012 N Angelacos - Based on Gentoo Foundation fprobe script
# Distributed under the terms of the GNU General Public License v2

depend() {
	need net
	after firewall
}


BIN=/usr/bin/nfcapd
PIDFILE_EXTRA=${SVCNAME#*.}
if [ -n "${PIDFILE_EXTRA}" ] && [ ${SVCNAME} != "nfcapd" ]; then
	PIDFILE="/var/run/nfcapd.${PIDFILE_EXTRA}.pid"
else
	PIDFILE="/var/run/nfcapd.pid"
fi

start() {
	ebegin "Starting nfcapd"
	local OPTS=""
	
	[ -n "${SOURCE}" ] && SOURCE=`echo -n "${SOURCE}" | sed 's/ / -n /g'`
	[ "${IPV4}"       == "yes" ] && OPTS="${OPTS} -4"
	[ "${IPV6}"       == "yes" ] && OPTS="${OPTS} -6"
	[ "${ALIGN}"      == "yes" ] && OPTS="${OPTS} -w"
	[ "${AUTOEXPIRE}" == "yes" ] && OPTS="${OPTS} -e"
	[ "${COMPRESS}"   == "yes" ] && OPTS="${OPTS} -z"
	for optname in p:PORT b:BINDHOST j:MULTICASTGROUP i:IFACE R:REPEAT \
		I:IDENT l:BASEDIR n:SOURCE s:SAMPLERATE S:SUBDIR \
		T:EXTENSIONS t:INTERVAL u:UID g:GID \
		B:BUFFLEN ; do
	    opt="${optname/:*}"	optvar="${optname/*:}"
	    eval optvalue="\$$optvar"
	    [ -n "$optvalue" ] && OPTS="${OPTS} -${opt} ${optvalue}"
	done

	# Attempt to make the basedir if specified
	if [ -n "${BASEDIR}" ]; then
		mkdir -p "${BASEDIR}"
		chown "${UID}":"${GID}" "${BASEDIR}"
	fi

	# Handle remote command as a special case
	if [ -n "${ROTATECMD}" ]; then
		start-stop-daemon --start -b --exec $BIN \
			--pidfile ${PIDFILE} --make-pidfile \
			-- ${OPTS} -x "${ROTATECMD}"
	else
		start-stop-daemon --start -b --exec $BIN \
			--pidfile ${PIDFILE} --make-pidfile \
			-- ${OPTS}
	fi

	eend $?
}

stop() {
	ebegin "Stopping nfcapd"
	start-stop-daemon --stop --quiet --exec $BIN \
		--pidfile ${PIDFILE}
	eend $?
}