#!/usr/bin/ksh
#
# Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
#
# @(#)preremove	1.4 03/03/18
#

# Define the paths used by this script
SCRIPT=$0
SCRNAME=`basename $SCRIPT`
COMPONENT_DIR=`dirname $0`

# Include function libraries
. $ESM_LIB/esm_lib.ksh
. $ESM_LIB/configvars_lib.ksh

. $COMPONENT_DIR/component_lib.ksh


#---------------------------------------
# Display the usage message
# Arguments: 
#---------------------------------------
l_usage () {

    echo $SCRIPT "INFO: usage:     $SCRNAME [options]

    where options are:

        <no options>           Perform the pre-remove actions
        -? | -h | --help       Display this message
"
    exit 0
}

#---------------------------------------
# Arguments: 
#  $1 command line arguments (see usage function above)
#---------------------------------------
l_preremove_actions () {

    # Remove the ESM properties files
    #
    /usr/bin/rm -f esm.properties esm_sensitive.properties

    # Remove all spurious ESM-related temp files in /var/tmp
    #
    /usr/bin/rm -f /var/tmp/esm*log*

    # Remove the bag 'o bits security file used by cci_wrapper.ksh
    #
    /usr/bin/rm -f $ESM_CONFIG/sd.dat

    return 0
}

#---------------------------------------
# Arguments: 
#  $1 command line arguments (see usage function above)
#---------------------------------------
l_main () {

    if [ $# -eq 0 ]; then
		el_secho 1 $ESM_LOG y "=== $CL_NAME $CL_VERSION Start: Execute pre-Remove actions for $CL_NAME"
		l_preremove_actions

		el_secho 1 $ESM_LOG y "=== $CL_NAME $CL_VERSION End:   Execute pre-Remove actions for $CL_NAME"
    else
		usage
	fi
}


l_main $*

if [ "$DEBUG" = "1" ]; then
    el_debug
    cl_debug
    el_secho 1 $ESM_LOG n "Local Environment Variables:"
    el_secho 1 $ESM_LOG n "    COMPONENT_DIR |$COMPONENT_DIR|"
    el_secho 1 $ESM_LOG n "    SCRIPT        |$SCRIPT|"
    el_secho 1 $ESM_LOG n "    SCRNAME       |$SCRNAME|"
    el_secho 1 $ESM_LOG n "    RELOCATE_DIR  |$RELOCATE_DIR|"
fi
