#!/bin/sh
#
# chkconfig: 345 07 91
# description: ulog-acctd is the userspace network accounting daemon
#


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

RETVAL=0
LOCKFILE="/var/lock/subsys/ulog-acctd"

function start()
{
	echo -n "Starting ulog-acctd: "
	daemon /usr/sbin/ulog-acctd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}


function stop()
{
	echo -n "Stopping ulog-acctd: "
	killproc ulog-acctd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}


function reload()
{
	echo -n "Reloading ulog-acctd: "
	killproc ulog-acctd -HUP
	RETVAL=$?
	echo
	return $RETVAL
}


case "$1" in
    start)
	start
	;;
    stop)
  	stop
	;;
    restart)
	stop
	start
	;;
    reload)
	reload
	;;
    condstop)
        if [ -e "$LOCKFILE" ]; then
            stop
        fi
        ;;
    condrestart)
        if [ -e "$LOCKFILE" ]; then
            stop
	    start
        fi
        ;;
    condreload)
        if [ -e "$LOCKFILE" ]; then
            reload
        fi
        ;;
    status)
	status ulog-acctd
	;;
    *)
	echo "Usage: %{0##/} {start|stop|status|restart|reload|condstop|condrestart|condreload}"
	RETVAL=1
esac

exit $RETVAL
