#!/bin/sh  -xv

PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH

if [ ! \( -f $BASEDIR/etc/devlink.tab -a \
	  -f $BASEDIR/etc/name_to_major -a \
	  -f $BASEDIR/etc/minor_perm \)  ] 
then
	echo "Package cannot be installed in $BASEDIR"
	exit 1
fi

#
# Select the correct rem_drv options to execute.
# Only attempt to unload the driver on a running system.
#
if [ "${BASEDIR}" = "/" ]; then
        REM_DRV="/usr/sbin/rem_drv"
else
        REM_DRV="/usr/sbin/rem_drv -b ${BASEDIR}"
fi

echo "removing old drivers"
${REM_DRV} oti1k >/dev/null 2>&1
${REM_DRV} o1k >/dev/null 2>&1

#
# remove old /devices and /dev entries
#
echo "Looking for and Removing old device entries"
find ${BASEDIR}/devices -name "pci1061*oti*" -print -exec rm -rf {} \;
rm -f ${BASEDIR}/dev/oti* >/dev/null 2>&1
find ${BASEDIR}/devices -name "pci1061*o1k*" -print -exec rm -rf {} \;
rm -f ${BASEDIR}/dev/o1k* >/dev/null 2>&1

