aboutsummaryrefslogtreecommitdiffstats
path: root/main/nfdump/sfcapd.initd
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@alpinelinux.org>2015-12-10 10:40:01 +0000
committerLeonardo Arena <rnalrd@alpinelinux.org>2015-12-10 10:43:42 +0000
commite490ba69b1f34788f3da6e2ed2cfcddb787861f7 (patch)
treeb38b3ec173d8785458b59e42b1cf67f2797d25be /main/nfdump/sfcapd.initd
parent6dc6352315dab985e4f651ddae90e7db19b247f8 (diff)
main/nfdump: enable sflow collector
Diffstat (limited to 'main/nfdump/sfcapd.initd')
-rw-r--r--main/nfdump/sfcapd.initd50
1 files changed, 50 insertions, 0 deletions
diff --git a/main/nfdump/sfcapd.initd b/main/nfdump/sfcapd.initd
new file mode 100644
index 00000000000..1a2171f2392
--- /dev/null
+++ b/main/nfdump/sfcapd.initd
@@ -0,0 +1,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 $?
+}