#!/sbin/sh
#------------------------------------------------------------------#
#
# HPUX_ID: @(#) $Revision: 17.3 $ generated on Wed Feb 21 17:19:34 MST 2001
#
# (c)Copyright 1983-2001 Hewlett-Packard Co.,  All Rights Reserved.
#
#------------------------------------------------------------------#
# SD preinstall script template for 11.X patches.                  #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to prepare the system for installation of the patch.   #
#------------------------------------------------------------------#

_PATCHID=PHCO_23149

UTILS="/usr/lbin/sw/control_utils"

if [ ! -f $UTILS ]; then
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

. $UTILS
exitval=$SUCCESS

#####
##### Insert any code you may require at this point in the script.
##### Pay attention to the exitval variable and set appropriately
##### in your code.  If you are unsure as to what types of operations
##### are legal in this file and what types aren't, consult the 
##### "Guidelines for SD Control Scripts" document.
#
#----------------------------------------------------------------------------
#-------------------------- Begin ESSD extended script ----------------------
#----------------------------------------------------------------------------
#
###############################################################################
# Try to kill any daemons - hparamgrd and AM60Srvr

    if [[ $SW_ROOT_DIRECTORY != "/" ]]
    then
      echo "WARNING: Software Root Directory, ${SW_ROOT_DIRECTORY}, is not \"/\",  "
      echo "         cannot kill monitor daemons.                                  " 
      exitval=$WARNING
      exit $exitval
    fi

    #
    # kill monitor daemon
    #

    kill_named_procs hparamgrd SIGKILL
    retval=$?
    if [[ $retval -ne 0 ]]
    then
      echo "ERROR:   Could not kill the \"hparamgrd\" daemon.  The new hparamgrd    "
      echo "         file cannot be installed while the daemon is running.          " 
      echo "         Please manually kill the hparamgrd daemon and reinstall the    " 
      echo "         \"$PRODUCT\" product.                                          "
      exit $FAILURE
    fi

    #
    # kill AM60Srvr daemon
    #
    
    kill_named_procs AM60Srvr SIGKILL
    retval=$?
    if [[ $retval -ne 0 ]]
    then
      echo "ERROR:   Could not kill the \"AM60Srvr\" daemon.  The new AM60Srvr    "
      echo "         file cannot be installed while the daemon is running.  Please  " 
      echo "         manually kill the AM60Srvr daemon and reinstall the           " 
      echo "         \"$PRODUCT\" product.                                          "
      exit $FAILURE
    fi
 
###############################################################################
# Saving /etc/rc.config.d/hparamgr for patch removal recovery

    FILE=/etc/rc.config.d/hparamgr
    
    if [ -z "${SW_ADMIN_DIRECTORY}" ]
    then
        SW_ADMIN_DIRECTORY="/var/adm/sw"
    fi

    SAVEFILE=${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE

    if [ -e $FILE ]
    then
        typeset DIRNAME=${SAVEFILE%/*}

        if [ ! -z $DIRNAME ] 
	then 
            r_mkdir 500 bin bin $DIRNAME
        fi

        cp -p ${FILE} ${SAVEFILE}
        if [[ $? -ne $SUCCESS ]]
        then
            echo "WARNING: ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE"
            echo "         not saved."
        else
            echo "NOTE:    ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE"
            echo "         saved."
        fi 
    fi

###############################################################################
#
#----------------------------------------------------------------------------
#------------------------ End ESSD extended script --------------------------
#----------------------------------------------------------------------------
#
#####
##### START_CUSTOMIZATION_HERE

exit $exitval
