allow install to be restarted in many cases without blowing away everything already...
authorgrr <grr@openbsd.org>
Fri, 2 May 1997 20:56:17 +0000 (20:56 +0000)
committergrr <grr@openbsd.org>
Fri, 2 May 1997 20:56:17 +0000 (20:56 +0000)
distrib/miniroot/install.sh
distrib/miniroot/install.sub

index 9362c6e..259e755 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-#      $OpenBSD: install.sh,v 1.5 1997/04/30 23:56:05 grr Exp $
+#      $OpenBSD: install.sh,v 1.6 1997/05/02 20:56:17 grr Exp $
 #      $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $
 #
 # Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -74,12 +74,21 @@ MODE="install"
 # which sets?
 THESETS="$ALLSETS"
 
-# Good {morning,afternoon,evening,night}.
-md_welcome_banner
-echo -n "Proceed with installation? [n] "
+if [ "`df /`" = "`df /mnt`" ]; then
+       # Good {morning,afternoon,evening,night}.
+       md_welcome_banner
+       echo -n "Proceed with installation? [n] "
+else
+       echo "You seem to be trying to restart an interrupted installation!"
+       echo ""
+       echo "You can try to skip the disk preparation steps and continue,"
+       echo "otherwise you should reboot the miniroot and start over..."
+       echo -n "Skip disk initialization? [n] "
+fi
 getresp "n"
 case "$resp" in
        y*|Y*)
+               echo    ""
                echo    "Cool!  Let's get to it..."
                ;;
        *)
@@ -100,25 +109,28 @@ get_timezone
 # Make sure we can write files (at least in /tmp)
 # This might make an MFS mount on /tmp, or it may
 # just re-mount the root with read-write enabled.
-md_makerootwritable
+if [ "`df /`" = "`df /tmp`" ]; then
+       md_makerootwritable
+fi
 
-# Install the shadowed disktab file; lets us write to it for temporary
-# purposes without mounting the miniroot read-write.
-cp /etc/disktab.shadow /tmp/disktab.shadow
+if [ "`df /`" = "`df /mnt`" ]; then
+       # Install the shadowed disktab file; lets us write to it for temporary
+       # purposes without mounting the miniroot read-write.
+       cp /etc/disktab.shadow /tmp/disktab.shadow
 
-while [ "X${ROOTDISK}" = "X" ]; do
-       getrootdisk
-done
+       while [ "X${ROOTDISK}" = "X" ]; do
+               getrootdisk
+       done
 
-# Deal with disklabels, including editing the root disklabel
-# and labeling additional disks.  This is machine-dependent since
-# some platforms may not be able to provide this functionality.
-md_prep_disklabel ${ROOTDISK}
+       # Deal with disklabels, including editing the root disklabel
+       # and labeling additional disks.  This is machine-dependent since
+       # some platforms may not be able to provide this functionality.
+       md_prep_disklabel ${ROOTDISK}
 
-# Assume partition 'a' of $ROOTDISK is for the root filesystem.  Loop and
-# get the rest.
-# XXX ASSUMES THAT THE USER DOESN'T PROVIDE BOGUS INPUT.
-cat << \__get_filesystems_1
+       # Assume partition 'a' of $ROOTDISK is for the root filesystem.
+       # Loop and get the rest.
+       # XXX ASSUMES THAT THE USER DOESN'T PROVIDE BOGUS INPUT.
+       cat << \__get_filesystems_1
 
 You will now have the opportunity to enter filesystem information.
 You will be prompted for device name and mount point (full path,
@@ -131,91 +143,96 @@ to resolve any filesystem order dependencies.
 
 __get_filesystems_1
 
-echo   "The following will be used for the root filesystem:"
-echo   "       ${ROOTDISK}a    /"
+       echo    "The following will be used for the root filesystem:"
+       echo    "       ${ROOTDISK}a    /"
 
-echo   "${ROOTDISK}a /" > ${FILESYSTEMS}
+       echo    "${ROOTDISK}a /" > ${FILESYSTEMS}
+
+       resp="X"        # force at least one iteration
+       while [ "X$resp" != X"done" ]; do
+               echo    ""
+               echo -n "Device name? [done] "
+               getresp "done"
+               case "$resp" in
+               done)
+                       ;;
+
+               *)
+                       _device_name=`basename $resp`
+
+                       # force at least one iteration
+                       _first_char="X"
+                       while [ "X${_first_char}" != X"/" ]; do
+                               echo -n "Mount point? "
+                               getresp ""
+                               _mount_point=$resp
+                               _first_char=`firstchar ${_mount_point}`
+                               if [ "X${_first_char}" != X"/" ]; then
+                                       echo "mount point must be an absolute path!"
+                               fi
+                       done
+                       if [ "X${_mount_point}" = X"/" ]; then
+                               echo "root mount point already taken care of!"
+                       else
+                               echo "${_device_name} ${_mount_point}" \
+                                       >> ${FILESYSTEMS}
+                       fi
+                       resp="X"        # force loop to repeat
+                       ;;
+               esac
+       done
 
