home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # ARM Linux installation script (c) 1996 R.M.King
- #
- # This is my first attempt at shell programming. There are
- # bits that are Slackware-alike, and hence this is covered by
- # the GNU GPL. (Origional copyright follows:)
- #
- # Copyright 1993, 1994 Patrick Volkerding, Moorhead, Minnesota USA
- # All rights reserved.
- #
- # Redistribution and use of this script, with or without modification, is
- # permitted provided that the following conditions are met:
- #
- # 1. Redistributions of this script must retain the above copyright
- # notice, this list of conditions and the following disclaimer.
- #
- # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- #
- TEST=
- TESTTAR=
- TARFLAGS=zxpf
- PATH=/bin:/sbin
- export TEST TESTTAR TARFLAGS PATH TARGET SRC
- yesno()
- {
- while [ 0 ]; do
- echo -n $1 "([y]es, [n]o) "
- read YN
- if [ "$YN" = "y" -o "$YN" = "n" ]; then
- break;
- fi
- done
- if [ "$YN" = "y" ]; then
- return 0
- else
- return 1
- fi
- }
- rm -f /fstab
- echo
- echo "arm Linux setup."
- echo "================"
- echo
- echo -n "Checking where to install to: "
- TARGET_MOUNTED="n"
- # Check the install location
- if [ -d /usr/man ]; then
- TARGET=/
- SOURCE=/var/adm/mount
- else
- TARGET=/mnt
- SOURCE=/floppy
- fi
- echo $TARGET
- echo "Source will be mounted under: $SOURCE"
- # Ensure that the source directory is not mounted and exists
- if mount | fgrep $SOURCE 1> /dev/null 2> /dev/null; then
- umount $SOURCE
- fi
- if [ ! -d $SOURCE ]; then
- mkdir $SOURCE
- fi
-
- if [ $TARGET = "/" ]; then
- echo
- echo "Are you installing linux from scratch, or adding software to an existing"
- echo "system?"
- echo
- while [ 0 ]; do
- echo -n "[i]nstall from scratch or [a]dd? "
- read ADDSOFT
- if [ "$ADDSOFT" = "a" -o "$ADDSOFT" = "i" ]; then
- break;
- fi
- done
- else
- ADDSOFT=i
- cat << EOF >> /fstab
- # /etc/fstab
- # static file system information, see fstab(5)
- #
- # This file is not used by the kernel, but rather by mount(8), umount(8),
- # swapon(8) and swapoff(8). (Some day fsck(8) will also use this file).
- #
- # Since entries in this file are processed sequentially, file systems must
- # appear after the file systems they are mounted on (/usr before /usr/spool).
- #
- # device directory type options freq pass
-
- EOF
- echo
- echo "Which device are you using for your swap partition?"
- echo "(eg. /dev/hda4 /dev/hdb4 /dev/sda4)"
- echo
- while [ 0 ]; do
- echo -n "Please enter the device for your swap partition? "
- read SWAP
- [ -n $SWAP ] || continue;
- if [ -b $SWAP ]; then
- if [ "$SWAP" = "/dev/hda" -o "$SWAP" = "/dev/hdb" -o "$SWAP" = "/dev/sda" ]; then
- echo "You cannot use the whole drive for a partition"
- else
- break;
- fi
- fi
- done
- echo
- echo "If the $SWAP partition is not formatted, you should do this now."
- echo
- if yesno "Do you want to format the $SWAP partition?"; then
- echo "Formatting your swap partition..."
- set -e
- mkswap $SWAP
- echo "Done. I will now use $SWAP..."
- swapon $SWAP
- set +e
- fi
- echo "$SWAP none swap sw" >> /fstab
- echo
- echo "Which device are you using for your root partition?"
- echo "(eg. /dev/hda1 /dev/hdb1 /dev/sda1)"
- echo
- while [ 0 ]; do
- echo -n "Please enter the device for your root partition? "
- read ROOT
- [ -n $ROOT ] || continue;
- if [ -b $ROOT ]; then
- if [ "$ROOT" = "/dev/hda" -o "$ROOT" = "/dev/hdb" -o "$ROOT" = "/dev/sda" ]; then
- echo "You cannot use the whole drive for a partition"
- else
- break;
- fi
- fi
- done
- echo
- echo "If the $ROOT partition is not formatted, you should do this now."
- echo
- if yesno "Do you want to format the $ROOT partition?"; then
- cat << EOF
-
- Ext2fs defaults to one inode per 4096 bytes of drive space. If you're going to
- have many small files on your drive, you may need more inodes (one is used for
- each entry in a directory). You can change the density to one inode per 2048
- bytes, or even per 1024 bytes.
-
- EOF
- echo "Enter '2048' or '1024', or just hit enter to accept the"
- echo -n "default of 4096: "
- read DENSITY
- if [ ! "$DENSITY" = "2048" -a ! "$DENSITY" = "1024" ]; then
- DENSITY=4096
- fi
- echo "Formatting $ROOT as type ext2 (Density 1 inode / $DENSITY bytes)..."
- set -e
- mke2fs -i $DENSITY $ROOT
- set +e
- echo "Done formatting $ROOT"
- fi
- echo "$ROOT / ext2 defaults 0 1" >> /fstab
- echo "none /proc proc defaults 0 0" >> /fstab
- fi
- cat << EOF
-
- SOURCE MEDIA SELECTION
- ----------------------
-
- You can install from the following devices:
-
- 1 - a floppy drive
- 2 - a hard drive partition (IDE PCEmulator only)
-
- Floppy disks must be a minix filesystem type.
- A hard drive partition can be either a linux, minix or msdos partition.
-
- EOF
- while [ 0 ]; do
- echo -n "From which source will you be installing Linux (1/2)? "
- read SOURCE_TYPE
- if [ "$SOURCE_TYPE" = "1" -o "$SOURCE_TYPE" = "2" ]; then
- break;
- fi
- done
- if [ "$SOURCE_TYPE" = "1" ]; then
- CHANGEABLE=y
- SOURCE_TYPE=minix
- cat << EOF
-
- INSTALLING FROM FLOPPY DISK
- ---------------------------
-
- 1 - /dev/fd0H1440 (1.44M adfs::0)
- 2 - /dev/fd1H1440 (1.44M adfs::1)
- 3 - /dev/fd2H1440 (1.44M adfs::2)
- 4 - /dev/fd3H1440 (1.44M adfs::3)
-
- EOF
- while [ 0 ]; do
- echo -n "Which drive would you like to install from (1/2/3/4)? "
- read TMP
- if [ "$TMP" = "1" ]; then
- SOURCE_DEV="/dev/fd0H1440"
- break;
- elif [ "$TMP" = "2" ]; then
- SOURCE_DEV="/dev/fd1H1440"
- break;
- elif [ "$TMP" = "3" ]; then
- SOURCE_DEV="/dev/fd2H1440"
- break;
- elif [ "$TMP" = "4" ]; then
- SOURCE_DEV="/dev/fd3H1440"
- break;
- fi
- done
- echo "What type of filesystem is $SOURCE_DEV? "
- cat << EOF
-
- 1 - Linux/ext2
- 2 - Linux/minix
- 3 - MSDOS
-
- EOF
- while [ 0 ]; do
- echo -n "Please enter the partition type: "
- read TMP
- if [ "$TMP" = "1" ]; then
- SOURCE_TYPE=ext2
- break;
- elif [ "$TMP" = "2" ]; then
- SOURCE_TYPE=minix
- break;
- elif [ "$TMP" = "3" ]; then
- SOURCE_TYPE=msdos
- break;
- fi
- done
- elif [ "$SOURCE_TYPE" = "2" ]; then
- CHANGEABLE=n
- cat << EOF
-
- INSTALLING FROM HARD DISK
- -------------------------
-
- In order to install directly from hard disk, you must have a partition
- containing the distribution sources in separate subdirectories. The
- partition must be either Linux/ext2, minix or msdos.
-
- EOF
- while [ 0 ]; do
- echo -n "Please enter the device for the sources: "
- read SOURCE_DEV
- [ -n $SOURCE_DEV ] || continue;
- if [ -b $SOURCE_DEV ]; then
- if [ "$SOURCE_DEV" = "/dev/hda" -o "$SOURCE_DEV" = "/dev/hdb" ]; then
- echo "You cannot give the whole drive as your distribution source location"
- continue;
- fi
- if [ "$SOURCE_DEV" = "$SWAP" ]; then
- echo "You cannot give your swap partition as your distribution source location"
- continue;
- fi
- break;
- fi
- done
- echo
- echo "What type of partition is $SOURCE_DEV? "
- cat << EOF
-
- 1 - Linux/ext2
- 2 - Linux/minix
- 3 - MSDOS
-
- EOF
- while [ 0 ]; do
- echo -n "Please enter the partition type: "
- read TMP
- if [ "$TMP" = "1" ]; then
- SOURCE_TYPE=ext2
- break;
- elif [ "$TMP" = "2" ]; then
- SOURCE_TYPE=minix
- break;
- elif [ "$TMP" = "3" ]; then
- SOURCE_TYPE=msdos
- break;
- fi
- done
- echo
- # echo "Where are the files stored in the partition (relative to the"
- # echo "top of the partition)?"
- # echo
- SOURCE_LOC="."
- fi
- if [ "$CHANGEABLE" = "y" ]; then
- echo
- echo "Using $SOURCE_DEV for distribution sources"
- else
- echo
- echo "Using $SOURCE_LOC in $SOURCE_DEV type $SOURCE_TYPE for distribution sources"
- set -e
- mount $SOURCE_DEV $SOURCE -t $SOURCE_TYPE
- set +e
- fi
- if [ -n "$ROOT" ]; then
- echo
- echo "Mounting root partition onto /mnt..."
- set -e
- mount $ROOT -t ext2 /mnt
- set +e
- TARGET_MOUNTED="y"
- fi
- cat << EOF
-
- The arm Linux distribution is split up into several sets of disks. Currently
- (1 Jan 1996) the list is:
-
- Name Contains Size (MB) No. Disks
- -----------------------------------------------------------------------------------
- 1 - base: base utilities 9 3
- 2 - dev: bison, flex, lisp, perl *
- 3 - gcc: gcc, g++, header files, libraries *
- 4 - net: Inet tools (TCP/IP) *
- 5 - mail: mail programs (elm, sendmail, deliver) *
- 6 - news: news programs (inn, trn) *
- 7 - x11: X11 30 *
-
- (*) - disk set as yet unavailable.
-
- EOF
- if [ "$ADDSOFT" = "i" ]; then
- echo " *** I will install the base set anyway - please don't specify it! ***"
- echo
- DISKSETS="1"
- fi
- echo "Please enter a list of disk sets you want to install separated by spaces"
- echo -n "Which disk sets do you want to install? "
- read TMP
- DISKSETS="$DISKSETS $TMP"
- echo
- echo "Installing... Please wait..."
- echo
- for I in $DISKSETS; do
- case $I in
- 1) SET="base" ;;
- 2) SET="dev" ;;
- 3) SET="gcc" ;;
- 4) SET="net" ;;
- 5) SET="mail" ;;
- 6) SET="news" ;;
- 7) SET="x11" ;;
- *) continue;
- esac
- # if [ `eval "echo `echo '$'$SET`"` != 1 ]; then
- # eval "$SET=1"
- echo "Installing disk set $SET"
- DISK="0"
- while [ 0 ]; do
- DISK=`expr $DISK + 1`
- if [ "$CHANGEABLE" = "y" ]; then
- SRC=$SOURCE
- else
- SRC=$SOURCE/$SOURCE_LOC/$SET/$DISK
- fi
- while [ ! -f $SRC/d$SET.$DISK ]; do
- umount $SOURCE 1> /dev/null 2> /dev/null
- echo -n " Please insert disk $DISK of set $SET in $SOURCE_DEV and press return"
- read DUMMY
- mount -r -t $SOURCE_TYPE $SOURCE_DEV $SOURCE
- done
- if [ -f $SRC/dinfo.gz ]; then
- zcat $SRC/dinfo.gz
- elif [ -f $SRC/dinfo ]; then
- cat $SRC/dinfo
- fi
- if [ -f $SRC/dinst ]; then
- sh $SRC/dinst
- else
- tar $TARFLAGS $SRC/$SET$DISK.tgz -C $TARGET
- fi
- if [ -f $SRC/dlast ]; then
- break;
- fi
- done
- # fi
- done
- if [ -f /fstab ]; then
- mv /fstab $TARGET/etc
- fi
- umount $SOURCE 1> /dev/null 2> /dev/null
- if [ "$TARGET_MOUNTED" = "y" ]; then
- umount $TARGET 1> /dev/null 2> /dev/null
- fi
- if [ "$ADDSOFT" = "i" ]; then
- echo "arm Linux installation complete."
- else
- echo "Additional software installation complete."
- fi
- cat << EOF
-
- If you wish to add any more partitions that can be mounted, please
- insert them into your /etc/fstab file in the same format as those
- already present with a pass number greater than 1.
-
- EOF
- exit 0;
-