home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 49 / PCPP49b.iso / freebies / BeOS5-PersonalEdition / data1.cab / Data_Files / image.be / beos / bin / makebootfloppy < prev    next >
Encoding:
Text File  |  2000-03-24  |  2.4 KB  |  108 lines

  1. #!/bin/sh
  2.  
  3. syntax() {
  4.     echo "Syntax: makebootfloppy [-cd] [-base directory] [-preserve]"
  5.     echo "-cd       : Creates a boot floppy capable of booting to a CD."
  6.     echo "            If not specified, the boot floppy will only be able to boot"
  7.     echo "            systems from hard drives."
  8.     echo "-base     : Specifies the base directory of the system you wish to make"
  9.     echo "            a boot floppy from. Defaults to /boot"
  10.     echo "-preserve : Leaves a copy of the floppy image in /tmp (only valid when"
  11.     echo "            used with the -cd option)."
  12.     exit 1
  13. }
  14.  
  15. BASE=/boot
  16. CD=0
  17. PRESERVE=0
  18. IMAGE=/dev/disk/floppy/raw
  19.  
  20. while [ "x$1" != "x" ] ; do
  21.     if [ "$1" = "-help" ] ; then
  22.         syntax
  23.     elif [ "$1" = "-cd" ] ; then
  24.         CD=1
  25.     elif [ "$1" = "-preserve" ] ; then
  26.         PRESERVE=1
  27.     elif [ "$1" = "-image" ] ; then
  28.         shift
  29.         IMAGE=$1
  30.         CD=1
  31.         if [ "x$1" = "x" ] ; then
  32.             echo "-image requires an argument."
  33.             syntax
  34.         fi
  35.     elif [ "$1" = "-base" ] ; then
  36.         shift
  37.         BASE=$1
  38.         if [ "x$1" = "x" ] || [ ! -d $BASE ] ; then
  39.             echo "-base requires a directory argument."
  40.             syntax
  41.         fi
  42.     else
  43.         echo "Invalid option: $1"
  44.         syntax
  45.     fi
  46.     shift
  47. done
  48.  
  49. if [ $CD = 1 ] ; then
  50.     rm -f /tmp/boot.tgz /tmp/boot.img
  51.  
  52.     echo Creating boot image...
  53.  
  54.     cd $BASE
  55.     tar chfz /tmp/boot.tgz \
  56.         beos/system/kernel_intel \
  57.         beos/system/kernel_intel.patch \
  58.         beos/system/add-ons/kernel/file_systems/bfs \
  59.         beos/system/add-ons/kernel/drivers/dev/disk \
  60.         beos/system/add-ons/kernel/bus_managers/{ide,scsi} \
  61.         beos/system/add-ons/kernel/busses/{ide,scsi} \
  62.         > /dev/null
  63.     cd -
  64.     if [ $? != 0 ] ; then
  65.         echo Error creating boot floppy
  66.         exit 1
  67.     fi
  68.  
  69.     dd if=/dev/zero of=/tmp/boot.img bs=1k count=1440
  70.     if [ $? != 0 ] ; then
  71.         echo Error creating boot floppy
  72.         exit 1
  73.     fi
  74.     dd if=$BASE/beos/system/zbeos of=/tmp/boot.img conv=notrunc
  75.     dd if=/tmp/boot.tgz of=/tmp/boot.img bs=128k seek=1 conv=notrunc
  76.  
  77.     echo Writing boot image to floppy...
  78.     dd if=/tmp/boot.img of=$IMAGE bs=72k
  79.     _retval=$?
  80.  
  81.     if [ $PRESERVE = 0 ] ; then
  82.         rm -f /tmp/boot.tgz /tmp/boot.img
  83.     fi
  84.  
  85.     if [ $_retval != 0 ] ; then
  86.         echo Error creating boot floppy
  87.         exit 1
  88.     fi
  89. else
  90.     echo Writing boot loader...
  91.     dd if=$BASE/beos/system/zbeos of=/dev/disk/floppy/raw bs=18k
  92.     if [ $? != 0 ] ; then
  93.         echo Error creating boot floppy
  94.         exit 1
  95.     fi
  96.  
  97.     echo Erasing old boot drivers from the floppy...
  98.     dd if=/dev/zero of=/dev/disk/floppy/raw bs=512 conv=notrunc seek=256 count=1
  99.     if [ $? != 0 ] ; then
  100.         echo Error creating boot floppy
  101.         exit 1
  102.     fi
  103. fi
  104.  
  105. echo Done!
  106.  
  107. exit 0
  108.