-resp="X"       # force at least one iteration
-while [ "X$resp" != X"done" ]; do
        echo    ""
-       echo -n "Device name? [done] "
-       getresp "done"
+       echo    "You have configured the following devices and mount points:"
+       echo    ""
+       cat ${FILESYSTEMS}
+       echo    ""
+       echo    "Filesystems will now be created on these devices."
+       echo -n "If you made any mistakes, you may edit this now.  Edit? [n] "
+       getresp "n"
        case "$resp" in
-       done)
-               ;;
-
-       *)
-               _device_name=`basename $resp`
-
-               # force at least one iteration
-               _first_char="X"
-               while [ "X${_first_char}" != X"/" ]; do
-                       echo -n "Mount point? "
-                       getresp ""
-                       _mount_point=$resp
-                       _first_char=`firstchar ${_mount_point}`
-                       if [ "X${_first_char}" != X"/" ]; then
-                               echo "mount point must be an absolute path!"
-                       fi
-               done
-               if [ "X${_mount_point}" = X"/" ]; then
-                       echo "root mount point is already taken care of!"
-               else
-                       echo "${_device_name} ${_mount_point}" >> ${FILESYSTEMS}
-               fi
-               resp="X"        # force loop to repeat
-               ;;
+               y*|Y*)
+                       ${EDITOR} ${FILESYSTEMS}
+                       ;;
+               *)
+                       ;;
        esac
-done
-
-echo   ""
-echo   "You have configured the following devices and mount points:"
-echo   ""
-cat ${FILESYSTEMS}
-echo   ""
-echo   "Filesystems will now be created on these devices.  If you made any"
-echo -n        "mistakes, you may edit this now.  Edit? [n] "
-getresp "n"
-case "$resp" in
-       y*|Y*)
-               ${EDITOR} ${FILESYSTEMS}
-               ;;
-       *)
-               ;;
-esac
-echo   ""
-echo    "The next step *WILL* overwrite any existing data on:"
-(
-       while read _device_name _junk; do
-               echo ${_device_name}
-       done
-) < ${FILESYSTEMS}
-echo   ""
+       echo    ""
+       echo     "The next step will overwrite any existing data on:"
+       (
+               echo -n "       "
+               while read _device_name _junk; do
+                       echo -n "${_device_name} "
+               done
+               echo ""
+       ) < ${FILESYSTEMS}
+       echo    ""
 
-echo -n        "Are you *SURE* that you're ready to proceed? [n] "
-getresp "n"
-case "$resp" in
-       y*|Y*)
-               ;;
-       *)
-               echo "ok, try again later..."
-               exit
-               ;;
-esac
+       echo -n "Are you really sure that you're ready to proceed? [n] "
+       getresp "n"
+       case "$resp" in
+               y*|Y*)
+                       ;;
+               *)
+                       echo "ok, try again later..."
+                       exit
+                       ;;
+       esac
 
-# Loop though the file, place filesystems on each device.
-echo   "Creating filesystems..."
-(
-       while read _device_name _junk; do
-               newfs /dev/r${_device_name}
-               echo ""
-       done
-) < ${FILESYSTEMS}
+       # Loop though the file, place filesystems on each device.
+       echo    "Creating filesystems..."
+       (
+               while read _device_name _junk; do
+                       newfs /dev/r${_device_name}
+                       echo ""
+               done
+       ) < ${FILESYSTEMS}
+fi
 
 # Get network configuration information, and store it for placement in the
 # root filesystem later.
 cat << \__network_config_1
+
 You will now be given the opportunity to configure the network.  This will
 be useful if you need to transfer the installation sets via FTP or NFS.
 Even if you choose not to transfer installation sets that way, this
@@ -242,7 +259,7 @@ case "$resp" in
 
                resp=""         # force at least one iteration
                while [ "X${resp}" = X"" ]; do
-                       echo -n "Enter DNS domain name: [$FQDN]"
+                       echo -n "Enter DNS domain name: [$FQDN] "
                        getresp "$FQDN"
                done
                FQDN=$resp
@@ -329,22 +346,23 @@ __network_config_2
                ;;
 esac
 
