#!/bin/sh

# @(#)preremove	1.3 00/08/14 Sun Microsystems
# SUNWglmr preremove script
# Copyright (c) 1998-2000 by Sun Microsystems, Inc.
# All rights reserved.
#

#
#	Defining convenient variables for later
#
REM_DRV=rem_drv
DRV1=rasctrl

#
# Select the correct rem_drv options to execute.
# Only attempt to unload the driver on a running system
#
if [ "${BASEDIR}" != "/" ]; then
	#
	# On a client,
	# modify the system files and touch /reconfigure ??
	# for reconfigure reboot ??
	#
	REM_DRV="${REM_DRV} -b ${BASEDIR}"
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}) " ${BASEDIR}/etc/name_to_major` -eq 1 ]; then

#
#	Must remove drivers in reverse order of installation
#

#	Remove rasctrl RAS driver
	${REM_DRV} ${DRV1} || {
		echo "\n${PKGINST}: Failed ${REM_DRV} ${DRV3}\n" >&2
		exit 1
	}

fi

exit 0
