#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61pkgha_r714 src/packages/cluster/es/client/clcomd/root/cluster.es.client.clcomd.unconfig.sh 1.5.1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2008,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 
# @(#)20  1.5  src/packages/cluster/es/client/clcomd/root/cluster.es.client.clcomd.unconfig.sh, pkghacmp, 53pkgha_r550 7/3/08 10:55:56
###############################################################################
#
# Un-config script for the clcomd fileset - undoes the config script
#
###############################################################################

###############################################################################
#
#  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
{
    typeset status
    typeset errmsg

    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

#
# target directory
#
CLUSTDIR="/usr/es/sbin/cluster"

#
# Trap interrupts so as to handle them gracefully
#
trap onintr 1 2 3

#
# Stop services
stopsrc -cs clcomdES > /dev/null 2>&1

#
# Remove Systems Services definitions
#
rmssys -s clcomdES > /dev/null 2>&1

#
# Remove legacy clcomd entry from the /etc/services file
#
chservices -d -v clcomd -p tcp -n 6191 > /dev/null 2>&1
if_failed $? " removing legacy clcomd port 6191 from /etc/services"

#
# These files may have been created at run-time 
#
rm -f /var/hacmp/clcomd/clcomd.log*
rm -f /var/hacmp/clcomd/clcomddiag.log*

exit 0
