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

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

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" != "no" ] || exit

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

start()
{
	echo -n "Starting arpwatch: "
	daemon arpwatch
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
}

stop()
{
	echo -n "Stopping arpwatch: "
	killproc arpwatch
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
}

restart()
{
	stop
	start
}

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

exit $RETVAL
