#! /usr/bin/sh
#
# ident "@(#)postbackout 1.2     02/10/05 SMI"
#
# Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
#	Defining convenient variables for later
#
PKG_INSTALL_ROOT=$ROOTDIR
REM_DRV=rem_drv
DRV1=uflash
DFILE=${PKG_INSTALL_ROOT}/etc/devlink.tab
TFILE=${PKG_INSTALL_ROOT}/etc/devlink.tab.tmp
#
# Select the correct rem_drv options to execute.
# Only attempt to unload the driver on a running system
#
if [ "${PKG_INSTALL_ROOT}" != "/" ]; then
	#
	# On a client,
	# modify the system files and touch /reconfigure ??
	# for reconfigure reboot ??
	#
	REM_DRV="${REM_DRV} -b ${PKG_INSTALL_ROOT}"
fi


#
#	(Rudimentary) Test to see if rem_drv has already been run before:
#   o	If found *exactly* 3 aliases, rem_drv hasn't been run before, so run it.
#   o	Else, rem_drv has run once already, so don't run it again.
#

if [ `egrep -c "^(${DRV1}) " ${PKG_INSTALL_ROOT}/etc/name_to_major` -eq 1 ]; then

#
#	Must remove drivers in reverse order of installation
#

	${REM_DRV} ${DRV1} || {
		echo "\n${PKGINST}: Failed ${REM_DRV} ${DRV1}\n" >&2
		exit 1
	}

fi

exit 0

