aboutsummaryrefslogtreecommitdiffstats
path: root/community/softflowd/softflowd.initd
blob: c6e05afc977190d6cd12b1d5862ce6628f275fb7 (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
#!/sbin/openrc-run

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"
	fi
	command_args="-p $pidfile -c /run/$RC_SVCNAME.ctl"
elif [ "${SOFTFLOWD_INTERFACE##*:*}" ]; then
	SOFTFLOWD_INTERFACE="${SOFTFLOWD_INTERFACE_IDX:+$SOFTFLOWD_INTERFACE_IDX:}$SOFTFLOWD_INTERFACE"
fi

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

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

depend() {
	need net
}

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
}