aboutsummaryrefslogtreecommitdiffstats
path: root/main/nfdump/sfcapd.initd
blob: 1a2171f239286279ffb0fddf394c27277ee4cab5 (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
#!/sbin/openrc-run

depend() {
	need net
	after firewall
}

command=/usr/bin/sfcapd
pidfile=/var/run/${SVCNAME}/${SVCNAME}.pid
: ${exec_user:=$UID}
: ${exec_group:=$GID}
: ${exec_dir:=$BASEDIR}

start_pre() {
	checkpath --directory --owner "${exec_user:-nobody}:${exec_group:-nobody}" "${exec_dir:-/var/log/nfcapd}"
	checkpath --directory --owner "${exec_user:-nobody}:${exec_group:-nobody}" "${pidfile/$SVCNAME.pid}"
}

start() {
	ebegin "Starting ${SVCNAME}"
	start_pre()
	
	[ -n "${SOURCE}" ] && SOURCE=`echo -n "${SOURCE}" | sed 's/ / -n /g'`
	[ "${IPV4}"       == "yes" ] && command_args="${command_args} -4"
	[ "${IPV6}"       == "yes" ] && command_args="${command_args} -6"
	[ "${ALIGN}"      == "yes" ] && command_args="${command_args} -w"
	[ "${AUTOEXPIRE}" == "yes" ] && command_args="${command_args} -e"
	[ "${COMPRESS}"   == "yes" ] && command_args="${command_args} -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" ] && command_args="${command_args} -${opt} ${optvalue}"
	done

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

	eend $?
}