#!/bin/sh
#
# ipcad     Start/Stop the ipcad server
#
# chkconfig: 2345 11 89
# description: ipcad - IP accounting daemon
#
# config: /etc/ipcad.conf
# pidfile: /var/lib/ipcad/ipcad.pid

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

WITHOUT_RC_COMPAT=1

IPCAD=/usr/sbin/ipcad
CONFIG=/etc/ipcad.conf
PIDFILE=/var/lib/ipcad/ipcad.pid

. /etc/sysconfig/ipcad

[ -f $IPCAD ] || exit 0
[ -f $CONFIG ] || exit 0

SourceIfNotEmpty /etc/sysconfig/network

RETVAL=0

start()
{
        start_daemon --lockfile "$LOCKFILE" --pidfile "$PIDFILE" --expect-user root -- $IPCAD $OPTIONS
        RETVAL=$?
        return $RETVAL
}

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

restart()
{
        stop
        start
}

reload()
{
        stop_daemon --pidfile "$PIDFILE" --expect-user root -HUP $IPCAD
        RETVAL=$?
        return $RETVAL
}

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

exit $RETVAL
