#!/bin/sh
#
# passivedns	A network sniffer that logs all DNS server replies for use in a passive DNS setup
#
# chkconfig: - 90 10
# description:	A tool to collect DNS records passively \
#		to aid Incident handling, Network \
#		Security Monitoring (NSM) and \
#		general digital forensics.
# processname: passivedns
# config: /etc/passivedns/passivedns.conf
# pidfile: /var/run/passivedns.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/passivedns/passivedns.pid
LOCKFILE=/var/lock/subsys/passivedns
RETVAL=0


SourceIfNotEmpty /etc/sysconfig/passivedns

OPTIONS="-D -u _passivedns -g _passivedns $OPTIONS"

start()
{
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user _passivedns -- passivedns "$OPTIONS"
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user _passivedns -- passivedns
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		restart
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user _passivedns -- passivedns
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
