#!/bin/sh

mount -n -o remount,rw /
mount /proc
cp /proc/mounts /etc/mtab

open -l /bin/sh

echo 'Probing for PCI and SBUS adapters in the system.'
echo ''
insmod openprom
[ -f /proc/pci ] && pciprobe
sbusprobe
[ -f /proc/pci ] && MODS=`pciprobe | sed -n -e '1,/^Probing for VIDEO/s/^.*-> |\(.*\)|/\1/p'`
MODS="$MODS `sbusprobe | sed -n -e '1,/^Probing for VIDEO/s/^.*-> |\(.*\)|/\1/p'`"
if echo $MODS | grep [a-z] > /dev/null 2>&1; then
    echo 'Autodetect has found it could be desirable to insmod these modules:'
    echo "$MODS"
    echo 'Please use insmod for these modules if you need to, and choose'
    echo 'your order of module loads.'
else
    echo 'Autodetect has not found any devices for which it would be desirable'
    echo 'to load their modules.'
fi

echo ''
echo 'This is the UltraPenguin network tftprescue set. Most of the basic system commands are'
echo 'in /bin.'
echo ''
echo 'Type exit to halt the system.'
echo ''

/bin/sh

echo "Unmounting filesystems..."
tac /proc/mounts | while read line ; do
    set $line
    if [ $2 != "/" ]; then
	umount $1
    fi
done
echo "Halting system.. All fixed? :-)"
