####################################################################
# (C) Copyright 2001-2012 Hewlett-Packard Development Company, L.P.
# @(#) Product Name              :  HP Serviceguard
# @(#) Product Version           :  A.12.10.00
# @(#) Patch Name                :  
####################################################################

# DRCheckDiskStatus 07/30/01
# * modified 10/26/05 
# * to accommodate CLX EVA support
# This program is called by the MC/SG package control script if  
# the package uses physical data replication (e.g. DATA_REP=CLX
# has been specified in the package control file.).
#
# This program checks the existence of the environment file  
# of a DR integration in the package directory (e.g. the User 
# Configuration File of Cluster Extension XP/EVA). The rule for the
# environment file name is the combination of the package name 
# concatenated with _clx.env (in case of Cluster Extension XP/EVA). 
# There must be only one DR environment file for each package.
#
# For example, if the name of package is CLXPKG and the package
# uses CA XP for remote data replication, then the environment 
# file must be named CLXPKG_clx.env and must exist in the SAME 
# directory in which the package control file is located, which
# is commonly referred to as package directory.
#
# INPUT PARAMETER:
# $1: The full path name of the package control file.
# $2: "start" or "stop" - indication whether the package is
#     starting or stopping.
# $3: Data replication method.  
# $4: LVM command - Currently not used. For future expansion   
# $5: Path to the XDC Configuration file
# $6: LVM Volume group name - Used by MD Software Mirroring
#
###############################################################
. ${SGCONFFILE:=/etc/cmcluster.conf}

PATH=$PATH:/sbin:/usr/bin:/usr/sbin:/etc:/bin:/opt/hpclx/bin:/opt/hpclxeva/bin
export PATH

PACKAGE_CNTL_FILE=$1
PACKAGE_ACTION=$2

if [[ $3 = [cC][lL][xX] ]]
then
        
        if [[ -x /opt/hpclx/bin/clxmcsg ]]
        then
                exec /opt/hpclx/bin/clxmcsg ${PACKAGE_ACTION} ${PACKAGE_CNTL_FILE} ${PACKAGE}
        else
                echo "ERROR: The package is configured to use Cluster Extension XP"
                echo -e "\tremote data replication, but /opt/hpclx/bin/clxmcsg"
                echo -e "\tis either non-existant or non-executable."
                echo -e "\tPlease install HP Cluster Extension XP for SG correctly."
                exit 1
        fi
elif [[ $3 = [cC][lL][xX][eE][vV][aA] ]]
then

        if [[ -x /opt/hpclxeva/bin/clxevamcsg ]]
        then
                exec /opt/hpclxeva/bin/clxevamcsg ${PACKAGE_ACTION} ${PACKAGE_CNTL_FILE} ${PACKAGE}
        else
                echo "ERROR: The package is configured to use Cluster Extension EVA"
                echo -e "\tremote data replication, but /opt/hpclxeva/bin/clxevamcsg"
                echo -e "\tis either non-existant or non-executable."
                echo -e "\tPlease install HP Cluster Extension EVA for SG correctly."
                exit 1
        fi
elif [[ $3 = [xX][dD][cC][mM][dD] ]]
then

        if [[ -x ${SGSBIN}/raid_control ]]
        then
                exec ${SGSBIN}/raid_control ${PACKAGE_ACTION} "$5" "$6"
        else
                echo "ERROR: The package is configured to use MD Software RAID"
                echo -e "\tremote data replication, but $SGSBIN/raid_control"
                echo -e "\tis either non-existent or non-executable."
                echo -e "\tPlease install the Extended Distance Cluster for SGLX correctly."
                exit 1
        fi
else
        echo "ERROR: Unrecognized remote data replication method - $3"
        echo -e "\tThe only supported values are \"CLX\" and \"CLXEVA\" and \"XDCMD\"."
        exit 1
fi
