#!/bin/sh
#
#	License:      GNU General Public License (GPL)
#
#	This script is called in response to an ip-request message after the
#	one we've called calls us back.
#
#	What we do then is to take over the IP address requested...
#
#	Note: this script is called by the heartbeat code, so it gets all
#	kinds of funny arguments
#
#		"ip-request-resp"

. $HA_FUNCS

#
#
US="ip-request-resp"
TAKE=$HA_NOARCHBIN/ResourceManager

CMD=$1
#
#	$HA_dest, $HA_ipaddr and $HA_ok are fields from the message
#
REQNODE=$HA_dest
RSCGRPNAME=$HA_ipaddr
RESPONSE=$HA_ok
THEYOWN=$HA_weown

# Really a resource group name...
case "$RSCGRPNAME" in
    ?*)		false;;
    *)
  	cat <<-!EOF
	$0 will take control the specified resource group using $TAKE.
	
	$0 was invoked with these arguments:
	$*
	And this is the HA_ environment:
	!EOF
	env | grep '^HA_'
	exit 1;;
esac
if
  [ "X$REQNODE" != "X$HA_CURHOST" ]
then
  exit 0; # We didn't request this IP address...  Ignore the response.
fi
ha_log "received $US $RSCGRPNAME $RESPONSE $THEYOWN"
case $RESPONSE in
  OK)	$TAKE takegroup $RSCGRPNAME;;
  *);;
esac
