#!/bin/sh
#
#       This script checks for the revision of the patch 
#       installed and takes the necessary action.
#       Updated script so it works with more than one
#       rev of this patch installed on the system.

PATID=109885
NOUNDO_GLM=06      # rev when this postbackout was introduced
rmv_glm=1

PKG_INSTALL_ROOT=$ROOTDIR

INFO="$PKG_INSTALL_ROOT/var/sadm/pkg/SUNWcsr/pkginfo"
pids=`egrep '^PATCHLIST' $INFO | nawk -F= '{print $2}'`  #Find highest rev 
						

# Cleanup function.

remove_entries()
{
        sed -e '/^glm "pci1000,20"$/d' \
            -e '/^glm "pci1000,21"*$/d'
}

undo_glm() {

# This script cleans up /etc/driver_alias. 
#

remove_entries < $PKG_INSTALL_ROOT/etc/driver_aliases > /tmp/drv.$$.tmp
cp /tmp/drv.$$.tmp $PKG_INSTALL_ROOT/etc/driver_aliases
rm -f /tmp/drv.$$.tmp


}

# Go through list of patches and find highest rev of this
# patch on the system after this patch has been removed.
# If patch rev is 06 or higher, do not do cleanup. 

for i in `echo $pids`; do
        echo $i | egrep -s $PATID || continue
        rev=`expr //$i : '.*-\(.*\)'`
        #No undo edits for rev-06 or higher
        [ $rev -ge $NOUNDO_GLM ] && exit
done

[ $rmv_glm ] && undo_glm

exit 0
 

