#!/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.
. /etc/ha.d/resource.d//hto-mapfuncs

usage() {
  echo "Usage: $0 <email> [<subject>] {start|stop|status}"
  echo "$Id: MailTo.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $"
  exit 1
}

# 
# See how we were called.
#
case "$#" in
  0|1)	echo "At least 1 Email address has to be given!"
    	usage
	;;
  2)	email=$1
	cmd=$2
	subject=""
	;;
  3)	email=$1
	cmd=$3
	subject=$2
    	;;
  *)	echo "Additional parameters found: $# but max. 3 are allowed!"
	usage;;
esac

case "$cmd" in
  start|stop|status)
		;;
  *)		usage
		;;
esac

ra_execocf  "rsc_id=MailTo" "rsc_type=MailTo" "provider=heartbeat" $cmd "email=$email" "subject=$subject"
