#!/bin/sh
#
#       This script checks for the revision of the Kernel Update
#       installed and takes the necessary action to remove the 
#       pseudo device and symlink created.
#
#

PATID=108528
NOUNDO_PSEUDO=14      # rev when creation of pseudo device was introduced
rmv_pseudo=1

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

# Function to remove pseudo device and symlink.

undo_pseudo() {

	devnode=$PKG_INSTALL_ROOT/devices/pseudo/mm@0:allkmem
	if [ -c $devnode ]; then
        	rm -f $devnode

        	devlink=allkmem
        	( cd $PKG_INSTALL_ROOT/dev; rm -rf $devlink )
	fi

}

# 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 14 or higher, do not remove pseudo device
# and symlink.

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

[ $rmv_pseudo ] && undo_pseudo

exit 0
 