-# Now that the network has been configured, it is safe to configure the
-# fstab.
-(
-       while read _dev _mp; do
-               if [ "$mp" = "/" ]; then
-                       echo /dev/$_dev $_mp ffs rw 1 1
-               else
-                       echo /dev/$_dev $_mp ffs rw 1 2
-               fi
-       done
-) < ${FILESYSTEMS} > /tmp/fstab
+if [ "`df /`" = "`df /mnt`" ]; then
+       # Now that the network has been configured, it is safe to configure the
+       # fstab.
+       (
+               while read _dev _mp; do
+                       if [ "$mp" = "/" ]; then
+                               echo /dev/$_dev $_mp ffs rw 1 1
+                       else
+                               echo /dev/$_dev $_mp ffs rw 1 2
+                       fi
+               done
+       ) < ${FILESYSTEMS} > /tmp/fstab
 
-echo   "The fstab is configured as follows:"
-echo   ""
-cat /tmp/fstab
-cat << \__fstab_config_1
+       echo    "The fstab is configured as follows:"
+       echo    ""
+       cat /tmp/fstab
+       cat << \__fstab_config_1
 
 You may wish to edit the fstab.  For example, you may need to resolve
 dependencies in the order which the filesystems are mounted.  You may
@@ -353,20 +371,21 @@ This would be especially useful if you plan to keep '/usr' on an NFS
 server.
 
 __fstab_config_1
-echo -n        "Edit the fstab? [n] "
-getresp "n"
-case "$resp" in
-       y*|Y*)
-               ${EDITOR} /tmp/fstab
-               ;;
+       echo -n "Edit the fstab? [n] "
+       getresp "n"
+       case "$resp" in
+               y*|Y*)
+                       ${EDITOR} /tmp/fstab
+                       ;;
 
-       *)
-               ;;
-esac
+               *)
+                       ;;
+       esac
 
-echo ""
-munge_fstab /tmp/fstab /tmp/fstab.shadow
-mount_fs /tmp/fstab.shadow
+       echo ""
+       munge_fstab /tmp/fstab /tmp/fstab.shadow
+       mount_fs /tmp/fstab.shadow
+fi
 
 mount | while read line; do
        set -- $line
@@ -387,42 +406,57 @@ done
 install_sets $ALLSETS $MDSETS
 
 # Copy in configuration information and make devices in target root.
-(
-       cd /tmp
-       for file in fstab hostname.* hosts myname mygate resolv.conf; do
-               if [ -f $file ]; then
-                       echo -n "Copying $file..."
-                       cp $file /mnt/etc/$file
-                       echo "done."
-               fi
-       done
 
-       # If no zoneinfo on the installfs, give them a second chance
-       if [ ! -e /usr/share/zoneinfo ]; then
-               get_timezone
-       fi
-       if [ ! -e /mnt/usr/share/zoneinfo ]; then
-               echo "Cannot install timezone link..."
-       else
-               echo -n "Installing timezone link..."
-               rm -f /mnt/etc/localtime
-               ln -s /usr/share/zoneinfo/$TZ /mnt/etc/localtime
+if [ ! -d /mnt/etc -o ! -d /mnt/usr/share/zoneinfo -o ! -d /mnt/dev ]; then
+       echo "Something needed to complete the installation seems"
+       echo "to be missing, did you forget to extract a required set?"
+       echo ""
+       echo "Please review the installation notes and try again..."
+       echo ""
+       echo "You *may* be able to correct the problem and type 'install'"
+       echo "without having to extract all of the distribution sets again."
+       exit
+fi
+
+cd /tmp
+for file in fstab hostname.* hosts myname mygate resolv.conf; do
+       if [ -f $file ]; then
+               echo -n "Copying $file..."
+               cp $file /mnt/etc/$file
                echo "done."
        fi
-       if [ ! -x /mnt/dev/MAKEDEV ]; then
-               echo "No /dev/MAKEDEV installed, something is wrong here..."
-       else
-               echo -n "Making devices..."
-               pid=`twiddle`
-               cd /mnt/dev
-               sh MAKEDEV all
-               kill $pid
-               echo "done."
-       fi
-       md_copy_kernel
+done
 
-       md_installboot ${ROOTDISK}
-)
+# If no zoneinfo on the installfs, give them a second chance
+if [ ! -e /usr/share/zoneinfo ]; then
+       get_timezone
+fi
+if [ ! -e /mnt/usr/share/zoneinfo ]; then
+       echo "Cannot install timezone link..."
+else
+       echo -n "Installing timezone link..."
+       rm -f /mnt/etc/localtime
+       ln -s /usr/share/zoneinfo/$TZ /mnt/etc/localtime
+       echo "done."
+fi
+
+
+md_copy_kernel
+
+md_installboot ${ROOTDISK}
+
+if [ ! -x /mnt/dev/MAKEDEV ]; then
+       echo "No /dev/MAKEDEV installed, something is wrong here..."
+       exit
+fi
+
+echo -n "Making all devices..."
+pid=`twiddle`
+cd /mnt/dev
+sh MAKEDEV all
+kill $pid
+echo "done."
+cd /
 
 unmount_fs /tmp/fstab.shadow
 
