home *** CD-ROM | disk | FTP | other *** search
/ Dream 46 / Amiga_Dream_46.iso / bo / boot / root.bin / root / sbin / swapsetup < prev    next >
Text File  |  1997-05-27  |  6KB  |  278 lines

  1. #!    /bin/ash
  2.  
  3. echo $0 started OK
  4.  
  5. #set -x 
  6.  
  7. readonly bold=''
  8. readonly clear='H'
  9. readonly norm=''
  10.  
  11. last ()
  12. {
  13.     eval echo $"$#"
  14. }
  15.  
  16. find_partitions ()
  17. {
  18.     local type="$1"
  19.     local line
  20.     while true; do
  21.         read line
  22.         if [ "$line" = "-EOF-" ]; then
  23.             return 0
  24.         fi
  25.         if [ "`last $line`" = "$type" ]; then
  26.             set -- $line
  27.             echo $1
  28.         fi
  29.     done
  30. }
  31.  
  32.  
  33. while true; do
  34.     echo "
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. "
  59.     echo $clear\
  60. "This system has relatively little memory. For a system like this, special 
  61. procedures are required, because there is not enough RAM available
  62. to run the graphical program without the virtual memory provided by the swap
  63. partition. Thus, you should:
  64.  
  65. 1. Run the disk partitioning program to add a \"Linux swap\" (type 82)
  66.    partition and the \"Linux native\" (type 83) partition. You have to create
  67.    an extra temporary root partition that has at least 1.2MB and type 81 
  68.     (\"Linux/MINIX\").
  69.    You will not be able to re-partition the drive while the
  70.    swap partition on it is active.
  71. 2. Then initialize the swap partition.
  72. 3. Then initialize the temporary root partition
  73. 4. Reboot.
  74.  
  75. Please select an action from the menu below:
  76.  
  77. 1. Run the disk partitioning program in order to create a swap partition."
  78.     if [ -n "$drive" ]; then
  79.         echo "2. Initialize and activate the swap partition."
  80.     fi
  81.     if [ -n "$swappartition" ]; then
  82.         echo "3. Initialize the temporary root partition."
  83.     fi
  84.     echo "4. Reboot."
  85.     echo ""
  86.  
  87.     read action
  88.  
  89.     case "$action" in 
  90.     1)
  91.         echo $clear
  92.  
  93.         if [ -n "$swappartition" ]; then
  94.             echo \
  95. "You already activated the swap partition $swappartition.
  96. It will be deactivated before running the partitioning program.
  97.  
  98. Type \"y\" to continue, type \"n\" to cancel: "
  99.             read line
  100.             case "$line" in 
  101.             y|Y)
  102.                 swapoff $swappartition
  103.                 swappartition=""
  104.                 ;;
  105.             *)
  106.                 break 2
  107.             esac
  108.         fi
  109.  
  110.         echo "Please wait while disk drives are detected..."
  111.         drives="`tryopen -w /dev/hd[a-z] /dev/sd[a-z]`"
  112.         echo $clear
  113.         if [ -z "$drives" ]; then
  114.             echo \
  115. "No hard disk drives could be found. Make sure they are cabled
  116. correctly and are turned on before the system is started. You
  117. may have to change driver settings when you start the system
  118. with a command at the \"boot:\" prompt, or you may have to load
  119. a driver that is in a loadable module to solve this problem."
  120.             read foo
  121.         else
  122.             echo \
  123. "The following drives are available. Drives that are named /dev/hdX
  124. are IDE, ATA, MFM, or RLL drives. Drives that are named /dev/sdX are
  125. SCSI drives."
  126.             for d in $drives; do
  127.                 echo "    "$d
  128.             done
  129.             echo -n "
  130. Please type a drive name from the above list: "
  131.             read drive
  132. # Note the -i flag to cfdisk is undocumented and liable to change.
  133.             if [ -n "$drive" ]; then
  134.                 if [ -x /sbin/cfdisk ]; then
  135.                     cfdisk -i $drive
  136.                 else
  137.                     fdisk $drive
  138.                 fi
  139.             fi
  140.         fi
  141.         ;;
  142.     2)
  143.         echo -n $clear
  144.         echo "Please wait while swap partitions are detected..."
  145.         fdisk -l > /tmp/$$ 2>/dev/null
  146.         echo "-EOF-" >>/tmp/$$
  147.         partitions="`find_partitions swap < /tmp/$$`"
  148.         rm -f /tmp/$$
  149.         echo -n $clear
  150.         if [ -z "$partitions" ]; then
  151.             echo "
  152. No swap partitions are available. You must select menu item 1 and create
  153. one.
  154.  
  155. Please press enter when you are ready to continue."
  156.             read line
  157.         else
  158.             echo "These swap partitions are available: "
  159.             for p in $partitions; do
  160.                 echo "    "$p
  161.             done
  162.             echo -n "
  163. Please type a partition name from the above list to use: "
  164.             read swappartition
  165.             if [ -z "$swappartition" ]; then
  166.                 continue
  167.             fi
  168.             echo -n "
  169. This will permanently destroy all data on $swappartition. Type \"y\" to continue,
  170. type \"n\" to cancel: "
  171.             read line
  172.             case "$line" in 
  173.             y|Y)
  174.                 echo
  175.                 echo "Creating swap signature ..."
  176.                 mkswap $swappartition
  177.                 echo "        done."
  178.                 if [ $? -ne 0 ]; then
  179.                     "Error creating swap signature"
  180.                     read foo
  181.                     break 2
  182.                 fi
  183.                 echo "Enable swap signature ..."
  184.                 swapon $swappartition
  185.                 echo "        done."
  186.                 if [ $? -ne 0 ]; then
  187.                     "Error enabling swap signature"
  188.                     read foo
  189.                     break 2
  190.                 fi
  191.                 
  192.                 echo "
  193. The swap partition $swappartition has been initialized successfully.
  194.  
  195. Please press enter when you are ready to continue."
  196.                 read line
  197.                 ;;
  198.             esac
  199.         fi
  200.         ;;
  201.     3)
  202.         echo -n $clear
  203.         echo
  204.         echo "Please wait while minix partitions are detected..."
  205.         fdisk -l > /tmp/$$ 2>/dev/null
  206.         echo "-EOF-" >>/tmp/$$
  207.         partitions="`find_partitions Linux/MINIX < /tmp/$$`"
  208.         rm -f /tmp/$$
  209.         echo -n $clear
  210.         if [ -z "$partitions" ]; then
  211.             echo "
  212. No minix partitions are available. You must select menu item 1 and create
  213. one.
  214.  
  215. Please press enter when you are ready to continue."
  216.             read line
  217.         else
  218.             echo "These minix partitions are available: "
  219.             for p in $partitions; do
  220.                 echo "    "$p
  221.             done
  222.             echo -n "
  223. Please type a partition name from the above list to use: "
  224.             read partition
  225.             if [ -z "$partition" ]; then
  226.                 continue
  227.             fi
  228.             echo -n "
  229. This will permanently destroy all data on $partition. Type \"y\" to continue,
  230. type \"n\" to cancel: "
  231.             read line
  232.             case "$line" in 
  233.             y|Y)
  234.                 echo
  235.                 echo "Copying root filesystem from floppy to $partition ..."
  236.                 cat /dev/fd0 >$partition
  237.                 echo "        done."
  238.                 if [ $? -ne 0 ]; then
  239.                     "Error copying root filesystem"
  240.                     read foo
  241.                 fi
  242.                 mount -t minix $partition /mnt
  243.                 rm /mnt/sbin/swapsetup
  244.                 echo $swappartition >/mnt/etc/swappartition
  245.                 umount /mnt
  246.                 echo "
  247. Please press enter when you are ready to continue."
  248.                 read line
  249.                 ;;
  250.             esac
  251.         fi
  252.         ;;
  253.     4)
  254.         echo "The system will reboot now.
  255.  
  256. When the system is shut down, insert the rescue disk and boot.
  257.  
  258. When the boot: prompt appears, type
  259. $bold        lowmemboot root=$partition$norm
  260.  
  261.  
  262. Please press enter to continue.
  263. "
  264.         read line
  265.                 
  266.         echo
  267.         echo "Rebooting ..."
  268.         reboot
  269.         while read foo; do
  270.             true
  271.         done
  272.         ;;
  273.     sh)
  274.         sh
  275.         ;;
  276.     esac
  277. done
  278.