#! /sbin/sh
#
# Granada Microcare Helpdesk
#
# mkkernel... A shell script for creating a bootable 
# kernel on a floppy

cat << INTRO
                       -- mkkernel --

 > This script creates a bootable kernel disk. Insert floppy disc 
 > and press Return when ready...................
 >
 >   ( Type any character key/s followed by Return to abort )

INTRO

read STRING
echo
if [ ${STRING}X != "X" ]
then
     echo; echo $0 aborted; echo
     exit 1
fi

# Only Return has been pressed so go ahead and make the kernel disk

echo; echo " > Formatting floppy....." ; echo
ffd 
# Check for errors during format.....
if [ $? -gt 1  ]
then
     echo; echo " > Error formatting floppy"; echo;
     exit 1
fi
echo
newfs /dev/fdf1024 fdf1024
# Check for errors during newfs.....
if [ $? -gt 0  ]
then
     echo; echo " > Error in newfs"; echo;
     exit 1
fi
echo; echo " > Making space....." ;echo
tunefs -o space -A -m 0 /dev/fdf1024

mount /dev/fdf1024 /mnt 

# Check for errors during mount.....
if [ $? -gt 0  ] 
then 
	echo; echo " > Error mounting floppy"; echo; exit 1 
fi

#And install the kernel

echo; echo " > Copying the kernel ( vmunix ) to the floppy....."
( cd /tmp ; tar cf - vmunix ) | ( cd /mnt ; tar xf - )

echo; echo " > Copying some files......" 
( cd /sbin ; tar cf - uncompress dsplit ls ) | ( cd /mnt ; tar xf - )
( cd /etc ; tar cf - group hosts passwd  ) | ( cd /mnt ; tar xf - )
( cd / ; tar cf - .profile  ) | ( cd /mnt ; tar xf - )


umount /mnt

cat << FINISHED

 > Kernel disk successfully created. Note that in future this
 > disk will be referred to as the 'Kernel disk' and you may 
 > wish to label it accordingly........

FINISHED

#    ================ END OF SCRIPT =====================
