home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / distrib / BOOT / BOOTIMG_ARC / bootdisk / sbin / setup < prev    next >
Encoding:
Text File  |  1996-02-25  |  10.8 KB  |  414 lines

  1. #!/bin/sh
  2. # ARM Linux installation script (c) 1996 R.M.King
  3. #
  4. # This is my first attempt at shell programming.  There are
  5. # bits that are Slackware-alike, and hence this is covered by
  6. # the GNU GPL. (Origional copyright follows:)
  7. #
  8. # Copyright 1993, 1994 Patrick Volkerding, Moorhead, Minnesota USA
  9. # All rights reserved.
  10. #
  11. # Redistribution and use of this script, with or without modification, is
  12. # permitted provided that the following conditions are met:
  13. #
  14. # 1. Redistributions of this script must retain the above copyright
  15. #    notice, this list of conditions and the following disclaimer.
  16. #
  17. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  18. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  20. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  21. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  25. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #
  28. TEST=
  29. TESTTAR=
  30. TARFLAGS=zxpf
  31. PATH=/bin:/sbin
  32. export TEST TESTTAR TARFLAGS PATH TARGET SRC
  33. yesno()
  34. {
  35.   while [ 0 ]; do
  36.     echo -n $1 "([y]es, [n]o) "
  37.     read YN
  38.     if [ "$YN" = "y" -o "$YN" = "n" ]; then
  39.       break;
  40.     fi
  41.   done
  42.   if [ "$YN" = "y" ]; then
  43.     return 0
  44.   else
  45.     return 1
  46.   fi
  47. }
  48. rm -f /fstab
  49. echo
  50. echo "arm Linux setup."
  51. echo "================"
  52. echo
  53. echo -n "Checking where to install to: "
  54. TARGET_MOUNTED="n"
  55. # Check the install location
  56. if [ -d /usr/man ]; then
  57.   TARGET=/
  58.   SOURCE=/var/adm/mount
  59. else
  60.   TARGET=/mnt
  61.   SOURCE=/floppy
  62. fi
  63. echo $TARGET
  64. echo "Source will be mounted under: $SOURCE"
  65. # Ensure that the source directory is not mounted and exists
  66. if mount | fgrep $SOURCE 1> /dev/null 2> /dev/null; then
  67.   umount $SOURCE
  68. fi
  69. if [ ! -d $SOURCE ]; then
  70.   mkdir $SOURCE
  71. fi
  72.  
  73. if [ $TARGET = "/" ]; then
  74.   echo
  75.   echo "Are you installing linux from scratch, or adding software to an existing"
  76.   echo "system?"
  77.   echo
  78.   while [ 0 ]; do
  79.     echo -n "[i]nstall from scratch or [a]dd? "
  80.     read ADDSOFT
  81.     if [ "$ADDSOFT" = "a" -o "$ADDSOFT" = "i" ]; then
  82.       break;
  83.     fi
  84.   done
  85. else
  86.   ADDSOFT=i
  87.   cat << EOF >> /fstab
  88. # /etc/fstab
  89. # static file system information, see fstab(5)
  90. #
  91. # This file is not used by the kernel, but rather by mount(8), umount(8),
  92. # swapon(8) and swapoff(8).  (Some day fsck(8) will also use this file).
  93. #
  94. # Since entries in this file are processed sequentially, file systems must
  95. # appear after the file systems they are mounted on (/usr before /usr/spool).
  96. #
  97. # device                directory               type    options                 freq pass
  98.  
  99. EOF
  100.   echo
  101.   echo "Which device are you using for your swap partition?"
  102.   echo "(eg. /dev/hda4 /dev/hdb4 /dev/sda4)"
  103.   echo
  104.   while [ 0 ]; do
  105.     echo -n "Please enter the device for your swap partition? "
  106.     read SWAP
  107.     [ -n $SWAP ] || continue;
  108.     if [ -b $SWAP ]; then
  109.       if [ "$SWAP" = "/dev/hda" -o "$SWAP" = "/dev/hdb" -o "$SWAP" = "/dev/sda" ]; then
  110.         echo "You cannot use the whole drive for a partition"
  111.       else
  112.         break;
  113.       fi
  114.     fi
  115.   done
  116.   echo
  117.   echo "If the $SWAP partition is not formatted, you should do this now."
  118.   echo
  119.   if yesno "Do you want to format the $SWAP partition?"; then
  120.     echo "Formatting your swap partition..."
  121.     set -e
  122.     mkswap $SWAP
  123.     echo "Done.  I will now use $SWAP..."
  124.     swapon $SWAP
  125.     set +e
  126.   fi
  127.   echo "$SWAP        none            swap    sw" >> /fstab
  128.   echo
  129.   echo "Which device are you using for your root partition?"
  130.   echo "(eg. /dev/hda1 /dev/hdb1 /dev/sda1)"
  131.   echo
  132.   while [ 0 ]; do
  133.     echo -n "Please enter the device for your root partition? "
  134.     read ROOT
  135.     [ -n $ROOT ] || continue;
  136.     if [ -b $ROOT ]; then
  137.       if [ "$ROOT" = "/dev/hda" -o "$ROOT" = "/dev/hdb" -o "$ROOT" = "/dev/sda" ]; then
  138.         echo "You cannot use the whole drive for a partition"
  139.       else
  140.         break;
  141.       fi
  142.     fi
  143.   done
  144.   echo
  145.   echo "If the $ROOT partition is not formatted, you should do this now."
  146.   echo
  147.   if yesno "Do you want to format the $ROOT partition?"; then
  148.     cat << EOF
  149.  
  150. Ext2fs defaults to one inode per 4096 bytes of drive space.  If you're going to
  151. have many small files on your drive, you may need more inodes (one is used for
  152. each entry in a directory).  You can change the density to one inode per 2048
  153. bytes, or even per 1024 bytes.
  154.  
  155. EOF
  156.     echo "Enter '2048' or '1024', or just hit enter to accept the"
  157.     echo -n "default of 4096: "
  158.     read DENSITY
  159.     if [ ! "$DENSITY" = "2048" -a ! "$DENSITY" = "1024" ]; then
  160.       DENSITY=4096
  161.     fi
  162.     echo "Formatting $ROOT as type ext2 (Density 1 inode / $DENSITY bytes)..."
  163.     set -e
  164.     mke2fs -i $DENSITY $ROOT
  165.     set +e
  166.     echo "Done formatting $ROOT"
  167.   fi
  168.   echo "$ROOT        /            ext2    defaults        0    1" >> /fstab
  169.   echo "none        /proc            proc    defaults        0    0" >> /fstab
  170. fi
  171. cat << EOF
  172.  
  173. SOURCE MEDIA SELECTION
  174. ----------------------
  175.  
  176. You can install from the following devices:
  177.  
  178. 1 - a floppy drive
  179. 2 - a hard drive partition (IDE PCEmulator only)
  180.  
  181. Floppy disks must be a minix filesystem type.
  182. A hard drive partition can be either a linux, minix or msdos partition.
  183.  
  184. EOF
  185. while [ 0 ]; do
  186.   echo -n "From which source will you be installing Linux (1/2)? "
  187.   read SOURCE_TYPE
  188.   if [ "$SOURCE_TYPE" = "1" -o "$SOURCE_TYPE" = "2" ]; then
  189.     break;
  190.   fi
  191. done
  192. if [ "$SOURCE_TYPE" = "1" ]; then
  193.   CHANGEABLE=y
  194.   SOURCE_TYPE=minix
  195.   cat << EOF
  196.  
  197. INSTALLING FROM FLOPPY DISK
  198. ---------------------------
  199.  
  200. 1 - /dev/fd0H1440 (1.44M adfs::0)
  201. 2 - /dev/fd1H1440 (1.44M adfs::1)
  202. 3 - /dev/fd2H1440 (1.44M adfs::2)
  203. 4 - /dev/fd3H1440 (1.44M adfs::3)
  204.  
  205. EOF
  206.   while [ 0 ]; do
  207.     echo -n "Which drive would you like to install from (1/2/3/4)? "
  208.     read TMP
  209.     if [ "$TMP" = "1" ]; then
  210.       SOURCE_DEV="/dev/fd0H1440"
  211.       break;
  212.     elif [ "$TMP" = "2" ]; then
  213.       SOURCE_DEV="/dev/fd1H1440"
  214.       break;
  215.     elif [ "$TMP" = "3" ]; then
  216.       SOURCE_DEV="/dev/fd2H1440"
  217.       break;
  218.     elif [ "$TMP" = "4" ]; then
  219.       SOURCE_DEV="/dev/fd3H1440"
  220.       break;
  221.     fi
  222.   done
  223.   echo "What type of filesystem is $SOURCE_DEV? "
  224.   cat << EOF
  225.  
  226. 1 - Linux/ext2
  227. 2 - Linux/minix
  228. 3 - MSDOS
  229.  
  230. EOF
  231.   while [ 0 ]; do
  232.     echo -n "Please enter the partition type: "
  233.     read TMP
  234.     if [ "$TMP" = "1" ]; then
  235.       SOURCE_TYPE=ext2
  236.       break;
  237.     elif [ "$TMP" = "2" ]; then
  238.       SOURCE_TYPE=minix
  239.       break;
  240.     elif [ "$TMP" = "3" ]; then
  241.       SOURCE_TYPE=msdos
  242.       break;
  243.     fi
  244.   done
  245. elif [ "$SOURCE_TYPE" = "2" ]; then
  246.   CHANGEABLE=n
  247.   cat << EOF
  248.  
  249. INSTALLING FROM HARD DISK
  250. -------------------------
  251.  
  252. In order to install directly from hard disk, you must have a partition
  253. containing the distribution sources in separate subdirectories.  The
  254. partition must be either Linux/ext2, minix or msdos.
  255.  
  256. EOF
  257.   while [ 0 ]; do
  258.     echo -n "Please enter the device for the sources: "
  259.     read SOURCE_DEV
  260.     [ -n $SOURCE_DEV ] || continue;
  261.     if [ -b $SOURCE_DEV ]; then
  262.       if [ "$SOURCE_DEV" = "/dev/hda" -o "$SOURCE_DEV" = "/dev/hdb" ]; then
  263.         echo "You cannot give the whole drive as your distribution source location"
  264.         continue;
  265.       fi
  266.       if [ "$SOURCE_DEV" = "$SWAP" ]; then
  267.         echo "You cannot give your swap partition as your distribution source location"
  268.         continue;
  269.       fi
  270.       break;
  271.     fi
  272.   done
  273.   echo
  274.   echo "What type of partition is $SOURCE_DEV? "
  275.   cat << EOF
  276.  
  277. 1 - Linux/ext2
  278. 2 - Linux/minix
  279. 3 - MSDOS
  280.  
  281. EOF
  282.   while [ 0 ]; do
  283.     echo -n "Please enter the partition type: "
  284.     read TMP
  285.     if [ "$TMP" = "1" ]; then
  286.       SOURCE_TYPE=ext2
  287.       break;
  288.     elif [ "$TMP" = "2" ]; then
  289.       SOURCE_TYPE=minix
  290.       break;
  291.     elif [ "$TMP" = "3" ]; then
  292.       SOURCE_TYPE=msdos
  293.       break;
  294.     fi
  295.   done
  296.   echo
  297. #  echo "Where are the files stored in the partition (relative to the"
  298. #  echo "top of the partition)?"
  299. #  echo
  300.   SOURCE_LOC="."
  301. fi
  302. if [ "$CHANGEABLE" = "y" ]; then
  303.   echo
  304.   echo "Using $SOURCE_DEV for distribution sources"
  305. else
  306.   echo
  307.   echo "Using $SOURCE_LOC in $SOURCE_DEV type $SOURCE_TYPE for distribution sources"
  308.   set -e
  309.   mount $SOURCE_DEV $SOURCE -t $SOURCE_TYPE
  310.   set +e
  311. fi
  312. if [ -n "$ROOT" ]; then
  313.   echo
  314.   echo "Mounting root partition onto /mnt..."
  315.   set -e
  316.   mount $ROOT -t ext2 /mnt
  317.   set +e
  318.   TARGET_MOUNTED="y"
  319. fi
  320. cat << EOF
  321.  
  322. The arm Linux distribution is split up into several sets of disks.  Currently
  323. (1 Jan 1996) the list is:
  324.  
  325.     Name    Contains                    Size (MB) No. Disks
  326. -----------------------------------------------------------------------------------
  327. 1 - base:    base utilities                     9        3
  328. 2 - dev:    bison, flex, lisp, perl                        *
  329. 3 - gcc:    gcc, g++, header files, libraries                *
  330. 4 - net:    Inet tools (TCP/IP)                        *
  331. 5 - mail:    mail programs (elm, sendmail, deliver)                *
  332. 6 - news:    news programs (inn, trn)                    *
  333. 7 - x11:    X11                        30        *
  334.  
  335. (*) - disk set as yet unavailable.
  336.  
  337. EOF
  338. if [ "$ADDSOFT" = "i" ]; then
  339.   echo " *** I will install the base set anyway - please don't specify it! ***"
  340.   echo
  341.   DISKSETS="1"
  342. fi
  343. echo "Please enter a list of disk sets you want to install separated by spaces"
  344. echo -n "Which disk sets do you want to install? "
  345. read TMP
  346. DISKSETS="$DISKSETS $TMP"
  347. echo
  348. echo "Installing... Please wait..."
  349. echo
  350. for I in $DISKSETS; do
  351.   case $I in
  352.     1) SET="base"  ;;
  353.     2) SET="dev"   ;;
  354.     3) SET="gcc"   ;;
  355.     4) SET="net"   ;;
  356.     5) SET="mail"  ;;
  357.     6) SET="news"  ;;
  358.     7) SET="x11"   ;;
  359.     *) continue;
  360.   esac
  361. #  if [ `eval "echo `echo '$'$SET`"` != 1 ]; then
  362. #    eval "$SET=1"
  363.     echo "Installing disk set $SET"
  364.     DISK="0"
  365.     while [ 0 ]; do
  366.       DISK=`expr $DISK + 1`
  367.       if [ "$CHANGEABLE" = "y" ]; then
  368.         SRC=$SOURCE
  369.       else
  370.         SRC=$SOURCE/$SOURCE_LOC/$SET/$DISK
  371.       fi
  372.       while [ ! -f $SRC/d$SET.$DISK ]; do
  373.         umount $SOURCE 1> /dev/null 2> /dev/null
  374.         echo -n "  Please insert disk $DISK of set $SET in $SOURCE_DEV and press return"
  375.         read DUMMY
  376.         mount -r -t $SOURCE_TYPE $SOURCE_DEV $SOURCE
  377.       done
  378.       if [ -f $SRC/dinfo.gz ]; then
  379.         zcat $SRC/dinfo.gz
  380.       elif [ -f $SRC/dinfo ]; then
  381.         cat $SRC/dinfo
  382.       fi
  383.       if [ -f $SRC/dinst ]; then
  384.         sh $SRC/dinst
  385.       else
  386.         tar $TARFLAGS $SRC/$SET$DISK.tgz -C $TARGET
  387.       fi
  388.       if [ -f $SRC/dlast ]; then
  389.         break;
  390.       fi
  391.     done
  392. #  fi
  393. done
  394. if [ -f /fstab ]; then
  395.   mv /fstab $TARGET/etc
  396. fi
  397. umount $SOURCE 1> /dev/null 2> /dev/null
  398. if [ "$TARGET_MOUNTED" = "y" ]; then
  399.   umount $TARGET 1> /dev/null 2> /dev/null
  400. fi
  401. if [ "$ADDSOFT" = "i" ]; then
  402.   echo "arm Linux installation complete."
  403. else
  404.   echo "Additional software installation complete."
  405. fi
  406. cat << EOF
  407.  
  408. If you wish to add any more partitions that can be mounted, please
  409. insert them into your /etc/fstab file in the same format as those
  410. already present with a pass number greater than 1.
  411.  
  412. EOF
  413. exit 0;
  414.