#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61pkgha_r714 src/packages/cluster/es/client/lib/usr/cluster.es.client.lib.unconfig.sh 1.2.1.1 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2001,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 
# @(#)36   1.2.1.1   src/packages/cluster/es/client/lib/usr/cluster.es.client.lib.unconfig.sh, pkghacmp, 61pkgha_r714 12/1/11 11:28:58
###############################################################################
#
#  Name:  onintr
#
#  Rudimentary signal handler
#
#  Arguments:    none
#  Returns:      5 - exit with error
#  Environment:  interrupt handler
#
###############################################################################
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
#
###############################################################################
if_failed()
{
    status=$1
    errmsg=$2
    if [ $status -ne 0 ]; then
        echo "Failed $errmsg"
        exit $status
    fi
}

###############################################################################
#
# Main
#
###############################################################################

#
# Setup a rudimentary PATH
#
PATH=/bin:/usr/bin:/usr/sbin:$PATH

#
# Establish a signal handler
#
trap onintr 1 2 3 15

#
# Remove symbolic links for the PowerHA System Mirror libraries
# 
ESDIR=/usr/es/lib
LNDIR=/usr/lib
success=0

cd ${ESDIR}
for file in $(ls | grep -v '^\.')
do
  ESFILE="${ESDIR}/${file}"
  LNFILE="${LNDIR}/${file}"
  if [[ -L "${LNFILE}" ]]; then
    rm -f ${LNFILE}
    if (( $? != $success )) ; then
       echo "WARNING: Failed to remove symbolic link ${LNFILE}."
    fi
  fi
done

exit 0