index dd0055f..548efcc 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-#      $OpenBSD: install.sub,v 1.7 1997/04/30 23:56:06 grr Exp $
+#      $OpenBSD: install.sub,v 1.8 1997/05/02 20:56:18 grr Exp $
 #      $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
 #
 # Copyright (c) 1996 The NetBSD Foundation, Inc.
 #      OpenBSD installation/upgrade script - common subroutines.
 
 ROOTDISK=""                            # filled in below
-VERSION=                               # filled in automatically (see list)
+VERSION=21
 export VERSION
 
-ALLSETS="base comp etc games man misc text"    # default install sets
-UPGRSETS="base comp games man misc text"       # default upgrade sets
+ALLSETS="etc base misc comp text man game"     # default install sets
+UPGRSETS="base misc comp text man game"                # default upgrade sets
 THESETS=                                       # one of the above
 
 local_sets_dir=""                      # Path searched for sets by install_sets
@@ -577,11 +577,20 @@ __install_ftp_1
        done
 
        # Get list of files for mget.
-       cat << \__install_ftp_2
+       cat << __install_ftp_2
 
-You will now be asked for files to extract.  Enter one file at a time.
+You will now be asked for files to extract.  If you specify just a setname,
+it will be treated as setname${VERSION}.tar.gz or you can specify the
+explict name.  You can also enter 'all' to install all the standard sets,
+or 'list' to list the files avilable at ${_ftp_server_ip}:${_ftp_server_dir}.
 When you are done entering files, enter 'done'.
 
+If you were enter 'all', the following sets would be fetched/extracted:
+       $THESETS
+
+Some of these sets are required for your ${MODE} and some are optional.
+Consult the intallation notes if you are not sure which sets are required!
+
 __install_ftp_2
        echo "#!/bin/sh" > /tmp/ftp-script.sh
        echo "cd /mnt" >> /tmp/ftp-script.sh
@@ -599,10 +608,22 @@ __install_ftp_2
                if [ "X${resp}" = X"done" ]; then
                        break
                fi
+               if [ "X${resp}" = X"list" ]; then
+                       echo "ls" >> /tmp/ftp-script.sh
+                       continue
+               fi
+               if [ "X${resp}" = X"all" ]; then
+                       resp="$THESETS"
+               fi
 
-               _ftp_file=`echo ${resp} | cutword 1'`
-               echo "get ${_ftp_file} |\"tar -zxvpf -\"" >> \
-                   /tmp/ftp-script.sh
+               for _ftp_file in $resp; do
+                       echo -n "get " >> /tmp/ftp-script.sh
+                       echo -n "${_ftp_file}" | \
+                           sed "/\./!s/\$/${VERSION}.tar.gz/" >> \
+                               /tmp/ftp-script.sh
+                       echo " |\"tar -zxvpf -\"" >> \
+                           /tmp/ftp-script.sh
+               done
        done
 
        echo "quit" >> /tmp/ftp-script.sh
@@ -611,10 +632,10 @@ __install_ftp_2
        cat << \__install_ftp_3
 
 Fetching the files via ftp may take a long time, especially over a slow
-network connection.  You may want to review/edit the fetch script to make
+network connection.  You may want to review/edit the ftp script to make
 sure that you haven't made any errors in the file names.
 __install_ftp_3
-       echo -n "edit ftp fetch script? [n] "
+       echo -n "edit ftp script? [n] "
        getresp "n"
        case "$resp" in
        y*|Y*)
@@ -624,10 +645,18 @@ __install_ftp_3
                ;;
        esac
        
-
-       sh /tmp/ftp-script.sh
+       echo -n "submit ftp script? [y] "
+       getresp "n"
+       case "$resp" in
+       y*|Y*)
+               sh /tmp/ftp-script.sh
+               echo "Extraction complete."
+               ;;
+       *)
+               ;;
+       esac
+       
        rm -f /tmp/ftp-script.sh
-       echo "Extraction complete."
 }
 
 install_from_mounted_fs() {
@@ -1145,8 +1174,12 @@ install_sets()
        cat << \__install_sets_1
 
 It is now time to extract the installation sets onto the hard disk.
-Make sure the sets are either on a local device (i.e. tape, CD-ROM) or on a
-network server.
+Make sure the sets are either on a local device (i.e. tape, CD-ROM)
+or on a network server.
+
+You will have the chance to repeat this step or to extract sets from
+several places, so you don't have to try to load all the sets in one
+try and can recover from some errors.
 
 __install_sets_1