#!/bin/sh
#
# Resource script for sending WinPopups using smbclient
# derived from Alan Robertson's MailTo script
#
# Author: Sandro Poppi <spoppi@gmx.de>
#
# License:      GNU General Public License (GPL)
# Support:      linux-ha@lists.linux-ha.org
#
# Description: sends WinPopups to a sysadmin's workstation
#	       whenever a takeover occurs.
#
#	Note: This command requires an argument, unlike normal init scripts.
#
#	This can be given in the haresources file as:
#
#		WinPopup::hosts
#
#	where "hosts" is a file containing the IPs/Workstation names
#	one by line to be sent WinPopups
#

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

usage() {
  echo "Usage: $0 [workstationfile] $LEGAL_ACTIONS"
  exit 1
}

# max. 2 parameters allowed
if [ $# -gt 2 ] ; then
  echo "Additional parameters found: $# but only 2 are allowed!"
  usage
fi

# See how we were called.
if [ $# -eq 2 ] ; then
  # optional parameter found
  cmd=$2
  hostfile=$1
else
  cmd=$1
  hostfile="hosts"
fi

OCF_RESKEY_hostfile=$hostfile
export OCF_RESKEY_hostfile

OCF_TYPE=WinPopup
OCF_RESOURCE_INSTANCE=${OCF_TYPE}
export OCF_TYPE OCF_RESOURCE_INSTANCE

ra_execocf  $cmd
