#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61pkgha_r714 src/packages/cluster/es/cspoc/rte/root/cluster.es.cspoc.rte.unconfig.sh 1.4 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2004,2008 
# 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 
# @(#)01	1.4 src/packages/cluster/es/cspoc/rte/root/cluster.es.cspoc.rte.unconfig.sh, pkghacmp, 61pkgha_r714 7/3/08 11:27:14

###############################################################################
#
#  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 99
    fi
}

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

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

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

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

#
# local variables
#
BFF="cluster.es.cspoc"
LPPDIR="/lpp/${BFF}"
HA_GROUP="hacmp"

#
#  Check to see if the group file exists
#
if [ -f ${LPPDIR}/.${HA_GROUP}group ]
then
    rm -f ${LPPDIR}/.${HA_GROUP}group

    #
    #  If no users exist in that group, remove it
    #
    LC_ALL=C lsgroup -c $HA_GROUP | grep users > /dev/null 2>&1
    if [ $? -ne 0 ]
    then
        rmgroup $HA_GROUP > /dev/null 2>&1
        if_failed $? "removing ${HA_GROUP}."
    fi
fi

exit 0
