#!/bin/bash
#
# ip_flood_detector	This shell script takes care of starting and stopping ip_flood_detector.
#
# chkconfig: - 65 35
# description: ip_flood_detector -  IP flood detector daemon
# probe: false
# processname: ip_flood_detector
# pidfile: /var/run/ip_flood_detector.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /usr/sbin/ip_flood_detector ] || exit 0

[ -f /etc/sysconfig/ip_flood_detector ] && . /etc/sysconfig/ip_flood_detector

RETVAL=0

# See how we were called.
case "$1" in
  start)
	if [ -n "`/sbin/pidof ip_flood_detector`" ]; then
            gprintf "ip_flood_detector: already running"
	    RETVAL=$?
	    echo
	    exit $RETVAL
        fi
	gprintf "Starting ip_flood_detector: "
	daemon ip_flood_detector -d ${IP_FLOOD_DETECTOR_OPTIONS:-""}
	RETVAL=$?
	[ $RETVAL -eq 0 ] && success || failure
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ip_flood_detector
	;;
  stop)
	gprintf "Starting ip_flood_detector: "
	killproc ip_flood_detector
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ip_flood_detector
	;;
  status)
	status ip_flood_detector
	RETVAL=$?
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
condrestart)
	[ -f /var/lock/subsys/ip_flood_detector ] && restart || :
	;;
  *)
	gprintf "Usage: ip_flood_detector {start|stop|status|restart|condrestart|reload}\n"
	exit 1
esac

exit $RETVAL
