#!/usr/bin/ksh
#  ALTRAN_PROLOG_BEGIN_TAG                                                    
#  This is an automatically generated prolog.                                  
#                                                                              
#  Copyright (C) Altran ACT S.A.S. 2017,2018,2021.  All rights reserved.  
#                                                                              
#  ALTRAN_PROLOG_END_TAG                                                      
#                                                                              
# @(#)  7d4c34b packages/cluster/es/ui/common/usr/cluster.es.smui.common.unconfig.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM

#
# Add tracing support through a variety of mechanisms, including the standard
# installp "INST_DEBUG" variable, and the SMIT trace flag (smitty -v). And for
# those times where we might just want to debug the GUI alone, and not see all
# the other information that those methods provide, we support our own variable,
# SMUI_TRACE (which can be set to any non-null value).
#
if [[ -n $SMUI_TRACE                     || \
      $_SMIT_TRACE_FLAG == 0             || \
      $SM_INST_DEBUG    == @(Y|y|DEBUG)* || \
      $INST_DEBUG       == @(Y|y|DEBUG)* ]]
then
    typeset TAB=$(printf '\t')
    typeset PROGNAME="${0##*/}(usr-part)"
    export PS4="$PROGNAME:"'main()[$LINENO]($SECONDS'"):$TAB "
    set -x
fi

#
# Setup a rudimentary PATH
#
export PATH="/usr/bin:/usr/sbin:$PATH"
export LC_ALL=C  # Required, per "The AIX LPP Owner's Guide"

#
: If there are still files/directories for the agent, go ahead and remove them
#
if [[ -d /usr/es/sbin/cluster/ui/bin ]]
then
    print "    Removing all common files..."
    if [[ $_SMIT_VERBOSE_FLAG == 0 ]]
    then
        print "    rm -rf /usr/es/sbin/cluster/ui/bin"
    fi
    rm -rf /usr/es/sbin/cluster/ui/bin
fi

#
: If none of the other GUI filesets are installed any longer,
: get rid of the whole installation directory.
#
if [[ -d /usr/es/sbin/cluster/ui ]] && \
   ! lslpp -lc cluster.es.smui.agent  >/dev/null 2>&1 && \
   ! lslpp -lc cluster.es.smui.server >/dev/null 2>&1
then
    print "    Removing the GUI installation directory..."
    if [[ $_SMIT_VERBOSE_FLAG == 0 ]]
    then
        print "    rm -rf /usr/es/sbin/cluster/ui"
    fi
    rm -rf /usr/es/sbin/cluster/ui
fi

exit 0
