#! /sbin/sh
###############################################################################
#  postremove for HPVM 
#  @(#) $Revision: 3649 $
###############################################################################
#
# (c) Copyright Hewlett-Packard Company 1994-1998
#
###############################################################################
# SD control utilities
###############################################################################

    UTILS="/usr/lbin/sw/control_utils"
    if [[ ! -f $UTILS ]]
    then
        echo "ERROR:   Cannot find $UTILS"
        exit 1
    fi
    . $UTILS
    exitval=$SUCCESS

###############################################################################
# uninstall dynamiclly loadable drivers



DeleteDriverEntry()
{

   typeset -i retval

   for driver_name in \
       ia64vmm \
       vswitch
   do


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

} #DeleteDriverEntry()
 


########
# MSG_DriverDeleteFailed
#
#   Purpose:  To issue an ERROR message to the agent log file.  
#
MSG_DriverDeleteFailed()
{
	msg ERROR "The attempt to remove driver "$driver_name" 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 "$driver_name" before a kernel build is attempted.  Manually \
         editing "${SW_SYSTEM_FILE_PATH}" to delete references to \
         "$driver_name" is one option you have."
} # MSG_DriverDeleteFailed()
 
########################################################################
# MAIN

    typeset -ix exitval
#########


DeleteDriverEntry

/usr/bin/rm -rf /usr/conf/mod/ia64vmm >/dev/null 2>&1
/usr/bin/rm -rf /usr/conf/mod/vswitch >/dev/null 2>&1


exit $exitval
