#!/bin/ash.static

/bin/more upgrade-doc1.txt
echo "Type 'OK' (no quotes) and press ENTER to proceed,"
echo -n "or CTRL-C to cancel the upgrade: "
read ANSWER
if [ "$ANSWER" = "OK" ]; then
    modprobe isofs || modprobe iso9660
    modprobe loop || (echo "Cannot insmod loop driver.. fatal error.";exit 2)
    grep '/mnt/cdrom' /etc/mtab || (mount /mnt/cdrom || (/bin/more upgrade-cdwarn.txt; \
    echo -n "Type 'OK' to proceed anyway, CTRL-C to cancel: "; read ANSWER))
    XSERVER=`rpm -qa --qf '%{NAME}:%{GROUP}\n' | grep '\:X11' | grep -i 'server' | grep -v 'wrapper' | grep -v 'VGA16' | cut -d : -f 1`
    if [ "$XSERVER" = "" ]; then
	echo "No X server, don't need to upgrade one."
    else
	echo "X Server is $XSERVER"
	if [ -d /mnt/cdrom/TurboLinux/RPMS ]; then
	    echo "Upgrading X Server..."
	    rpm -Uvh --nodeps --force /mnt/cdrom/TurboLinux/RPMS/$XSERVER-*
	else
	    echo "You must manually download and install the $XSERVER"
	    echo "package from the TurboLinux 3.0 package tree."
	    echo -n "Press ENTER to continue, CTRL-C to abort: "
	    read ANSWER2
	fi;
    fi;

    echo "Upgrading turbopkg to 5.3.3-1TL..."
    rpm -Uvh --nodeps --force turbopkg-5.3.3-1TL.i386.rpm
    if [ -f /mnt/cdrom/TurboLinux/RPMS/bash-2.02.1-5TL.i386.rpm -a -f /mnt/cdrom/TurboLinux/RPMS/glibc-2.0.7-20TL.i386.rpm ]; then
	echo "Upgrading glibc, and bash before running turbopkg..."
	rpm -Uvh --nodeps --force /mnt/cdrom/TurboLinux/RPMS/glibc-2.0.7-20TL.i386.rpm
	rpm -Uvh --nodeps --force /mnt/cdrom/TurboLinux/RPMS/bash-2.02.1-5TL.i386.rpm
    else
	echo "Cannot find packages in /mnt/cdrom (probably okay)"
    fi;
    exec ./upgrade2.sh
else
    echo "Upgrade Cancelled."
fi;
