#!/bin/sh
#
# iplog		This start and stops the iplog traffic logger.
#
# chkconfig:	345 97 03
# description:	iplog's capabilities include the ability to detect \
#		TCP port scans, TCP null scans, FIN scans, UDP and \
#		ICMP "smurf" attacks, bogus TCP flags (used by \
#		scanners to detect the operating system in use), \
#		TCP SYN scans, TCP "Xmas" scans, ICMP ping floods, \
#		UDP scans, and IP fragment attacks.
#
# processname: /usr/sbin/iplog
# config: /etc/iplog.conf
# pidfile: /var/run/iplog.pid

PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin

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

# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network

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

[ -x /usr/sbin/iplog ] || exit 1
[ -r /etc/iplog.conf ] || exit 1

RETVAL=0

prog="iplog"

start() {
	# Check if iplog is already running
	if [ ! -f /var/lock/subsys/iplog ]; then
		echo -n $"Starting $prog: "
		daemon /usr/sbin/iplog
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/iplog
		echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc /usr/sbin/iplog
	RETVAL=$?
	rm -f /var/lock/subsys/iplog
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

status_iplog() {
	status /usr/sbin/iplog
}

# See how we were called.
case "$1" in
start)
	start
	;;
stop)
	stop
	;;
status)
	status_iplog
	;;
restart|reload)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/nessusd ]; then
	    restart
	fi
	;;
*)
	echo "Usage: $0 {start|stop|status|restart|condrestart}"
	RETVAL=1
esac

exit $RETVAL

