#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61pkgha_r714 src/packages/cluster/es/client/rte/root/cluster.es.client.rte.unconfig.sh 1.19.1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1997,2011 
# 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 
# @(#)59  1.19.1.1  src/packages/cluster/es/client/rte/root/cluster.es.client.rte.unconfig.sh, pkghacmp, 61pkgha_r714 12/1/11 11:26:12
#

###############################################################################
#
# unconfig script for the client.rte fileset
#
###############################################################################

###############################################################################
#
#  Name:  onintr
#
#  Rudimentary signal handler
#
#  Arguments:    none
#  Returns:      5 - exit with error
#  Environment:  interrupt handler
#
###############################################################################
function onintr
{
    echo "$0: Caught signal - exiting"
    exit 5
}

###############################################################################
#
#  Name:  if_failed
#
#  Common exit method
#
#  Arguments:    status - return code from some operation
#                errmsg - error message to display (if operation failed)
#
#  Returns:      if status is non 0 exit with error
#  Environment:  installp
#
###############################################################################
function if_failed
{
    status=$1
    errmsg=$2
    if [ $status -ne 0 ]; then
        echo Failed $errmsg
        exit 99
    fi
}

###############################################################################
#
# MAIN
#
###############################################################################
#
# Trap interrupts
#
trap onintr 1 2 3

#
# Establish a rudimentary path
#
PATH=$PATH:/bin:/usr/bin:/usr/sbin


STATUS=0
SAVEODMDIR=${ODMDIR}


LPPNAME="HACMP/ES for AIX"
CLUSTDIR="/usr/es/sbin/cluster"

HA_PRODUCT=""
HA_LEVEL=""
HA_STATE=""

################## Begin removal of old HACMP subsystems   ###################
# Remove any subsystem stuff first. Port to null.
rmssys -s clinfoES > /dev/null 2>&1
if_failed $? "removing clinfo from System Resource Controller"
##################  End removal of old HACMP subsystems    ###################

############### Begin removal of old /etc/services entries ###################
# Delete old entry from /etc/services just in case they exist.

chservices -d -v clinfo_deadman -p tcp -n 6176 >/dev/null 2>&1
if_failed $? "removing ${LPPNAME} entries from /etc/services"

chservices -d -v clinfo_client -p tcp -n 6174 >/dev/null 2>&1
if_failed $? "removing clinfo_client entry from /etc/services"

###############  End removal of old /etc/services entries  ###################

###################### Begin /etc/inittab modifications ######################
# Remove /etc/inittab entry 
rmitab hacmp >/dev/null 2>&1

######################  End /etc/inittab modifications  ######################

######################   Begin Refresh subsystem Daemons #######################
if [ -z "$INUCLIENTS" -a -z "$INUBOSTYPE" ]
then
	for SUB in inetd snmpd; do
        LC_ALL=C lssrc -s $SUB | grep inoperative > /dev/null 2>&1
        [ $? -eq 0 ] && continue
        refresh -s $SUB >/dev/null 2>&1
	done
fi
######################   End Refresh subsystem Daemons #########################

exit $STATUS

