#!/bin/sh
#
# flow-capture	Captures flow PDU's from a Cisco router.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux by
#		Ian Murdock <imurdock@gnu.ai.mit.edu> and
#		Anibal Monsalve Salazar <A.Monsalve.Salazar@IEEE.org>
#
# This file was automatically customized by dh-make on Fri, 10 Aug 2001 11:19:06 +0200

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/flow-capture
CONFIG=/etc/flow-tools/flow-capture.conf
NAME=flow-capture
DESC=flow-capture

test -f $DAEMON || exit 0
test -f $CONFIG || exit 0

set -e

pid=`pidof $DAEMON` || true

case "$1" in
  start)
	if [ "$pid" ]; then
		echo "Sorry, flow-capture is already running."
		exit 0
	fi
  	IFS=$'\n'
	lines=`grep -E " |\t" /etc/flow-tools/flow-capture.conf | grep -v "^#"`
	echo -n "Starting $DESC: "
	for args in $lines; do
		IFS=$' '
		$DAEMON ${args}
	done
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	pid=`pidof $DAEMON` || true
	if [ "$pid" ]; then
		kill -SIGTERM $pid >/dev/null 2>&1
	fi
	echo "$NAME."
	;;
  reload|restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	$0 stop
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
