#!/bin/sh

# $Header: /mit/linux/share/bin/RCS/linux-install-floppy,v 1.4 2002/07/30 19:09:13 tibbetts Exp $

SIPBIMAGEDIR=/mit/linux/rh-6.2
SIPBIMAGE=$IMAGEDIR/bootnet.img

attach -q bootkit
ISIMAGE=/mit/bootkit/rhlinux/athena.img

case $ATHENA_SYS in
  sgi*)    FLOPPY=/dev/rdsk/fds0d2.3.5 ;;
  sun*)    volcheck ; FLOPPY=/vol/dev/aliases/floppy0 ;;
  *linux*) FLOPPY=/dev/fd0 ;;
  *nbsd*)  FLOPPY=/dev/fd0a ;;
  *)       echo "This is an unsupported system. Please use a" >&2;
	   echo "Sun, SGI, Linux or NetBSD Athena machine." >&2;
	   exit ;;
esac

# bsd or sysv style echo
TESTECHO=`echo -n`
case "$TESTECHO" in
   -n) N=''; C='\c';;
   *)  N='-n'; C='';;
esac


echo "Welcome to the SIPB linux installer..."
echo "The SIPB linux installer is no longer supported."
echo "You probably want the IS installer. If you want the SIPB installer,"
echo "please enter \`\`I know what I'm doing is wrong.''. Otherwise, just hit enter."

read iknow

if [ "$iknow" = "I know what I'm doing is wrong." ]; then
    IMAGE=$SIPBIMAGE;

    echo ""
    echo "Welcome to the SIPB installer. I hope you know what you are doing."
    echo ""
    echo "Please print out a copy of the one-sheet guide to installing"
    echo "from /mit/sipb/doc/rh-net-install.ps"
    echo ""
    echo "Most PC laptops require PCMCIA support in order to use their"
    echo "network connection.  Is this the case for your machine?"
    echo $N "(If you have a desktop, the answer is probably no.) [y/n] $C"

    read pcmcia
    if [ "$pcmcia" = "y" ]; then
	IMAGE=$IMAGEDIR/pcmcia.img
    fi

    echo ""
else
    echo ""
    echo "Welcome to the IS installer. This should work on most hardware,"
    echo "except where it doesn't. IS doens't really support this, so if you"
    echo "have questions, you are probably best of mailing linux-help@mit.edu"
    echo ""
    echo "You probably want to read the instructions at"
    echo "/mit/bootkit/rhlinux/INSTRUCTIONS"
    echo ""
    IMAGE=$ISIMAGE
fi

dd if=$IMAGE of=$FLOPPY bs=18k conv=sync

if [ $? -eq 0 ]; then
  echo "Floppy written successfully.";
else
  cat >&2 <<EOF
Write failed. Make sure that your floppy disk is in the drive,
and that the disk is not write protected. If this continues to
fail, try another workstation or another floppy. If neither of
those solutions work, then try coming to the SIPB office, w20-557.
EOF
fi
