softflowd.initd 1.31 KB
Newer Older
1 2
#!/sbin/openrc-run

3 4 5 6 7 8 9 10 11 12 13 14
name="Netflow probe"
description="NetFlow Probe"
command=/usr/sbin/softflowd
pidfile=/run/$RC_SVCNAME.pid

if [ -z "${RC_SVCNAME##*.*}" ]; then
	_suffix=${RC_SVCNAME#*.}
	SOFTFLOWD_INTERFACE=${_suffix%@*}
	name="$name: $SOFTFLOWD_INTERFACE"
	if [ -z "${_suffix##*@*}" ]; then
		SOFTFLOWD_COLLECTOR=${_suffix#*@}
		name="$name -> $SOFTFLOWD_COLLECTOR"
15
	fi
16 17 18 19
	command_args="-p $pidfile -c /run/$RC_SVCNAME.ctl"
elif [ "${SOFTFLOWD_INTERFACE##*:*}" ]; then
	SOFTFLOWD_INTERFACE="${SOFTFLOWD_INTERFACE_IDX:+$SOFTFLOWD_INTERFACE_IDX:}$SOFTFLOWD_INTERFACE"
fi
20

21
command_args="-i $SOFTFLOWD_INTERFACE -n $SOFTFLOWD_COLLECTOR $command_args $SOFTFLOWD_EXTRA"
22

23 24 25
# legacy compatibility
command_args="$command_args ${SOFTFLOWD_TIMEOUTS:+-t $SOFTFLOWD_TIMEOUTS}"
command_args="$command_args ${SOFTFLOWD_MAXFLOWS:+-m $SOFTFLOWD_MAXFLOWS}"
26

27 28
depend() {
	need net
29 30
}

31 32 33 34 35 36 37 38 39 40
start_pre() {
	[ "$SOFTFLOWD_INTERFACE" -a "$SOFTFLOWD_COLLECTOR" ] && return 0
	eerror Specify interface name in form [index:]ifname
	eerror and collector host:port in /etc/conf.d/$RC_SVCNAME:
	eerror "    SOFTFLOWD_INTERFACE=eth0"
	eerror "    SOFTFLOWD_COLLECTOR=collector.host:9995"
	eerror Or create an init script for each interface or interface@collector:
	eerror "    cd /etc/init.d"
	eerror "    ln -s softflowd softflowd.1:eth0@collector.host:9995"
	return 1
41
}