#!/bin/sh

#  If an old version of the 3132 driver is loaded,
#  then remove it from the system.
#  The old version may be named Si3132r5 or SiliconImage3132r5

a=`sudo kextstat | grep Si3132r5.kext`
if [ "$a" != "" ] ; then
    sudo kextunload Si3132r5.kext
fi

a=`sudo kextstat | grep SiliconImage3132r5.kext`
if [ "$a" != "" ] ; then
    sudo kextunload SiliconImage3132r5.kext
fi

#  If an older version of the driver using the old name (si3132r5) 
#  is present in the extensions directory, remove it before installing 
#  the new version.

if [ -d /System/Library/Extensions/Si3132r5.kext ] ; then
    sudo rm -rf /System/Library/Extensions/Si3132r5.kext
fi

#  If the Silicon Image base driver is installed in the extensions directory,
#  remove it so that there is no conflict between it and the SATARaid5 Driver.

b=`sudo kextstat | grep sii`
if [ "$b" != "" ] ; then
    sudo kextunload /System/Library/Extensions/SiliconImage3132.kext
fi

#  If the base driver is installed in the Extensions directory,
#  remove it so there's no conflict on the next startup.

if [ -d /System/Library/Extensions/SiliconImage3132.kext ] ; then
    sudo rm -rf /System/Library/Extensions/SiliconImage3132.kext
fi
