:
# msinstall - install XENIX COBOL, FORTRAN or Pascal
#
# Copyright (C) Microsoft Corporation, 1984
#
block=20

trap \
 'echo;echo;echo "msinstall: INTERRUPTED.";exit'\
 1 2 3 15

if [ $# -ne 1 -a $# -ne 3 ]
then
	echo "Usage: msinstall [-d drive] product"
	exit 1
fi
if [ $# -eq 1 ]
then
   name=$1
   drive=/dev/rfd048ds9
else
   name=$3
   if [ -b $2 -o -c $2 ]
   then
      drive=$2
   else
      drive=/dev/$2
   fi
   if [ ! -b $drive -a ! -c $drive ]
   then
      echo "Invalid drive '$drive'"
      exit 1
   fi
fi

products='basic cobol file fortran multiplan pascal project utilcob word'
productNames='Basic COBOL File FORTRAN Multiplan Pascal Project Utilcob Word .'

# lower case the product name
name=`echo $name | tr [A-Z] [a-z]`

# verify the product name and set uname to the correctly punctuated name
valid=no
set -- $productNames
for i in $products
do
   if [ x$name = x$i ]
   then
      valid=yes
      break
   fi
   shift
done
if [ $valid = no ]
then
   echo "'$name' is an invalid product"
   echo "valid products are: $productNames"
   exit 1
fi
uname=$1

product="Microsoft $uname"
directory=/tmp/$name


echo "\n\n\n\n\n\n\nThis program installs $product."
echo ""
echo "Please note that it updates a number of files which may be needed by"
echo "other users.  If there is anyone else using your system, we recommend"
echo "that you stop at this point and ask them to logout."
echo ""

a=null
while [ "$a" != "y" -a "$a" != "Y" ]
do
	echo "Are you ready to begin the installation [y or n]?  \c"
	read a rest
	if [ "$a" = "y" -o "$a" = "Y" ]
	then
		echo ""
	elif [ "$a" = "n" -o "$a" = "N" ]
	then
		echo "Please take steps to prepare your system, then type"
		echo "msinstall to resume installation."
		exit
	else
		echo "Please answer with y or n"
	fi
done

echo "The distribution diskettes are numbered consecutively starting at 1."
echo ""
echo "You will be prompted for each diskette.  When you see the prompt,"
echo "wait until the light in drive zero goes out, remove the diskette in"
echo "the drive, place the next diskette in the drive, close the drive door,"
echo "and type \"y\" to indicate that another diskette is ready."
echo "If you have no more diskettes, reply \"n\".  After you have replied,"
echo "press the ENTER key."
echo ""

mkdir $directory
cd $directory

more="yes"
Umodifier=First
while [ $more = "yes" ]
do
	if [ $Umodifier = "First" ]
	then
		echo "If the first diskette is still in the drive, just leave it in place;"
		echo "otherwise, please insert it."
	else
		echo "\nInsert the next diskette when the diskette drive light goes out."
	fi
	echo "$Umodifier disk [y or n]?  \c"
	read a rest
	if [ A$a = Ay -o A$a = AY ]
	then
		echo "\nExtracting files from diskette.....\n"
		tar xvfb $drive $block
		sync
		Umodifier=Next
	elif [ A$a = An -o A$a = AN ]
	then
		more="no"
	else
		echo "\nPlease answer with y or n.\n"
	fi
done
echo

if [ -f $name.perms ]
then
	echo "msinstall: setting file permissions."
	/etc/fixperm -S -dS -c $name.perms
	sync
fi

mv README ..
cd ..
/bin/rm -r $directory

echo "\nInstallation complete\n"

more README
