#! /bin/sh
#
# chkconfig: - 55 45
# description:	The arpwatch daemon attempts to keep track of ethernet/ip \
#		address pairings.
# processname: arpwatch
WITHOUT_RC_COMPAT=1

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

ARPWATCH_USER=_arpwd
ARPWATCH_ARGS=

# Get config.
SourceIfNotEmpty /etc/sysconfig/network
SourceIfNotEmpty /etc/sysconfig/arpwatch

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

start()
{
	is_yes "$NETWORKING" || return 0
	start_daemon --lockfile "$LOCKFILE" --expect-user "$ARPWATCH_USER" -- arpwatch ${ARPWATCH_ARGS}
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --lockfile "$LOCKFILE" --expect-user "$ARPWATCH_USER" -- arpwatch
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status --expect-user "$ARPWATCH_USER" -- arpwatch
		RETVAL=$?
		;;
	restart|reload)
		restart
		;;
	condstop)
		if [ -f "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart|condreload)
		if [ -f "$LOCKFILE" ]; then
			restart
		fi
		;;
	*)
		msg_usage "${0##*/} {start|stop|status|restart|reload|condstop|condrestart}"
		RETVAL=1
esac

exit $RETVAL
