#!/bin/sh
#
#       This script will remove the changes introduced by
#       the removable media project if your target system
#	no longer has the removable media project support
#	after backing out this patch rev.

PATID=108969
NUNDO_REV=01

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

rmv_rmmconf=1
undo_rmedia_rmmconf() {
sed \
"s@ident_udfs.so cdrom floppy rmdisk@ident_udfs.so cdrom floppy@" \
$PKG_INSTALL_ROOT/etc/rmmount.conf > /tmp/rmmconf_a.$$
cp /tmp/rmmconf_a.$$ $PKG_INSTALL_ROOT/etc/rmmount.conf
rm /tmp/rmmconf_a.$$

sed "s@rmdisk@rmscsi@" $PKG_INSTALL_ROOT/etc/rmmount.conf > \
        /tmp/rmmconf_b.$$
cp /tmp/rmmconf_b.$$ $PKG_INSTALL_ROOT/etc/rmmount.conf
rm /tmp/rmmconf_b.$$

sed -e '/^mount \* hsfs udfs ufs -o nosuid/d' \
	$PKG_INSTALL_ROOT/etc/rmmount.conf >  /tmp/rmmconf_c.$$
cp /tmp/rmmconf_c.$$ $PKG_INSTALL_ROOT/etc/rmmount.conf
rm /tmp/rmmconf_c.$$

}

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