#!/bin/sh
# $Id$
#
# Script:	S10arp
#
# Description:	Send gratuitous ARPs after takeover
#
# Platform:	Linux
#
# Author:	High-Availability.Com Ltd
#

#
# standard variables and functions
#
. /opt/HAC/bin/rsf.sh

arp="send_arp"	# gratuitous ARP generator command
count=5	# number of ARPs to send

service=${RSF_SERVICE:-"service_name"}	# edit for pre-1.3 releases
script="`basename $0`"

#
# args: <start|stop> [no_of_attempts]
#
state=$1		# starting or stopping?
attempts=${2:-'1'}	# no of attempts at this action

#
# decide action based on first argument
#
case "${state}" in

'start')
	dated_echo "Sending ARP packets"
	#
	# startup commands here
	#
	macaddr=`ifconfig ${RSF_IPDEV} |awk '/HWaddr/ { print $5 }'|sed -e 's/://g'`
	i=1
	while [ $i -le $count ]; do
		# may need to adjust args depending on command
		${arp} ${RSF_FLOATNAME} ${macaddr} ${RSF_FLOATNAME} ffffffffffff
		i=`expr $i + 1`
	done
	;;

'stop')
	:
	;;

*)
	echo "Usage: $0 <start|stop>"
	exit ${RSF_WARN}	# warning code
	;;

esac

exit ${RSF_OK}	# OK code (default)
