aboutsummaryrefslogtreecommitdiffstats
path: root/community/softflowd/softflowd.initd
diff options
context:
space:
mode:
Diffstat (limited to 'community/softflowd/softflowd.initd')
-rw-r--r--community/softflowd/softflowd.initd78
1 files changed, 32 insertions, 46 deletions
diff --git a/community/softflowd/softflowd.initd b/community/softflowd/softflowd.initd
index 3cf1e4231b..c6e05afc97 100644
--- a/community/softflowd/softflowd.initd
+++ b/community/softflowd/softflowd.initd
@@ -1,55 +1,41 @@
#!/sbin/openrc-run
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-analyzer/softflowd/files/softflowd.initd,v 1.2 2012/03/21 07:52:49 robbat2 Exp $
-depend() {
- need net
-}
-
-softflowd_checkconfig() {
- SOFTFLOWD_INTERFACE=${SVCNAME#*.}
- if [ ${SOFTFLOWD_INTERFACE} = ${SVCNAME} ]; then
- eerror "You have to create an init script for each interface:"
- eerror "ln -s softflowd /etc/init.d/softflowd.eth0"
- return 1
+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
- if [ -z "${SOFTFLOWD_COLLECTOR}" ]; then
- eerror "Specify the host and port that the accounting datagrams are to be"
- eerror "sent to in /etc/conf.d/${SVCNAME}."
- eerror "Example: SOFTFLOWD_COLLECTOR=collector.example.com:9995"
- return 1
- fi
- SOFTFLOWD_PIDFILE="/var/run/softflowd.${SOFTFLOWD_INTERFACE}.pid"
- SOFTFLOWD_CTLFILE="/var/run/softflowd.${SOFTFLOWD_INTERFACE}.ctl"
-}
+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}"
-start() {
- softflowd_checkconfig || return 1
-
- ebegin "Starting softflowd on interface ${SOFTFLOWD_INTERFACE}"
- iface_arg=${SOFTFLOWD_INTERFACE}
- [ -n "${SOFTFLOWD_INTERFACE_IDX}" ] && iface_arg="${SOFTFLOWD_INTERFACE_IDX}:${iface_arg}"
- start-stop-daemon --start \
- --exec /usr/sbin/softflowd \
- -- -i "${iface_arg}" \
- -n "${SOFTFLOWD_COLLECTOR}" \
- -p "${SOFTFLOWD_PIDFILE}" \
- -c "${SOFTFLOWD_CTLFILE}" \
- -t "${SOFTFLOWD_TIMEOUTS-maxlife=600}" \
- -m "${SOFTFLOWD_MAXFLOWS-17000}" \
- ${SOFTFLOWD_EXTRA}
- eend $?
+depend() {
+ need net
}
-stop() {
- softflowd_checkconfig || return 1
-
- ebegin "Stopping softflowd on interface ${SOFTFLOWD_INTERFACE}"
- # use softflowd's own way to shut it down
- /usr/sbin/softflowctl -c ${SOFTFLOWD_CTLFILE} shutdown
- eend $?
+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
}
-