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