#!/bin/sh  
#
# Support:      linux-ha-dev@lists.tummy.com
# License:      GNU General Public License (GPL)
# This script sets the node (where it was called) to *active*
# It forces the other node to release all the held resources and lets
# this node do a takeover.
#
#       This script will only work for a two machine setup...
#       More than that and you need to vote, or something...


HA_DIR=/etc/ha.d
. ${HA_DIR}/shellfuncs

usage() {
	echo "usage:"
	echo "$0 [all|foreign|local|failback]" >&2
	exit 1
}

if 
  [ $# -ge 2 ]
then
	echo "$0: too many arguments"
	usage
	exit 1
fi

if
  [ $# -ge 1 ]
then
  resources=$1
else
  resources=all
fi

if [ $resources = "--help" ]; then
	usage
fi

if [ $resources != "all" ] && [ $resources != "foreign" ] &&
   [ $resources != "local" ] && [ $resources != "failback" ]; then
	echo "$0: wrong resources($resources)."
	usage
	exit 1
fi

ha_clustermsg <<-!MSG
	t=hb_takeover
	rsc_hold=$resources
!MSG


