home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- echo "Welcome to the SLS installation program (copyright Softlanding Software)"
- echo " "
-
- function usage() {
- echo " "
- echo "Installs SLS onto a hard disk from floppies, tape, CD, HD or Network"
- echo "usage: doinstall PART [ PART2 MNT2 ...]"
- echo "where: PART is the partition to install to, optionally followed by"
- echo "partition/directory pairs to mount on root. for example"
- echo " doinstall # does menu driven install"
- echo " doinstall /dev/hda2"
- echo " doinstall /dev/hda2 /dev/hda3 /usr /dev/hdb1 /usr/spool"
- exit 1
- }
-
- function domount() {
- if [ ! -b $1 ]; then
- echo "Error: $1 is not a block device, can not mount on $2";
- usage;
- exit 2
- fi
- MOUNTTYPE="ext2"
- mount -t $MOUNTTYPE $1 $2
- MNTSTAT=$?;
- if [ $MNTSTAT != 0 ]; then
- echo "Error: can not mount $1. Did you use: mke2fs -c $1 SIZE"
- echo "where SIZE is the number of blocks shown by fdisk?"
- exit 1;
- fi
- if [ "$2" = "/root/" ]; then
- echo "$1 / $MOUNTTYPE defaults" > /root/fstab.tmp
- else
- echo "$1 $2 $MOUNTTYPE defaults" >> /root/fstab.tmp
- fi
- }
-
- function partdetect()
- {
- (fdisk $1 << EOF
- q
- EOF
- ) >& /dev/null
- return $?
- }
-
- function partshow()
- {
- (fdisk $1 << EOF
- p
- q
- EOF
- echo "") | fgrep '/dev/' | sed '/Disk/d'
- }
-
- function partsize () { partshow `echo $1 | cut -c1-8` | fgrep $1 | cut -c38-45 }
-
- declare -i DISKCOUNT
-
- function partdisplay()
- {
- echo 'Following is your current partition setup:'
- DISKCOUNT=0;
- DISKLIST=""
- for i in hda hdb sda sdb sdc sdd sde sdf; do
- partdetect /dev/$i &&
- DISKCOUNT=$DISKCOUNT+1 &&
- DISKLIST="/dev/$i $DISKLIST" &&
- partshow /dev/$i &&
- if [ "$EXPART" = "" ]; then
- EXPART=/dev/${i}1
- fi
- done
- if [ $DISKCOUNT = 0 ]; then
- echo "Sorry, Linux can not find any hard disks $DISKLIST";
- exit 1
- fi
- }
-
- function runfdisk()
- {
- if [ $DISKCOUNT = 1 ]; then
- CURDISK=$DISKLIST;
- else
- echo -n "which disk do you wish to partition [$DISKLIST]"
- read CURDISK
- fi
- fdisk $CURDISK;
- echo "If you wrote any changes, please (hard) reboot your PC now"
- exit 0
- }
-
- function domkfs()
- {
- if [ "$1" = "" ]; then
- return 1
- fi
- if [ ! -b $1 ]; then
- echo "$1 is not a valid partition"
- return 1
- fi
- if [ "`echo $1 | cut -c9`" = "" ]; then
- echo "invalid partition"
- return 1
- fi
- echo "Preparing Hard Drive. This will take a few minutes, please standby..."
- echo " "
- mke2fs -c $1 `partsize $1` || (echo "mke2fs failed"; exit 1)
- }
-
- function partsetup()
- {
- if [ "$ROOTDEVICE" = "" ]; then
- echo -n "enter the name of the partition to use as root (eg. $EXPART): "
- read ROOTDEVICE
- NEWPART=$ROOTDEVICE
- NEWDIR=
- else
- echo -n "enter the name of the partition to use as root (eg. $EXPART):"
- read NEWPART
- echo -n "what directory should this partition be mounted on (eg. /home): "
- read NEWDIR
- fi
- domkfs $NEWPART || exit 1
- if [ "$NEWDIR" != "" ]; then
- mkdir /root/$NEWDIR || exit
- fi
- domount $NEWPART /root/$NEWDIR
- }
-
- function linuxsetup()
- { partdisplay
- while [ 1 ]; do
- echo ' Disk Setup Procedure '
- echo ' '
- echo ' 1 Setup Linux partitions (first one will be used as the root)'
- echo ' 2 Setup a swap PARTITION (required for 4 Megs RAM or less)'
- echo ' 3 Setup a swap FILE on root (must do 1 above first)'
- echo ' 4 Display partition sizes'
- echo ' 5 Run fdisk to change partition sizes (will require a reboot)'
- echo ' 6 Abort installation'
- echo ' 7 Done (commence installation)'
- echo ' '
- echo -n " Select one of the above (1-7): "
- read func;
- case $func in
- 1) partsetup;;
- [2,3]) if [ "$swapsize" != "" ]; then
- echo "Sorry: swap area was already created"
- continue;
- fi
- if [ "$func" = "2" ]; then
- echo -n "Use which partition for swapping (eg. $EXPART): "
- read swappart;
- swapsize=`partsize $swappart`
- else
- if [ "$PARTNAMES" = "" ]; then
- echo "Sorry, you must setup the root first";
- continue;
- fi
- echo -n "How big a swap file in Megs (max 16): "
- declare -i swapmegs
- read swapmegs
- swapsize = swapmegs * 1024;
- swappart=/root/swap
- fi
- mkswap $swappart $swapsize &&
- swapon $swappart &&
- if [ -f /root/fstab.tmp ]; then
- echo "$1 $2 swap" >> /root/fstab.tmp
- fi
- ;;
- 4) partdisplay;;
- 5) runfdisk ;;
- 6) exit 0;;
- 7) break;;
- esac
- done
- }
-
- function mountsource() {
- case $1 in
- harddrive)
- INSTSRC=/mnt/install
- echo -n "Enter the partition that the source is on (eg. /dev/hda1):"
- read hdloc;
- echo -n "Enter the type of the filesystem (minix/ext2/msdos)";
- read hdtype;
- mount -t $hdtype $hdloc /mnt
- ;;
- cdrom)
- INSTSRC=/mnt/install
- echo -n "Is this a Mitsumi CDROM player (y/n)"
- read ans;
- if [ "$ans" = "y" ]; then
- echo -n "Enter the IRQ,BASEADDR (eg 7,280):"
- readn ans;
- echo "mitsumi=$ans" >> /root/etc/hwconfig
- mount -t iso9660 /dev/mcd0 /mnt
- else
- echo "Assuming SCSI CDROM"
- mount -t iso9660 /dev/sr0 /mnt
- echo "CDROM SCSI" >> /root/etc/hwconfig
- fi
- ;;
- network)
- INSTSRC=/mnt/install
- echo "Following is your current IP setup"
- cat /etc/hosts
- echo -n "Do you wish to change or set your IP address(y/n)?: "
- read ans;
- if [ "y" = "$ans" ]; then
- echo -n "Enter your IP address (eg, 192.0.2.129): "
- read ans;
- echo "$ans `hostname`" > /etc/hosts
- echo -n "Enter your Network address (eg, 192.0.2.0): "
- read ans;
- echo "$ans network" >> /etc/hosts
- echo -n "Enter your Router address, if any (eg, 192.0.2.1): "
- read ans;
- if [ "" != "$ans" ]; then
- echo "$ans router" >> /etc/hosts
- fi
- echo "127.0.0.1 localhost" >> /etc/hosts
- sync
- echo "IP setup is now changed";
- fi
- if [ "$RCNET_RUN" = "" ]; then
- /etc/rc.net
- fi
- RCNET_RUN=1
- echo -n "Enter IP address of NFS server:"
- read ipaddr;
- echo -n "Enter directory on server where SLS source dir ./install/ is located:"
- read path;
- while [ 1 ]; do
- mount -t nfs $ipaddr:$path /mnt && break;
- echo -n "mount failed (sometimes takes 2-3 tries). Try again (y/n): "
- read ans;
- if [ "$ans" != "y" ]; then
- break;
- fi
- done
- ;;
- esac
- MNTSTAT=$?
- if [ $MNTSTAT != 0 ]; then
- echo "error: can not mount source"
- exit 2;
- fi
- if [ -d $INSTSRC/a4 -a -d $INSTSRC/a3 ]; then
- return
- else
- echo "error: SLS distribution files not found in $INSTSRC"
- usage
- fi
- }
-
- umount /root >& /dev/null
- if [ $# -lt 1 ]; then
- linuxsetup
- else
- ROOTDEVICE=$1
- domount $ROOTDEVICE /root
- fi
- INSTDEV=/dev/fd0
- INSTSRC=
- INSTTYPE=
- INSTMEDIA=
-
- if [ "/dev/ram /" = "`rdev`" ]; then
- if [ -f /bin/vi ]; then
- rm -f /bin/vi /bin/telnet /bin/ping
- SWAPSIZE=400
- else
- SWAPSIZE=200
- fi
- if [ -f /zImage -a ! -f /swap ]; then
- rm /zImage
- dd if=/dev/zero of=/swap bs=1k count=$SWAPSIZE >& /dev/null
- mkswap /swap $SWAPSIZE
- swapon /swap
- fi
- fi
- while [ 0 ]; do
- umount /mnt >& /dev/null
- echo ' Install Source '
- echo ''
- echo ' 1 Install from Floppy Disks'
- echo ' 2 Install from Hard Disk'
- echo ' 3 Install from Tape'
- echo ' 4 Install from CDROM'
- echo ' 5 Install from Network (via NFS)'
- echo ' 6 Install just bootdisk to HD'
- echo ' '
- echo -n 'Where will you be installing SLS from (1-6): '
- read ans;
- case $ans in
- 1 ) INSTMEDIA=floppy
- while [ 0 ];do
- echo " "
- echo ' 1) Drive A: 5 1/4 inch'
- echo ' 2) Drive A: 3 1/2 inch'
- echo ' 3) Drive B: 5 1/4 inch'
- echo ' 4) Drive B: 3 1/2 inch'
- echo " "
- echo -n "Enter Drive You Will Be Doing The Installation From (1/2/3/4): "
- read answer;
- case $answer in
- 1) INSTDEV=/dev/fd0h1200;;
- 2) INSTDEV=/dev/fd0H1440;;
- 3) INSTDEV=/dev/fd1h1200;;
- 4) INSTDEV=/dev/fd1H1440;;
- *) continue;;
- esac
- umount $INSTDEV
- break;
- done
- ;;
- 2 ) INSTMEDIA=harddrive; mountsource harddrive ;;
- 3 ) INSTMEDIA=tape ;;
- 4 ) INSTMEDIA=cdrom; mountsource cdrom ;;
- 5 ) INSTMEDIA=network; mountsource network ;;
- 6 ) umount /proc; cp -ax /[a-qs-z]* /root; mkdir /root/root; sync
- echo "Reboot now using ALT at LILO prompt and \"harddisk root=$ROOTDEVICE\""
- exit 0 ;;
- *) echo "$ans invalid, pick again"; continue;;
- esac
- break;
- done
- while [ "$INSTMEDIA" != tape ]; do
- echo ' '
- echo ' 1 - Install a minimal system (12 Meg)'
- echo ' 2 - Install the full base system (50 Meg)'
- echo ' 3 - Install base system + X11 (70 Meg)'
- echo ' 4 - Install everything (90 Meg)'
- echo " "
- echo -n 'Enter type of install (1/2/3/4)'
- read ans;
- if [ $ans = 1 ]; then
- INSTTYPE="mini"
- break;
- elif [ $ans = 2 ]; then
- INSTTYPE="base"
- break;
- elif [ $ans = 3 ]; then
- INSTTYPE="all"
- break;
- elif [ $ans = 4 ]; then
- INSTTYPE="everything"
- break;
- fi
- done
- mkdir -p /root/etc
- echo -n "" > /root/etc/hwconfig
- mkdir -p /root/install/installed
- mkdir -p /root/install/disks
- mkdir -p /root/install/scripts
- mkdir -p /root/install/catalog
- while [ "$NEWPART" = "" ]; do
- if [ "" != "$2" -a "" != "$3" ]; then
- mkdir /root$3
- domount $2 /root$3
- shift 2;
- else
- break;
- fi
- done
- if [ -f /root/doinst.sh ]; then
- sh /root/doinst.sh;
- fi
- if [ "$INSTMEDIA" != tape ]; then
- echo -n 'Do you want to be prompted, with a description, before installing each package? (y/n): '
- read ans
- if [ "$ans" = "y" ]; then
- DOPROMPT="-doprompt"
- fi
- fi
- if [ "$INSTSRC" != "" ]; then
- INSTSRC="-instsrc $INSTSRC"
- fi
- if [ "$INSTMEDIA" = tape ]; then
- export DOPROMPT
- tarsh /dev/rmt0 /bin/tapeinstall
- else
- echo "sysinstall -instdev $INSTDEV $INSTSRC -instroot /root $DOPROMPT -$INSTTYPE"
- sysinstall -instdev $INSTDEV $INSTSRC -instroot /root $DOPROMPT -$INSTTYPE
- fi
- hash -r
- mv /root/fstab.tmp /root/etc/fstab
- if [ "$INSTDEV" != "" ]; then
- if [ $INSTDEV = /dev/fd1H1440 ]; then
- INSTDEV=/dev/fd0h1200;
- elif [ $INSTDEV = /dev/fd1h1200 ]; then
- INSTDEV=/dev/fd0H1440;
- fi
- echo "FLOPPYA $INSTDEV" >> /root/etc/hwconfig
- fi
- echo "ROOTDEV $ROOTDEVICE" >> /root/etc/hwconfig
- VGAMODE=-3
- if [ "/dev/ram /" = "`rdev`" ]; then
- echo -n 'Now put a formatted floppy into your boot drive and hit enter: '
- read ans;
- dd if=/root/zImage of=$INSTDEV
- rdev $INSTDEV $ROOTDEVICE
- echo -n "Do you wish to have the video mode preset at boot time? (y/n): "
- read ans;
- if [ "$ans" = "y" ]; then
- echo -n "Enter the mode (-1 for 80x25 mode, or the key 1, 2, 3, ...): "
- read VGAMODE;
- rdev -v $INSTDEV $VGAMODE
- fi
- sync
- fi
- echo "VGAMODE $VGAMODE" >> /root/etc/hwconfig
- if [ -x /root/etc/syssetup ]; then
- (cd /root; etc/syssetup -instroot /root -install )
- fi
- ANOTHER=""
- while [ 1 ]; do
- echo -n "If there is a$ANOTHER patch disk to install, insert it in A: and type y (y/n): "
- read ans;
- if [ "$ans" = "y" ]; then
- sysinstall -disk && echo "Patch disk installed..."
- ANOTHER=" another"
- else
- break;
- fi
- done
- sync
- echo "Installation is complete. You may now hard reset your computer and start"
- echo "using SLS from your hard drive. Alternatively, you can boot from the"
- echo "newly created boot disk, or you can boot from the install disk as follows:"
- echo ' - when you see the word "LILO", hold down the ALT key'
- echo " - type \"harddisk root=$ROOTDEV\" to boot to your installation"
- echo 'Once there, you can use "makebootdisk" to create a boot floppy'
-