PATH=/bin:/usr/bin:/etc ; export PATH 

clear
echo "This install script will extract the \"VIA Bus Master PCI IDE device driver\""
echo "from the \"Bus Master PCI IDE Device Drivers\" which is prepared"
echo "with the DOS format."
echo "Would you continue to this install script (y/n)?\c"
read i
[ "$i" = "n" -o "$i" = "N" ] && exit 0

[ -d /tmp/viaide ] || mkdir /tmp/viaide
cd /tmp/viaide
doscp -r a:/unix/viaide.tar .
doscp -r a:/unix/viaunix.dat /tmp/viaunix.dat 2>/dev/null

echo "
**** Remove the "VIA Bus Master PCI IDE Device Drivers" **** 
and insert a new blank 1.2 MB (5.25\") or 1.44 MB (3.5\") into floppy drive A. 
The floppy drive A is the first floppy drive on the SCO UNIX.\n"

while true
do
    echo "Type 1 : Use 1.2 MB (5.25\") floppy drive.
Type 2 : Use 1.44 MB (3.5\") floppy drive.
Type q : Exit the installation.
Please enter your choice: (1/2/q) \c" >&2

    read i

    [ "$i" = "q" -o "$i" = "Q" ] && exit 1
    if [ "$i" = "1" -o "$i" = "2" ] 
    then
	echo "\nDo you want to format the diskette? (y/n)\c" >&2

	read yn

	if [ "$yn" = "y" -o "$yn" = "Y" ]
	then 
		if [ "$i" = "1" ]
		then	
			format -f /dev/rfd096
		else 
			format -f /dev/rfd0135ds18
		fi
	fi
	if [ $? = "1" ] 
	then 
		echo "\nThe format of the diskette failed, try another one.\n"
		continue
	fi
    else
	echo "\nPlease type 1, 2 or q only.\n"
	continue
    fi

    if [ "$i" = "1" ]
    then	
        dd if=viaide.tar of=/dev/fd096 
    else 
        dd if=viaide.tar of=/dev/fd0135ds18 
    fi

    if [ $? != "0" ]
    then
	echo "\nDisk copy failed. Please type again.\n"
	continue
    fi

    echo ""
echo "The conversion is successfully from DOS format to SCO UNIX format.
Please follow the \"custom\" command to install the 
\"VIA Bus Master PCI IDE Device Driver\" to your SCO UNIX system."
    rm -f /tmp/install
    exit 0
done
