#!/bin/sh
#
# netams	Network Traffic Accounting and Management Service.
#
# chkconfig: 345 90 91
# description: Network Traffic Accounting and Management System.
# processname: netams
# config: /etc/netams/netams.conf

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/lib/ntop/ntop.pid
LOCKFILE=/var/lock/subsys/ntop
RETVAL=0

NTOPD="/usr/bin/ntop -d @/etc/ntop/ntop.conf"

start()
{
	RETVAL=$?
	[ $RETVAL -ne "0" ] && return $RETVAL
	
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user ntop -- $NTOPD
	RETVAL=$?
	return $RETVAL
}

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

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	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 ntop -- $NTOPD
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|restart|status|condrestart|condreload|condstop}"
		RETVAL=1
esac

exit $RETVAL
