home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / Other / Coherent / documents / CohFAQ-v4-TechTips / mkboot.sh.Z / mkboot.sh
Encoding:
Text File  |  1995-09-01  |  5.5 KB  |  213 lines

  1. # shell script to create a bootable floppy disk
  2. # Written by Udo Munk (udo@umunk.GUN.de)
  3. # with help from Vladimir Smelyansky (vlad@mwc.com)
  4. # Modified for 4.2 by Robert Chalmers ( robert@cstpl.com.au )
  5.   clear
  6.   if [ $USER != root ]
  7.   then
  8.     echo "This program must be run as user root!"
  9.     exit
  10.   fi
  11.   echo "This programm creates a bootable floppy disk for COHERENT."
  12.   echo "Because booting the PC hardware only works with floppy drive A"
  13.   echo "I want to know the size of your A device first."
  14.   echo
  15.   while true
  16.   do
  17.     echo -n "Is your A device a 5.25 inch drive (answer y or n): "
  18.     read answer
  19.     if [ $answer = y -o $answer = n ]
  20.     then
  21.       break
  22.     else
  23.       echo "answer with y or n please!"
  24.       echo
  25.     fi
  26.   done
  27.   if [ $answer = y ]
  28.   then
  29.     echo "Fine, let us create a 5.25 inch bootable floppy disk."
  30.     dev=/dev/fha0
  31.     devsize="5.25"
  32.     devblocks=2400
  33.     boot=/conf/boot.fha
  34.   else
  35.     echo "Fine, let us create a 3.5 inch bootable floppy disk."
  36.     dev=/dev/fva0
  37.     devsize="3.5"
  38.     devblocks=2880
  39.     boot=/conf/boot.fva
  40.   fi
  41.   echo
  42.   echo "Now please put a" $devsize "floppy disk into your drive A".
  43.   echo "WARNING: ALL DATA ON THIS FLOPPY DISK WILL BE DESTROYED!"
  44.   echo
  45.   echo -n "Type y if you want to continue, any other to abort: "
  46.   read answer
  47.   if [ $answer != y ]
  48.   then
  49.     exit
  50.   fi
  51.   clear
  52.   echo "Step 1: formating floppy disk..."
  53.   if [ $dev = /dev/fha0 ]
  54.       then
  55.      /etc/fdformat -i 3 -o 0 $dev
  56.   else
  57.      /etc/fdformat -i 3 -o 6 $dev
  58.   fi
  59.   echo "Step 2: building the bad block list..."
  60.   /etc/badscan -o bootdisk $dev $devblocks
  61.   echo "Step 3: building a filesystem..."
  62.   /etc/mkfs $dev bootdisk
  63.   rm bootdisk
  64.   echo "Step 4: copy the bootstrap onto the floppy disk..."
  65.   cp $boot $dev
  66.   /etc/mount $dev /mnt
  67.   if [ -f /tboot ]
  68.   then
  69.     cp /tboot /mnt
  70.   fi
  71.   echo "Step 5: copy the kernel and patch it..."
  72.   cp /coherent /mnt
  73.   ln /mnt/coherent /mnt/autoboot
  74.   if [ -f /tboot ]        
  75.   # we are running Coherent 4.x
  76.   then
  77.     if [ $dev = /dev/fha0 ]    
  78.     # drive A is 5.25 inch
  79.     then
  80.       /conf/patch /mnt/coherent rootdev=makedev\(4,14\)
  81.       /conf/patch /mnt/coherent pipedev=makedev\(4,14\)
  82.     else                
  83.     # drive A is 3.5 inch
  84.       /conf/patch /mnt/coherent rootdev=makedev\(4,15\)
  85.       /conf/patch /mnt/coherent pipedev=makedev\(4,15\)
  86.     fi
  87.    fi
  88.   echo "Step 6: copy all neccesary files to the floppy disk..."
  89.   mkdir /mnt/mnt
  90.   mkdir /mnt/tmp
  91.   cpdir /dev /mnt/dev
  92.   mkdir /mnt/conf
  93.   mkdir /mnt/bin
  94.   #=================== put the keyboard of choice here ==========
  95.   # However, this new keyboard may not run as required. Check
  96.   # your configuration to ensure this. It seems to depend on where
  97.   # the loadable keyboard driver is loaded from? See Udo on this one.
  98.   cp /conf/kbd/german /mnt/conf/kbd
  99.   cp /bin/bad /mnt/bin
  100.   cp /bin/check /mnt/bin
  101.   cp /bin/chgrp /mnt/bin
  102.   cp /bin/chmod /mnt/bin
  103.   cp /bin/chown /mnt/bin
  104.   cp /bin/cp /mnt/bin
  105.   cp /bin/cpdir /mnt/bin
  106.   cp /bin/date /mnt/bin
  107.   cp /bin/df /mnt/bin
  108.   cp /bin/[ /mnt/bin
  109.   cp /bin/find /mnt/bin
  110.   cp /bin/grep /mnt/bin
  111.   cp /bin/ln /mnt/bin
  112.   cp /bin/ls /mnt/bin
  113.   cp /bin/lc /mnt/bin
  114.   cp /bin/mkdir /mnt/bin
  115.   cp /bin/mv /mnt/bin
  116.   cp /bin/ps /mnt/bin
  117.   cp /bin/pwd /mnt/bin
  118.   cp /bin/rm /mnt/bin
  119.   cp /bin/rmdir /mnt/bin
  120.   cp /bin/sh /mnt/bin
  121.   cp /bin/stty /mnt/bin
  122.   cp /bin/sync /mnt/bin
  123.   mkdir /mnt/usr
  124.   mkdir /mnt/usr/tmp
  125.   mkdir /mnt/usr/bin
  126.   cp /usr/bin/vi /mnt/usr/bin
  127.   cp /usr/bin/dpac /mnt/usr/bin
  128.   cp /usr/bin/more /mnt/usr/bin
  129.   if [ -d /usr/lib/terminfo ]
  130.   then
  131.     mkdir /mnt/usr/lib
  132.     mkdir /mnt/usr/lib/terminfo
  133.     mkdir /mnt/usr/lib/terminfo/a
  134.     cp /usr/lib/terminfo/a/ansipc /mnt/usr/lib/terminfo/a
  135.   fi
  136.   mkdir /mnt/etc
  137.   cp /etc/ATclock /mnt/etc
  138.   cp /etc/badscan /mnt/etc
  139.   cp /etc/clri /mnt/etc
  140.   if [ -f /etc/drvld ]
  141.   then
  142.     cp /etc/drvld /mnt/etc
  143.   fi
  144.   cp /etc/profile /mnt/etc
  145.   cp /etc/passwd /mnt/etc
  146.   cp /etc/shadow /mnt/etc
  147.   cp /etc/group /mnt/etc
  148.   cp /etc/domain /mnt/domain
  149.   cp /etc/drvld.all /mnt/etc
  150.   cp /etc/fdisk /mnt/etc
  151.   cp /etc/fsck /mnt/etc
  152.   cp /etc/init /mnt/etc
  153.   cp /etc/mkfs /mnt/etc
  154.   cp /etc/mount /mnt/etc
  155.   cp /etc/reboot /mnt/etc
  156.   cp /etc/umount /mnt/etc
  157.   cp /etc/serialno /mnt/etc
  158.   cp /etc/timezone /mnt/etc
  159.   cp /etc/termcap /mnt/etc
  160.   mkdir /mnt/etc/default
  161.   cp /etc/default/login /mnt/etc/default
  162.   echo "Step 7: create lost+found with enough empty directory slots..."
  163.   mkdir /mnt/lost+found
  164.   if [ $dev = /dev/fha0 ]    
  165.   then
  166.   for I in 0 1 2
  167.   do
  168.     for J in 0 1 2
  169.     do
  170.       touch /mnt/lost+found/$I$J
  171.     done
  172.   done
  173.   else
  174.   for I in 0 1 2 3 4 5 
  175.   do
  176.     for J in 0 1 2 3 4 5
  177.     do
  178.       touch /mnt/lost+found/$I$J
  179.     done
  180.   done
  181.  fi
  182.   rm /mnt/lost+found/*
  183. echo "Step 8: create some files, so that boot ends in single user mode..."
  184. cat > /mnt/etc/brc << TT_EOF
  185. . /etc/timezone
  186. /bin/date -s \`/etc/ATclock\` >/dev/null
  187. #this next bit should load keyboard tables?
  188. /etc/drvld.all
  189. exit 1
  190. TT_EOF
  191. #put a profile in here....
  192. cat > /mnt/etc/.profile << PF_EOF
  193. # /etc/profile 09/08/93
  194. # Executed at login for all users.
  195. umask 022
  196. export PAGER="exec /usr/bin/more -ls"
  197. export PATH=/bin:/usr/bin
  198. export TERM=ansipc
  199. export LOGNAME=$USER
  200. export HZ=100
  201. PF_EOF
  202. cat /etc/checklist >/mnt/etc/checklist
  203. cat /etc/mount.all >/mnt/etc/mount.all
  204. echo "Last step: check the filesystem of the created floppy disk:"
  205. sync
  206. echo "Just a moment..."
  207. sleep 5
  208. /etc/umount $dev
  209. /etc/fsck $dev
  210. echo "Fine, floppy disk ready, store it at a cool dry place but"
  211. echo "where you can remember in case of an emergency :-)"
  212. echo "========================================================="
  213.