#!/bin/sh
#
# 
# Description:	wrapper of OCF RA WAS, based on original heartbeat RA.
#		See OCF RA WAS 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
#
# An example usage in /etc/ha.d/haresources: 
#       node1  10.0.0.170 WAS::/opt/WebSphere/ApplicationServer/config/server-cfg.xml
#
# See usage() function below for more details...
#

# Source function library.
. @HB_RA_DIR@/hto-mapfuncs

unset LC_ALL; export LC_ALL
unset LANGUAGE; export LANGUAGE

usage() {
  cat <<-! >&1
	For the single server edition of WAS:
	usage: $0 [<WAS-configuration file>] $LEGAL_ACTIONS

	For the advanced edition of WAS:
	usage: $0 [<WAS-(snoop)-port-number>] $LEGAL_ACTIONS
	!
  exit 1
}

case $# in
  1)
    op=$1;;
  2)
    op=$2
    if [ -f $1 ]; then
	OCF_RESKEY_config=$1; export OCF_RESKEY_config
    else
	case $1 in
	    *[^0-9]*)	
		echo "ERROR: $1 is neither a WAS configuration file nor a valid port number!"
  		usage;;
	    *)
		OCF_RESKEY_port=$1; export OCF_RESKEY_port
		port=$1;;
	esac
    fi;;
  *)
    usage;;
esac

OCF_TYPE=WAS
OCF_RESOURCE_INSTANCE=${OCF_TYPE}
export OCF_TYPE OCF_RESOURCE_INSTANCE

ra_execocf $op
