#!/bin/ksh93
#  ALTRAN_PROLOG_BEGIN_TAG                                                    
#  This is an automatically generated prolog.                                  
#                                                                              
#  Copyright (C) Altran ACT S.A.S. 2019,2020,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/tsmserver/sbin/cl_tsmserverdiscovery.sh 1.4 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 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/tsmserver/sbin/cl_tsmserverdiscovery.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM

###############################################################################################
#
# NAME:
#	cl_tsmserverdiscovery
#
# PURPOSE:
#	Discovers TSM server configuration is installed or not it checks the fileset 
#	tivoli.tsm.server is installed or not.	
#
# ARGUMENTS:
#	n/a
#
# RETURNS
#  0 on success
#  1 on Failure
#
#################################################################################################


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

. /usr/es/sbin/cluster/sa/tsmserver/sbin/cl_tsmserverGlobals

function discover_tsm_server {

        [[ "$VERBOSE_LOGGING" == "high" ]] && set -x
	
        /usr/bin/lslpp -iq tivoli.tsm.server >> $LOG_FILE 2>&1
        # For TSM server version 8.0.0 and more,fileset tivoli.dsm.server does
        # not exist,hence verify TSM server availability from installed packages   
        if (( $? != 0 ))
        then
            /opt/IBM/InstallationManager/eclipse/tools/imcl listInstalledPackages 2>>$LOG_FILE| grep -q tivoli.dsm.server && return 1
        else
            return 1
        fi
        return 0
	
}

typeset result

discover_tsm_server
result=$?
echo "TSM server smart assist:TSM_SERV:TSM server:TSM_SERVER:$result"
exit 0
