#!/bin/sh
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)postremove	1.1	09/07/13 SMI"
#

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

BASEDIR=${BASEDIR:-/}

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

EXIT=0

# Make sure rem_drv has not been previously executed
# before attempting to remove the driver
if grep "\<mpt_sas\>" $BASEDIR/etc/name_to_major > /dev/null 2>&1
then
	$REM_DRV mpt_sas || EXIT=1
fi
exit $EXIT
