#!/bin/sh
#
#       This script removes (as necessary) the changes introduced by the
#       removable media project.
#

PATID=108969
NUNDO_REV=01

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

rmv_voldconf=1

undo_rmedia_voldconf() {
sed "s@rmdisk@rmscsi@g" $PKG_INSTALL_ROOT/etc/vold.conf > \
        /tmp/voldconf_a.$$
cp /tmp/voldconf_a.$$ $PKG_INSTALL_ROOT/etc/vold.conf
rm /tmp/voldconf_a.$$

sed "s@^ use rmscsi@# use rmscsi@" $PKG_INSTALL_ROOT/etc/vold.conf > \
        /tmp/voldconf_b.$$
cp /tmp/voldconf_b.$$ $PKG_INSTALL_ROOT/etc/vold.conf
rm /tmp/voldconf_b.$$

sed -e '/^remount/d' $PKG_INSTALL_ROOT/etc/vold.conf > \
        /tmp/mip.$$
cp /tmp/mip.$$ $PKG_INSTALL_ROOT/etc/vold.conf
rm /tmp/mip.$$
}

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_voldconf ] && undo_rmedia_voldconf
exit 0
