#!/sbin/sh
###############
# Product: PHKL_25100
# Fileset: PHKL_25100
# preremove
# @(#) preremove  $Revision: AUTO-GENERATED PATCH_11.00 (PHKL_25100)
#------------------------------------------------------------------#
# (c)Copyright 1983-2001 Hewlett-Packard Co., All Rights Reserved. #
#------------------------------------------------------------------#
# SD preremove 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 actions not done in the       #
# unconfigure script in preparation for removal of the patch's     #
# files.                                                           #
#------------------------------------------------------------------#

_PATCHID=PHKL_25100

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.
#####
##### START_CUSTOMIZATION_HERE
########################################################################
# FUNCTIONS
########
# DeleteDriverEntry
#
#	Purpose:  To delete from the system file all the drivers that this fileset
#		has delivered.  Set the $exitval value based on the return value from
#		mod_systemfile().  If multiple deletions, ensure that a FAILURE value
#		of $exitval is not reduced by a later SUCCESS return.
#
DeleteDriverEntry()
{
	typeset retval

	mod_systemfile ${SW_SYSTEM_FILE_PATH} -d gvid
	retval=$?
	if [[ $retval -ne $SUCCESS ]]
	then
		MSG_DriverDeleteFailed
		exitval=$FAILURE
	fi

	mod_systemfile ${SW_SYSTEM_FILE_PATH} -d gvid_core
	retval=$?
	if [[ $retval -ne $SUCCESS ]]
	then
		MSG_DriverDeleteFailed
		exitval=$FAILURE
	fi
} # DeleteDriverEntry()
#
########
# MSG_DriverDeleteFailed
#
#	Purpose:  To issue an ERROR message to the agent log file.  
#
MSG_DriverDeleteFailed()
{
	cat <<- !!EOF
ERROR:   The attempt to remove driver gvid from the system file has
         failed for the above reason.  You must ensure that the system
         file at "${SW_SYSTEM_FILE_PATH}" does not contain an entry for
         gvid or gvid_core before a kernel build is attempted.  Manually
         editing "${SW_SYSTEM_FILE_PATH}" to delete references to gvid
         is one option you have.
!!EOF
} # MSG_DriverDeleteFailed()
#
########################################################################
# MAIN
########

	if [[ ${SW_SESSION_IS_KERNEL:-FALSE} = "TRUE" ]]
	then
		DeleteDriverEntry
	fi
 
##### END_OF_CUSTOMIZATION
exit $exitval