#! /bin/sh
# Copyright (c) 2004 SuSE AG, Nuernberg, Germany.  All rights reserved.
#		2006 Emil Stephan, ste@esqhen.su.uunet.de
#
# Author: Mads Martin Joergensen <mmj@suse.de>
#	  Emil Stephan, <ste@esqhen.su.uunet.de>
#
# /etc/init.d/arp
#
# System startup script for arp service(s)
#
### BEGIN INIT INFO
# Provides: arp
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: create arp entries
### END INIT INFO

. /etc/rc.status

rc_reset

case "$1" in
    # It's a one shot binary creating arp entries, so the below is
    # ok in this special case.
    start|restart|try-restart|reload|force-reload)
	echo -n "creating arp entries "
	if=`fgrep '# if' /etc/ethers | cut -d " " -f 3`
	arp -i $if -f /etc/ethers
        rc_status -v
	;;
    stop)
	# we had rc_reset above, so we return 0 anyway
	if=`fgrep '# if' /etc/ethers | cut -d " " -f 3`
	cat /etc/ethers | while read eth ip flags
	do
	    if test "$eth" != "#"
	    then
		echo deleteing arp entry for $ip
		arp -i $if -d $ip
	    fi
	done
	;;
    status)
	# sm-notify is not a daemon, but a one-shot binary
	# nothing to be checked, status is unknown
	rc_failed 4
        rc_status -v
        ;;
    *)
	echo "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
	exit 1
	;;
esac
rc_exit
