#!/bin/sh
##
##  @(#)preremove	1.1 - 05/02/00
##
##  Description:  preremove script for SUNWscrdt installation.
##                This script is run before the package is removed.
#
# ident	"@(#)preremove	1.1	01/11/15 SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#

REM_DRV=/usr/sbin/rem_drv
RM=/bin/rm
DEVDIR=/dev
RDT_MODULE=rsmrdt
SED=/usr/bin/sed
DEVLINKS_TAB="/etc/devlink.tab"
GREP=/usr/bin/grep
CP=/bin/cp

#
# remove the driver
#

if [ ! -x $REM_DRV ] ; then
    echo "Cannot find $REM_DRV, aborting..."
    exit 1
fi
echo "removing rsmrdt driver from the system."
$REM_DRV $RDT_MODULE


#
# remove the symbolic link
#

if [ ! -d $DEVDIR ] ; then
    echo "The directory $DEV is not there, aborting..."
    exit 1
fi

echo "removing symbolic link $DEVDIR/$RDT_MODULE"
$RM -f $DEVDIR/$RDT_MODULE

#
# remove ourselves from /etc/devlink.tab
# Warning: the whitespace after "rsmrdt" in the string below
#          is a TAB, not a space.
#

DEVLINK_MODIFIED=`${GREP} "type=ddi_pseudo;name=rsmrdt	" ${DEVLINKS_TAB}`
if [ -n "$DEVLINK_MODIFIED" ]
then
	echo "Removing rsmrdt from $DEVLINKS_TAB."
	${SED} /"type=ddi_pseudo\;name=rsmrdt	"/d ${DEVLINKS_TAB} > /etc/devlink.tab.norsmrdt
	${CP} /etc/devlink.tab.norsmrdt ${DEVLINKS_TAB}
	${RM} /etc/devlink.tab.norsmrdt
fi

exit 0

## EOF
