#!/bin/sh
#
# netams	Network Traffic Accounting and Management Service.
#
# chkconfig: - 11 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/run/netams.pid
LOCKFILE=/var/lock/subsys/netams
RETVAL=0

NETAMSD="/usr/sbin/netams -l -q"

start()
{
#	action "Loading ip_queue module" modprobe ip_queue
	RETVAL=$?
	[ $RETVAL -ne "0" ] && return $RETVAL
	
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $NETAMSD
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $NETAMSD
	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
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user root -- $NETAMSD
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
