#!/bin/sh
#
# Description:	wrapper of OCF RA MailTo, based on original heartbeat RA.
#		See OCF RA MailTo 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
#
#	This can be given in the haresources file as:
#		MailTo::alanr@unix.sh::BigImportantWebServer
#		MailTo::alanr@unix.sh,spoppi@gmx.de::BigImportantWebServer
#
#	This will then be put into the message subject and body.

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

usage() {
  echo "Usage: $0 <email> [<subject>] $LEGAL_ACTIONS"
  exit 1
}

case "$#" in
  0|1)	echo "At least 1 Email address has to be given!"
    	usage
	;;
  2)	
	cmd=$2
	OCF_RESKEY_email=$1
	export OCF_RESKEY_email
	;;
  3)	
	cmd=$3
	OCF_RESKEY_email=$1
	OCF_RESKEY_subject=$2
	export OCF_RESKEY_email OCF_RESKEY_subject
    	;;
  *)	echo "Additional parameters found: $# but max. 3 are allowed!"
	usage;;
esac

OCF_TYPE=MailTo
OCF_RESOURCE_INSTANCE=${OCF_TYPE}
export OCF_TYPE OCF_RESOURCE_INSTANCE

ra_execocf $cmd
