#! /bin/sh
#
# nemac          Start/Stop the nemac daemon.
#
# chkconfig: 2345 40 60
# description: nemac is a traffic accounting daemon(reader) for NeTraMet/NetFlowMet collectors

# processname: NeMaC
# config: /etc/sysconfig/nemac
# pidfile: /var/run/NeMaC.pid

# Source function library.
. /etc/init.d/functions
. /etc/sysconfig/netramet/nemac

LOCKFILE=/var/lock/subsys/nemac
RETVAL=0

start()
{
	echo -n "Starting NeMaC daemon: "
	daemon NeMaC $FLAGS -D
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}

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

restart()
{
	stop
	start
}

reload()
{
	echo -n "Reloading NeMaC daemon configuration: "
	killproc NeMaC -HUP
	RETVAL=$?
	echo
	return $RETVAL
} 

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status NeMaC
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
