#!/bin/sh
#
# fwlogwatch	This shell script takes care of starting and stopping fwlogwatch.
#
# chkconfig: 2345 90 10
# description: Firewall log analysis with realtime response.
# probe: false
# processname: fwlogwatch
# config: /etc/fwlogwatch.config
# config: /etc/sysconfig/fwlogwatch
# pidfile: /var/run/fwlogwatch.pid

### BEGIN INIT INFO
# Provides: fwlogwatch
# Required-Start: $network
# Should-Start: iptables shorewall
# Required-Stop:
# Default-Start:  2 3 5
# Default-Stop:	  0 1 6
# Description:	  Firewall log analysis with realtime response.
# Short-Description: fwlogwatch
### END INIT INFO

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

if [ -r /etc/sysconfig/fwlogwatch ]; then
    . /etc/sysconfig/fwlogwatch
else
    OPTIONS="-R -A -X 888 -Pn"
fi

# See how we were called.
case "$1" in
start)
	gprintf "Starting fwlogwatch: "
	if [ -z $OPTIONS ]; then
	    OPTIONS="-R -A -X 888 -Pn"
	fi
	daemon fwlogwatch $OPTIONS
	RETVAL=$?
	echo
	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/fwlogwatch
	;;
stop)
	gprintf "Stopping fwlogwatch: "
	killproc fwlogwatch -TERM
	RETVAL=$?
	echo
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/fwlogwatch
	;;
status)
	status fwlogwatch
	RETVAL=$?
	;;
restart)
	$0 stop
	$0 start
	;;
reload)
	gprintf "Reloading fwlogwatch:"
	killproc fwlogwatch -HUP
	RETVAL=$?
	echo
	;;
condrestart)
	[ -f /var/lock/subsys/fwlogwatch ] && restart
	;;
	*)
	gprintf "Usage: %s {start|stop|status|restart|condrestart|reload}\n" "$0"
	RETVAL=1
esac

exit $RETVAL
