#!/bin/ksh93
#  ALTRAN_PROLOG_BEGIN_TAG                                                    
#  This is an automatically generated prolog.                                  
#                                                                              
#  Copyright (C) Altran ACT S.A.S. 2018,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/sa/ihs/sbin/cl_ihssaquery.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 
# @(#)  7d4c34b 43haes/usr/sbin/cluster/sa/ihs/sbin/cl_ihssaquery.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM
#############################################################################
##
## Name:    cl_ihssaquery
##
## Description:    Performs application discovery query on the local node
##                 to determine if IBM Http Server is available 
##
## Arguments:    none
##
## Returns:    n/a
##
#############################################################################

. /usr/es/lib/ksh93/func_include
version='1.1 $Source: 61haes_r711 43haes/usr/sbin/cluster/sa/ihs/sbin/cl_ihssaquery.sh 1$'


#############################################################################
# Functions:
#
#
#############################################################################

function displayIHSInstall
{
    [[ "$VERBOSE_LOGGING" == "high" ]] && set -x
    integer installed=0
    
    # Perform volume group discovery
    clharvest_vg -w > /dev/null

    $IHSSA_SBIN_DIR/cl_discihs 2>/dev/null | while read line; do
        echo $line | IFS=: read component install_count install_path version install_vgs install_pvids listen_host
        
        # Check for version
        if (( $version < $IHS_MIN_VERSION || $version > $IHS_MAX_VERSION )) ; then
            break
        fi

        # Check for multiple installs
        if (( $install_count > 1 )); then
            break
        fi

        # Check for volume groups
        if [[ -z $install_vgs ]] ; then
            break
        fi

        KLIB_HACMP_are_pvids_shared $install_pvids
        if (( $? != 0 )); then
            break
        fi
        
        installed=1
        break;

    done
    
    print -n $(dspmsg -s 10 ihssa.cat 10 "IBM HTTP Server Smart Assist")
    print -n ":IHS_6.0:"
    print -n $(dspmsg -s 10 ihssa.cat 15 "IBM Http Server")
    print -n ":IHS_SERVER:"
    echo $installed
    
}

#############################################################################
# Global Variables:
#############################################################################

# Set the FPATH for all IHS / HACMP functions
FLIB=/usr/es/lib/ksh93
FPATH=$FLIB/utils:$FLIB/hacmp:$FLIB/ihs:$FLIB/util:$FLIB/util/list:$FLIB/aix/:$FLIB/aix/odm/:$FLIB/db2/vg
PATH=$PATH:/usr/es/sbin/cluster/sa/sbin/:/usr/es/sbin/cluster/utilities/

IHSSA_HOME="/usr/es/sbin/cluster/sa/ihs"
IHSSA_SBIN_DIR="$IHSSA_HOME/sbin"

IHS_MIN_VERSION="6.0"
IHS_MAX_VERSION="6.1"


#############################################################################
# Main:
#############################################################################

displayIHSInstall

exit 0
