#!/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 postremove script template for 11.X patches.                  #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to perform any necessary cleanup actions after the     #
# patch's files have been removed.                                 #
#------------------------------------------------------------------#

_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 ----------------------
#----------------------------------------------------------------------------
#
################################################################################
# Restore previous custom saved files.  After restore, remove save_custom dir.

    FILE=/etc/rc.config.d/hparamgr

    if [ -z "${SW_ADMIN_DIRECTORY}" ]
    then
        SW_ADMIN_DIRECTORY="/var/adm/sw"
    fi

    if [ -e ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE ]
    then
        # restore the original file
	cp -p ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE $FILE
        if [ $? -ne 0 ]
        then
            echo "WARNING: ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE"
            echo "         not restored."
        else
            echo "NOTE:    ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID$FILE"
            echo "         restored."
            echo "         ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID directory being deleted."
            rm -r ${SW_ADMIN_DIRECTORY}/save_custom/$_PATCHID 
        fi
    fi

################################################################################
# Start up the array daemon's (AM60Srvr and/or hparamgrd)

    echo "NOTE:    Starting the relevant array daemons."

    ps -e | grep hparamgrd >/dev/null 2>&1
    hparamgrd_stat=$?	
    if [[ $hparamgrd_stat -eq 0 ]] 
    then
      echo "NOTE:    Monitor daemon \"hparamgrd\" is already runing" 
    fi
 
    if [[ -x ${SW_ROOT_DIRECTORY}usr/lbin/hparray/hparamgrrc ]]
    then
      echo "NOTE:    Check the file ${SW_ROOT_DIRECTORY}etc/hparray/HPARAMGR.INFO"
      echo "         to determine if any arrays where found."

      ${SW_ROOT_DIRECTORY}usr/lbin/hparray/hparamgrrc >> ${SW_ROOT_DIRECTORY}etc/hparray/HPARAMGR.INFO 2>&1 &
    else
      echo "WARNING:   Array monitor daemon(s) cannot be started."
      exitval=$WARNING
    fi

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

exit $exitval
