:
# $Id: dosremove.sh,v 1.2 2001/11/07 18:06:49 rlawrence Exp $ 
# SCCSID(@(#)dosremove.sh	1.42) Modified 22:12:26 7/12/99
#############################################################################
# Script to remove MSDOS files
#############################################################################
#
#	Copyright (c) 1990-1999 TreLOS, Inc.
#	All rights reserved.
#	This is an unpublished work containing CONFIDENTIAL INFORMATION
#	that is the property of TreLOS, Inc.
#	Any unauthorized use, duplication or disclosure is prohibited.
#
#############################################################################

# Get the VARMERGE and STATICMERGE settings.
. /etc/mrgssv.sh

# In non-enduser situations, INST_ROOT might be set in dosinstall,
# so use it if it exists.
VARM=${INST_ROOT}${VARMERGE}
DOS_ROOT=${VARM}/dosroot
DOSROOTDOS=${DOS_ROOT}/dos
DOSI_TMP=${DOS_ROOT}/dosi_tmp
IMAGEDIR=${VARM}/image/std
PATH=/bin:/usr/bin:/usr/local/bin:$PATH; export PATH
TRACE=${TRACE:-/dev/null}
NULL=${NULL:-/dev/null}
if [ "x$1" = "xfrom_dosinstall" ]
then
	From_dosinstall=yes
	shift
else
	From_dosinstall=no
fi
OPTION="$1"
[ -z "$OPTION" ] && OPTION=none

# Remove file linked into dosroot/ubin
if [ -f ${DOS_ROOT}/ubin/.ubin.list ]
then
	cd ${DOS_ROOT}/ubin
	rm -f `cat .ubin.list`
	rm -f .ubin.list
fi

if [ -d ${DOSROOTDOS} ]
then
	# Remove everything from DOSROOTDOS, but not the directory itself.
	# (Actually remove it and then recreate it)
	rm -rf     ${DOSROOTDOS}
	mkdir -p   ${DOSROOTDOS}
	chown  bin ${DOSROOTDOS}
	chgrp  bin ${DOSROOTDOS}
	chmod  775 ${DOSROOTDOS}
fi

if [ "$From_dosinstall" = "no" ]
then
	# Make sure dosinstall related temporary directories are deleted.
	rm -rf ${DOSI_TMP}
fi

rm -f ${VARM}/image/config.mki
rm -f $IMAGEDIR/mono/*.img $IMAGEDIR/mono/dblspace.ini
rm -f $IMAGEDIR/cga/*.img $IMAGEDIR/cga/dblspace.ini
rm -f $IMAGEDIR/ega/*.img $IMAGEDIR/ega/dblspace.ini $IMAGEDIR/ega/ega.rom
rm -f $IMAGEDIR/vga/*.img $IMAGEDIR/vga/dblspace.ini $IMAGEDIR/vga/vga.rom
rmdir $IMAGEDIR/mono >> $TRACE 2>&1
rmdir $IMAGEDIR/cga  >> $TRACE 2>&1
rmdir $IMAGEDIR/ega  >> $TRACE 2>&1
rmdir $IMAGEDIR/vga  >> $TRACE 2>&1
rmdir $IMAGEDIR      >> $TRACE 2>&1
rmdir ${VARM}/image >> $TRACE 2>&1
rm -f ${VARM}/dosneedspace

rm -f  ${DOS_ROOT}/mwindows/oemsetup.inf
rm -f  ${DOS_ROOT}/mwindows/vgadib.3g_
rm -f  ${DOS_ROOT}/mwindows/vgadibj.3g_
rm -f  ${DOS_ROOT}/msdos.sys  ${DOS_ROOT}/io.sys ${DOS_ROOT}/winboot.sys
rm -f  ${DOS_ROOT}/ibmdos.com ${DOS_ROOT}/ibmbio.com
rm -f  ${DOS_ROOT}/command.com ${DOS_ROOT}/country.sys
# Merge 3.x put command.com and country.sys in root, so we want to remove
# the files from there just in case they somehow got left there.
rm -f  /command.com /country.sys

[ "$OPTION" = "silent" ] && exit 0

# Only have one message in this script, right at the end, so
# only set up the lmf stuff for that one message here.
# (DM is the domain for messages for this script.)
# (The script "set_nls.sh" uses STATICMERGE to set MFILE.)

# STATICMERGE should always exist, but since we can test for it
# make sure it exists before using it.
if [ ! -d $STATICMERGE ]
then
	exit 0
fi
DM="LCC.MERGE.UNIX.DOSINSTALL"
. $STATICMERGE/set_nls.sh

lmfmsg $MFILE $DM.RM_DONE >>$NULL 2>&1
if [ $? -eq 0 ]
then
	lmfmsg $MFILE $DM.RM_DONE
else
	echo "DOS removal done."
fi
exit 0
