#!/bin/ksh
#  ALTRAN_PROLOG_BEGIN_TAG
#  This is an automatically generated prolog.
#
#  Copyright (C) Altran ACT S.A.S. 2017,2021.  All rights reserved.
#
#  ALTRAN_PROLOG_END_TAG
#
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/events/intersite_fallover_prevented.sh 1.4 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2005,2011 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)  7d4c34b 43haes/usr/sbin/cluster/events/intersite_fallover_prevented.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM
#########################################################################
#
# Questions ? Comments ? Suggestions ? mailto:hafeedbk@us.ibm.com
#
#########################################################################

#########################################################################
#                                                                       #
#       Name:           intersite_fallover_prevented                    #
#                                                                       #
#       Description:    This event script is called when intersite      #
#                       fallover would normally occur, but is prevented #
#                       because resource group cross-site recovery      #
#                       for selective is set to notify.                 #
#                                                                       #
#                                                                       #
#       Called by:      rg_move event script                            #
#                                                                       #
#       Calls to:       None                                            #
#                                                                       #
#       Arguments:      nodename resource_group_name                    #   
#                                                                       #
#                                                                       #
#       Returns:        0       success                                 #
#                       1       failure                                 #
#                       2       bad argument                            #
#                                                                       #
#########################################################################

typeset PROGNAME=${0##*/}
export PATH="$(/usr/es/sbin/cluster/utilities/cl_get_path all)"

if [[ $VERBOSE_LOGGING == "high" ]]; then
    eval export $(cllsparam -x)
    set -x
    version='%I%'
fi

#
# Set the Run-Time Parameter values and export them
# to all successive scripts.
#
set -a
eval $(cllsparam -n $LOCALNODENAME)
set +a

#
# Check for minimal invocation
#
if [ $# -gt 2 ]
then
    cl_log  10405 "Usage: $PROGNAME nodename resource_group_name\n"  $PROGNAME
    exit 2
fi


STATUS=0
EXIT_STATUS=0

#
# args are the event node, id of the server and an optional monitor name
#
export NODENAME=$1
export GROUPNAME=$2

#
# Event emulation support
#
if [ ! -n "$EMULATE" ]
then
   EMULATE="REAL"
fi


#
# Lookup any user defined notification method and execute it 
    
NOTIFY=$(odmget -q"monitor=CROSS_SITE_RG_MOVE and name=NOTIFY_METHOD" HACMPmonitor | grep "value =" | cut -d'"' -f2)

NOTIFY_SCRIPT=$(echo $NOTIFY | cut -d' ' -f1) # in case of embedded blank

if [[ -n $NOTIFY_SCRIPT && -x $NOTIFY_SCRIPT ]]
    then
    	dspmsg scripts.cat 9333 "$PROGNAME: Calling user specified notify method $NOTIFY_SCRIPT\n" $PROGNAME $NOTIFY_SCRIPT
  	ODMDIR=/etc/objrepos $NOTIFY &
    fi


#
# Note to users: to add any user defined processing during an 
# intersite_fallover_prevented event,
# define a pre or post event (do not modify this script).
# 

exit 0

