#!/usr/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/sa/ihs/sbin/cl_ihsstop.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2009,2010 
# 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 
# @(#)44	1.1  src/43haes/usr/sbin/cluster/sa/ihs/sbin/cl_ihsstop.sh, hacmp, 61haes_r714 11/28/11 14:59:04
###################################################################
##
## NAME:	cl_stopihs.sh
##
## DESCRIPTION:	
##    Stops the IBM HTTP Server
##
## ARGUMENTS:	
##    application name - Used to fetch the data from metadata odm
##
## OUTPUT:
##    None	
##
## EXIT CODES:	
##    0 - success
###   1 - failure
##
## KLIB Functions:
##    KLIB_IHS_log_message
##
###################################################################


##########
# MAIN
##########


# Load the common klib functions, abort, logmsg, dbgmsg, etc.
. /usr/es/lib/ksh93/common_functions.ksh93

# Set the FPATH for all HACMP functions
umask -S u=rw,g=,o=

PROGNAME=$(basename ${0})
PATH="$($(dirname ${0})/../../../utilities/cl_get_path all)"
PATH=$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin:/usr/es/sbin/cluster/sa/sbin
FPATH_BASE=/usr/es/lib/ksh93
FPATH=$FPATH_BASE/hacmp:$FPATH_BASE/sa:$FPATH_BASE/aix:$FPATH_BASE/aix/odm:$FPATH_BASE/ihs
export PATH FPATH

[[ "$VERBOSE_LOGGING" == "high" ]] && set -x

KLIB_DEFAULT_LOGFILE=/var/hacmp/log/ihssa.log
KLIB_HACMPLOG_ENTRY=ihssa.log
KLIB_OUTPUT_CONSOLE=false
KLIB_MSGCATALOG="ihssa.cat"
KLIB_MSGSET=7

# Get the application name
APPLICATION_NAME=$1
if [[ -z $APPLICATION_NAME ]]; then
    KLIB_IHS_log_message "WAS ERROR: Please specify the application name."
    exit 1
fi

typeset INSTALL_PATH
set -a
    eval $(clquerysaapp -a $APPLICATION_NAME INSTALL_PATH)
set +a

if [[ $INSTALL_PATH != "" ]] ; then
    IHS_SCRIPT="$INSTALL_PATH/bin/apachectl stop"

    KLIB_IHS_log_message "WAS INFO: Stop IBM HTTP Server by calling $IHS_SCRIPT"

    # Stop the HTTP Server
    $IHS_SCRIPT
else
    # error
    KLIB_IHS_log_message "WAS ERROR: No Metadata information Found."
    exit 1
fi

exit 0
