#!/bin/sh
# $Id: unloadwindowsCD.sh,v 1.2 2001/11/07 18:06:46 rlawrence Exp $ 
# SCCSID(@(#)unloadwindowsCD.sh	1.3) Modified 12:36:21 2/14/00
# 
# This script reverses what the "loadwindowsCD" command does.
# It removes the loaded Windows CAB files and removes the DOS
# files that were installed from them.
#
# Get the STATICMERGE, VARMERGE, and DOSWINBINDIR settings.
. /etc/mrgssv.sh

NULL=/dev/null

No_Permission()
{
	echo "You do not have permission to use this command."
	echo "Normally you must be logged in as root to use this command."
	exit 1
}

# Only root can do a "reload".  We test this by seeing if
# the critical related directories are writeable.
[ -d $VARMERGE/dosi      -a ! -w $VARMERGE/dosi ]      && No_Permission

# Removing Windows/DOS files previously copied in from the Windows CAB files
# and the related "dosinstall" files.
rm -f $VARMERGE/dosi/*ms7cd.set
rm -f $VARMERGE/dosi/*ms7cd.vdl
rm -f $VARMERGE/dosi/*ms7cd.dsk*
rm -f $VARMERGE/dosi/*ms7cd.cpio*
if [ ! -s $VARMERGE/dosi/default.set ]
then
	rm -f $VARMERGE/dosi/default.set
elif [ -f $VARMERGE/dosi/default.set ]
then
	grep -s ms7cd $VARMERGE/dosi/default.set > $NULL
	[ $? -eq 0 ] && rm -f $VARMERGE/dosi/default.set
fi

# Removing wincabs directory.
rm -rf $VARMERGE/dosroot/wincabs

# Remove the temporary files that loadwindowsCD might have created.
rm -f "$VARMERGE/bsboot.dsk
rm -f "$VARMERGE/bootflop.dsk $VARMERGE/bootflopA.dsk
CDIR="$VARMERGE/instC"
rm -f "$CDIR/a[0-9]*.bat"

exit 0
