#!/bin/sh
#
#
# Description:	wrapper of OCF RA IPsrcaddr, based on original heartbeat RA.
#		See OCF RA IPsrcaddr for more information.
#
# Author:	Xun Sun <xunsun@cn.ibm.com>
# Support:	linux-ha@lists.linux-ha.org
# License:	GNU General Public License (GPL)
# Copyright:	(C) 2005 International Business Machines
#
#	It can add a preferred source address, or remove one.
#
#	usage: IPsrcaddr ip-address {start|stop|status|monitor}
#
#	The "start" arg adds a preferred source address.
#
#	Surprisingly, the "stop" arg removes it.	:-)
#
#	NOTES:
#
#	1) There must be exactly one default route!
#	2) The script depends on Alexey Kuznetsov's ip utility from the
#	iproute aka iproute2 package.
#	3) No checking is done to see if the passed in IP address can
#	reasonably be associated with the interface on which the default
#	route exists.  So unless you want to deliberately spoof your source IP,
#	check it!  Normally, I would expect that your haresources looks
#	something like:
#
#		nodename ip1 ip2 ... ipN IPsrcaddr::ipX
#
#	where ipX is one of the ip1 to ipN.
#

. @HB_RA_DIR@/hto-mapfuncs

USAGE="usage: $0 <ip-address> $LEGAL_ACTIONS";

usage() {
    echo $USAGE >&2
    exit 1
}

if [ $# != 2 ]; then
    usage
fi

OCF_TYPE=IPsrcaddr
OCF_RESOURCE_INSTANCE=${OCF_TYPE}
export OCF_TYPE OCF_RESOURCE_INSTANCE

OCF_RESKEY_ipaddress=$1; export OCF_RESKEY_ipaddress
ra_execocf $2
