#!/bin/sh
#
# chkconfig: - 81 19
# description: ulogd is the userspace logging daemon for netfilter/iptables
### BEGIN INIT INFO
# Provides: ulogd
# Required-Start: $local_fs $network $remote_fs
# Should-Start: $syslog
# Required-Stop: $local_fs $network $remote_fs
# Should-Stop: $syslog
# Default-Start: 
# Default-Stop: 0 1 6
# Short-Description: start and stop ulogd
# Description: ulogd is the userspace logging daemon for netfilter/iptables
### END INIT INFO
#


. /etc/rc.d/init.d/functions

prog="ulogd"
test -x /usr/sbin/ulogd || exit 0

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

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

function start()
{
	pid=`pidof ulogd`
	if [ "x$pid" == "x" ]; then
		echo -n $"Starting $prog: "
		daemon /usr/sbin/ulogd -d || exit $?
		echo
		touch /var/lock/subsys/ulogd
	else
		echo $"$prog is already running."
	fi
}


function stop()
{
	pid=`pidof ulogd`
	if [ "x$pid" != "x" ]; then
		echo -n $"Stopping $prog: "
		killproc ulogd || exit $?
		echo
		rm -f /var/lock/subsys/ulogd
	else
		echo $"$prog is already stopped."
	fi
}


function reload()
{
	echo -n $"Reloading $prog: "
	pid=`pidof ulogd`
	if [ "x$pid" != "x" ]; then
		kill -HUP $pid 2>/dev/null || exit $?
	fi
	touch /var/lock/subsys/ulogd
}


case "$1" in
  start)
	start
	;;
  stop)
  	stop
	;;
  restart)
	echo $"restarting $prog..."
	stop
	start
	;;
  try-restart|condrestart)
	pid=`pidof ulogd`
	if [ "x$pid" != "x" ]; then
		stop
		start
	fi
	;;
  reload|force-reload)
	reload
	;;
  status)
	status ulogd
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload}"
	exit 2
esac

exit 0
