#!/bin/sh
#
# ipfm	This shell script takes care of starting and stopping ipfm.
#
# chkconfig: - 85 15
# description:	IP Flow Meter
# processname: ipfm
# config: /etc/ipfm.conf
# pidfile: /var/run/ipfm.pid

NAME=ipfm

[ -f /etc/$NAME.conf ] || exit 0

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/$NAME.pid
LOCKFILE=/var/lock/subsys/$NAME
RETVAL=0

do_call() {
	$1 --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $NAME
	RETVAL=$?
	return $RETVAL
}

restart() {
	do_call stop_daemon
	do_call start_daemon
}

function ipfm_main()
{
	case "$1" in
	start)       do_call start_daemon ;;
	stop)        do_call stop_daemon  ;;
	reload)      restart              ;;
	restart)     restart              ;;
	status)      do_call status       ;;
	condstop)    [ -e "$LOCKFILE" ] && do_call stop_daemon ;;
	condrestart) [ -e "$LOCKFILE" ] && restart ;;
	condreload)  [ -e "$LOCKFILE" ] && restart ;;
	*)	     msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		     RETVAL=1
	esac

	return $RETVAL
}

ipfm_main "$@"

## EOF ##
