diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-05 21:27:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-05 21:27:39 +0000 |
commit | 59436c90b065edbbd368ed8679d5be33153d4fcc (patch) | |
tree | 2b6543cda0aa334b4d05e91f21b85211da5ffde5 /distrib/miniroot/install.sub | |
parent | ff0f2a750cbaf08bb2ec918bdabe6ad55177f066 (diff) |
sync to netbsd
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r-- | distrib/miniroot/install.sub | 692 |
1 files changed, 509 insertions, 183 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index a48d9a7155c..7ccea68a553 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,6 +1,5 @@ #!/bin/sh -# $OpenBSD: install.sub,v 1.3 1996/06/29 05:54:16 tholo Exp $ -# $NetBSD: install.sub,v 1.2 1996/02/28 00:47:43 thorpej Exp $ +# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1996 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,14 +36,27 @@ # POSSIBILITY OF SUCH DAMAGE. # -# OpenBSD installation/upgrade script - common subroutines. +# NetBSD installation/upgrade script - common subroutines. -VERSION=1.1A -export VERSION # XXX needed in subshell ROOTDISK="" # filled in below +VERSION= # filled in automatically (see list) +export VERSION ALLSETS="base comp etc games man misc text" # default install sets UPGRSETS="base comp games man misc text" # default upgrade sets +THESETS= # one of the above + +local_sets_dir="" # Path searched for sets by install_sets + # on the local filesystems + +# decide upon an editor +if [ X$EDITOR = X ]; then + if [ -x /usr/bin/vi ]; then + EDITOR=vi + else + EDITOR=ed + fi +fi getresp() { read resp @@ -65,6 +77,8 @@ isin() { rmel() { # remove first argument from list formed by the remaining arguments + local _a + _a=$1; shift while [ $# != 0 ]; do if [ "$_a" != "$1" ]; then @@ -74,6 +88,83 @@ rmel() { done } +cutword () { +# read a line of data, return Nth element. + local _a + local _n + local _oifs + + # optional field separator + _oifs="$IFS" + case "$1" in + -t?*) IFS=${1#-t}; shift;; + esac + + _n=$1 + read _a; set -- $_a + IFS="$_oifs" + if [ "$1" = "" ]; then return; fi + eval echo \$$_n +} + +cutlast () { +# read a line of data, return last element. Equiv. of awk '{print $NF}'. + local _a + local _oifs + + # optional field separator + _oifs="$IFS" + case "$1" in + -t?*) IFS=${1#-t}; shift;; + esac + + read _a; set -- $_a + IFS="$_oifs" + if [ "$1" = "" ]; then return; fi + while [ "$#" -gt 10 ]; do shift 10; done + eval echo \$$# +} + +firstchar () { +# return first character of argument + local _a + _a=$1 + while [ ${#_a} != 1 ]; do + _a=${_a%?} + done + echo $_a +} + +basename () { + local _oifs + if [ "$1" = "" ]; then return; fi + _oifs="$IFS" + IFS="/" + set -- $1 + IFS="$_oifs" + while [ "$#" -gt 10 ]; do shift 10; done + eval echo \$$# +} + +dir_has_sets() { + # return true when the directory $1 contains a set for $2...$n + local _dir + local _file + + _dir=$1; shift + for _file in $* + do + if [ -f $_dir/${_file}.tar.gz ]; then + return 0 + fi + # Try for stupid msdos convention + if [ -f $_dir/${_file}.tgz ]; then + return 0 + fi + done + return 1 +} + twiddle() { # spin the propeller so we don't get bored while : ; do @@ -84,24 +175,53 @@ twiddle() { done > /dev/tty & echo $! } -. install.md - -do_mfs_mount() { - # $1 is the mount point - # $2 is the size in DEV_BIZE blocks - - umount $1 > /dev/null 2>&1 - if ! mount_mfs -s $2 swap $1 ; then - cat << \__mfs_failed_1 +get_localdir() { + # $1 is relative mountpoint + local _mp + local _dir -FATAL ERROR: Can't mount the memory filesystem. - -__mfs_failed_1 - exit - fi - - # Bleh. Give mount_mfs a chance to DTRT. - sleep 2 + _mp=$1 + _dir= + while : ; do + echo -n "Enter the pathname where the sets are stored [$_dir] " + getresp "$_dir" + _dir=$resp + + # Allow break-out with empty response + if [ -z "$_dir" ]; then + echo -n "Are you sure you don't want to set the pathname? [n] " + getresp "n" + case "$resp" in + y*|Y*) + break + ;; + *) + continue + ;; + esac + fi + + if dir_has_sets "$_mp/$_dir" $THESETS + then + local_sets_dir="$_mp/$_dir" + break + else + cat << __get_reldir_1 +The directory \"$local_sets_dir\" does not exist, or does not hold any of the +upgrade sets. +__get_reldir_1 + echo -n "Re-enter pathname? [y] " + getresp "y" + case "$resp" in + y*|Y*) + ;; + *) + local_sets_dir="" + break + ;; + esac + fi + done } getrootdisk() { @@ -144,7 +264,7 @@ __labelmoredisks_1 ;; *) - if echo "$_DKDEVS" | grep "^$resp" > /dev/null ; then + if isin $resp $_DKDEVS ; then md_labeldisk $resp else echo "" @@ -165,10 +285,8 @@ addhostent() { echo "127.0.0.1 localhost" > /tmp/hosts fi - if grep "^$1 " /tmp/hosts > /dev/null; then - grep -v "^$1 " /tmp/hosts > /tmp/hosts.new - mv /tmp/hosts.new /tmp/hosts - fi + sed "/^$1 /d" < /tmp/hosts > /tmp/hosts.new + mv /tmp/hosts.new /tmp/hosts echo "$1 $2 $2.$FQDN" >> /tmp/hosts } @@ -178,9 +296,10 @@ addifconfig() { # $2 - interface symbolic name # $3 - interface IP address # $4 - interface netmask + # $5 - (optional) interface link-layer directives # Create a hostname.* file for the interface. - echo "inet $2 $4" > /tmp/hostname.$1 + echo "inet $2 $4 NONE $5" > /tmp/hostname.$1 addhostent $3 $2 } @@ -230,13 +349,33 @@ __configurenetwork_1 configure_ifs() { + local _up + local _interface_name + local _interface_ip + local _interface_mask + local _interface_symname + local _interface_extra + _interface_name=$1 + set -- `ifconfig $_interface_name | sed -n ' + 1s/.*<UP,.*$/UP/p + 1s/.*<.*>*$/DOWN/p + 2s/inet// + 2s/--> [0-9.][0-9.]*// + 2s/netmask// + 2s/broadcast// + 2p'` + + _up=$1 + _interface_ip=$2 + _interface_mask=$3 + # Get IP address resp="" # force one iteration while [ "X${resp}" = X"" ]; do - echo -n "IP address? " - getresp "" + echo -n "IP address? [$_interface_ip] " + getresp "$_interface_ip" _interface_ip=$resp done @@ -251,24 +390,44 @@ configure_ifs() { # Get netmask resp="" # force one iteration while [ "X${resp}" = X"" ]; do - echo -n "Netmask? " - getresp "" + echo -n "Netmask? [$_interface_mask] " + getresp "$_interface_mask" _interface_mask=$resp done + echo "Your network interface might require additional link-layer" + echo "directives (like \`link0'). If this is the case you can enter" + echo "these at the next prompt." + echo "" + echo -n "Additional link-layer arguments? [$_interface_extra] " + getresp "$_interface_extra" + if [ "X${resp}" != X"" ]; then + _interface_extra=$resp + fi + # Configure the interface. If it # succeeds, add it to the permanent # network configuration info. - ifconfig ${_interface_name} down - if ifconfig ${_interface_name} inet \ - ${_interface_ip} \ - netmask ${_interface_mask} up ; then + if [ $_up != "UP" ]; then + ifconfig ${_interface_name} down + if ifconfig ${_interface_name} inet \ + ${_interface_ip} \ + netmask ${_interface_mask} ${_interface_extra} up ; then + addifconfig \ + ${_interface_name} \ + ${_interface_symname} \ + ${_interface_ip} \ + ${_interface_mask} ${_interface_extra} + return 0 + fi + else + echo "Interface ${_interface_name} is already active." + echo "Just saving configuration on new root filesystem." addifconfig \ ${_interface_name} \ ${_interface_symname} \ ${_interface_ip} \ - ${_interface_mask} - return 0 + ${_interface_mask} ${_interface_extra} fi return 1 } @@ -422,8 +581,8 @@ __install_ftp_2 break fi - _ftp_file=`echo ${resp} | awk '{print $1}'` - echo "get ${_ftp_file} |\"tar -xzvpf -\"" >> \ + _ftp_file=`echo ${resp} | cutword 1'` + echo "get ${_ftp_file} |\"tar --unlink -zxvpf -\"" >> \ /tmp/ftp-script.sh done @@ -435,49 +594,57 @@ __install_ftp_2 echo "Extraction complete." } -install_common_nfs_cdrom() { - # $1 - directory containing file +install_from_mounted_fs() { + # $1 - directory containing installation sets local _filename - local _setsdone - local _prev + local _sets + local _next local _f - _sets=`(cd /mnt2/$1; ls *.tar.gz)` - if [ -z "$_sets" ]; then - echo "There are no OpenBSD install sets available in \"$1\"" + _sets="" + if dir_has_sets $1 $THESETS; then + for _f in $THESETS ; do + if [ -f $1/${_f}.tar.gz ]; then + _sets="$_sets ${_f}.tar.gz" + elif [ -f $1/${_f}.tgz ]; then + _sets="$_sets ${_f}.tgz" + fi + done + else + echo "There are no NetBSD install sets available in \"$1\"" return fi - _setsdone="" while : ; do echo "The following sets are available for extraction:" echo "(marked sets have already been extracted)" echo "" - _prev="" + _next="" for _f in $_sets ; do if isin $_f $_setsdone; then echo -n "[X] " + _next="" else echo -n " " - if [ -z "$_prev" ]; then _prev=$_f; fi + if [ -z "$_next" ]; then _next=$_f; fi fi echo $_f done echo "" # Get the name of the file. - if [ "X$_prev" = "X" ]; then resp=n; else resp=y; fi + if [ "X$_next" = "X" ]; then resp=n; else resp=y; fi echo -n "Continue extraction [$resp]?" getresp "$resp" if [ "$resp" = "n" ]; then break fi - echo -n "File name [$_prev]? " - getresp "$_prev" + echo -n "File name [$_next]? " + getresp "$_next" _f=$resp - _filename="/mnt2/$1/$_f" + _filename="/$1/$_f" # Ensure file exists if [ ! -f $_filename ]; then @@ -487,7 +654,7 @@ install_common_nfs_cdrom() { fi # Extract file - cat $_filename | (cd /mnt; tar -xzvpf -) + cat $_filename | (cd /mnt; tar --unlink -zxvpf -) echo "Extraction complete." _setsdone="$_f $_setsdone" @@ -495,11 +662,17 @@ install_common_nfs_cdrom() { } install_cdrom() { + local _drive + local _partition_range + local _partition + local _fstype + local _directory + # Get the cdrom device info cat << \__install_cdrom_1 The following CD-ROM devices are installed on your system; please select -the CD-ROM device containing the installation media: +the CD-ROM device containing the partition with the installation sets: __install_cdrom_1 _CDDEVS=`md_get_cddevs` @@ -515,7 +688,7 @@ __install_cdrom_1 *) if isin $resp $_CDDEVS ; then - _cdrom_drive=$resp + _drive=$resp else echo "" echo "The CD-ROM $resp does not exist." @@ -526,13 +699,14 @@ __install_cdrom_1 esac # Get partition + _partition_range=`md_get_partition_range` resp="" # force one iteration while [ "X${resp}" = X"" ]; do echo -n "Partition? [c] " getresp "c" case "$resp" in - [a-h]) - _cdrom_partition=$resp + $_partition_range) + _partition=$resp ;; *) @@ -556,7 +730,7 @@ __install_cdrom_2 getresp "cd9660" case "$resp" in cd9660|ffs) - _cdrom_filesystem=$resp + _fstype=$resp ;; *) @@ -567,8 +741,8 @@ __install_cdrom_2 done # Mount the CD-ROM - if ! mount -t ${_cdrom_filesystem} -o ro \ - /dev/${_cdrom_drive}${_cdrom_partition} /mnt2 ; then + if ! mount -t ${_filesystem} -o ro \ + /dev/${_drive}${_partition} /mnt2 ; then echo "Cannot mount CD-ROM drive. Aborting." return fi @@ -577,12 +751,136 @@ __install_cdrom_2 resp="" # force one iteration while [ "X${resp}" = X"" ]; do echo "Enter the directory relative to the mount point that" - echo -n "contains the file. [${_cdrom_directory}] " - getresp "${_cdrom_directory}" + echo -n "contains the file. [${_directory}] " + getresp "${_directory}" + done + _directory=$resp + + install_from_mounted_fs /mnt2/${_directory} + umount -f /mnt2 > /dev/null 2>&1 +} + +mount_a_disk() { + # Mount a disk on /mnt2. The set of disk devices to choose from + # is $_DKDEVS. + # returns 0 on failure. + + local _drive + local _partition_range + local _partition + local _fstype + local _fsopts + local _directory + local _md_fstype + local _md_fsopts + + getresp "abort" + case "$resp" in + abort) + echo "Aborting." + return 0 + ;; + + *) + if isin $resp $_DKDEVS ; then + _drive=$resp + else + echo "" + echo "The disk $resp does not exist." + echo "Aborting." + return 0 + fi + ;; + esac + + # Get partition + _partition_range=`md_get_partition_range` + resp="" # force one iteration + while [ "X${resp}" = X"" ]; do + echo -n "Partition? [d] " + getresp "d" + case "$resp" in + $_partition_range) + _partition=$resp + ;; + + *) + echo "Invalid response: $resp" + resp="" # force loop to repeat + ;; + esac + done + + # Ask for filesystem type + cat << \__mount_a_disk_2 + +The following filesystem types are supported: + 1) ffs +__mount_a_disk_2 + _md_fstype=`md_native_fstype` + _md_fsopts=`md_native_fsopts` + if [ ! -z "$_md_fstype" ]; then + echo " 2) $_md_fstype" + else + _md_fstype="_undefined_" + fi + resp="" # force one iteration + while [ "X${resp}" = X"" ]; do + echo -n "Which filesystem type? [ffs] " + getresp "ffs" + case "$resp" in + ffs) + _fstype=$resp + _fsopts="ro" + ;; + $_md_fstype) + _fstype=$resp + _fsopts=$_md_fsopts + ;; + *) + echo "Invalid response: $resp" + resp="" # force loop to repeat + ;; + esac + done + + # Mount the disk + if ! mount -t ${_fstype} -o $_fsopts \ + /dev/${_drive}${_partition} /mnt2 ; then + echo "Cannot mount disk. Aborting." + return 0 + fi + return 1 +} + +install_disk() { + local _directory + + cat << \__install_disk_1 + +The following disk devices are installed on your system; please select +the disk device containing the partition with the installation sets: + +__install_disk_1 + _DKDEVS=`md_get_diskdevs` + echo "$_DKDEVS" + echo "" + echo -n "Which is the disk with the installation sets? [abort] " + + if mount_a_disk ; then + return + fi + + # Get the directory where the file lives + resp="" # force one iteration + while [ "X${resp}" = X"" ]; do + echo "Enter the directory relative to the mount point that" + echo -n "contains the file. [${_directory}] " + getresp "${_directory}" done - _cdrom_directory=$resp + _directory=$resp - install_common_nfs_cdrom ${_cdrom_directory} + install_from_mounted_fs /mnt2/${_directory} umount -f /mnt2 > /dev/null 2>&1 } @@ -633,11 +931,13 @@ install_nfs() { done _nfs_directory=$resp - install_common_nfs_cdrom ${_nfs_directory} + install_from_mounted_fs /mnt2/${_nfs_directory} umount -f /mnt2 > /dev/null 2>&1 } install_tape() { + local _xcmd + # Get the name of the tape from the user. cat << \__install_tape_1 @@ -709,31 +1009,42 @@ __install_tape_2 echo -n "Which way is it? [1] " getresp "1" case "$resp" in - 1) - ( - cd /mnt - dd if=$TAPE | tar -xzvpf - - ) - ;; + 1) + _xcmd="tar --unlink -zxvpf -" + ;; - 2) - ( - cd /mnt - dd if=$TAPE | tar -xzvpf - - ) - ;; + 2) + _xcmd="tar --unlink -xvpf -" + ;; - *) - echo "Invalid response: $resp." - resp="" # force loop to repeat - ;; + *) + echo "Invalid response: $resp." + resp="" # force loop to repeat + ;; esac + ( cd /mnt; dd if=$TAPE | $_xcmd ) done echo "Extraction complete." } get_timezone() { local _a + local _zonepath + + # + # If the zoneinfo is not on the installation medium or on the + # installed filesystem, set TZ to GMT and return immediatly. + # + if [ ! -e /usr/share/zoneinfo -a ! -e /mnt/usr/share/zoneinfo ]; then + TZ=GMT + return + fi + if [ ! -d /usr/share/zoneinfo ]; then + _zonepath=/mnt + else + _zonepath="" + fi + cat << \__get_timezone_1 Select a time zone for your location. Timezones are represented on the @@ -747,8 +1058,8 @@ at the prompts below. __get_timezone_1 if [ X$TZ = X ]; then - TZ=`ls -l /etc/timezone 2>/dev/null | awk '{print $NF}' | - sed -e 's?/usr/share/zoneinfo/??'` + TZ=`ls -l /mnt/etc/localtime 2>/dev/null | cutlast` + TZ=${TZ#/usr/share/zoneinfo/} fi while :; do echo -n "What timezone are you in [\`?' for list] [$TZ]? " @@ -760,25 +1071,25 @@ __get_timezone_1 break; ;; "?") - ls /usr/share/zoneinfo + ls ${_zonepath}/usr/share/zoneinfo ;; *) _a=$resp - while [ -d /usr/share/zoneinfo/$_a ]; do + while [ -d ${_zonepath}/usr/share/zoneinfo/$_a ]; do echo -n "There are several timezones available" echo " within zone '$_a'" echo -n "Select a sub-timezone [\`?' for list]: " getresp "" case "$resp" in - "?") ls /usr/share/zoneinfo/$_a ;; + "?") ls ${_zonepath}/usr/share/zoneinfo/$_a ;; *) _a=${_a}/${resp} - if [ -f /usr/share/zoneinfo/$_a ]; then + if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then break; fi ;; esac done - if [ -f /usr/share/zoneinfo/$_a ]; then + if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then TZ="$_a" echo "You have selected timezone \"$_a\"". break 2 @@ -791,113 +1102,107 @@ __get_timezone_1 install_sets() { -# arguments: the base names of the distribution sets to consider -# Ask the user which media to load the distribution from. -cat << \__install_sets_1 + local _yup + _yup="FALSE" + + # Ask the user which media to load the distribution from. + 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 +Make sure the sets are either on a local device (i.e. tape, CD-ROM) or on a network server. __install_sets_1 -if [ -f $RELDIR/$1.tar.gz ]; then - echo -n "Install from sets in the current root filesystem? [y] " - getresp "y" - case "$resp" in - y*|Y*) - for _f do - if [ ! -f $RELDIR/${_f}.tar.gz ]; then - continue - fi - echo -n "Install \"$_f\" ? [y]" - getresp "y" + + if [ "X$local_sets_dir" != "X" ]; then + install_from_mounted_fs ${local_sets_dir} + if [ X"$_setsdone" != X ]; then + _yup="TRUE" + fi + fi + + # Go on prodding for alternate locations + resp="" # force at least one iteration + while [ X"${resp}" = X ]; do + # If _yup is not FALSE, it means that we extracted sets above. + # If that's the case, bypass the menu the first time. + if [ X"$_yup" = X"FALSE" ]; then + echo -n "Install from (f)tp, (t)ape, (C)D-ROM, (N)FS" + echo -n " or local (d)isk? " + getresp "" case "$resp" in - y*|Y*) - cat $RELDIR/${_f}.tar.gz | - (cd /mnt; tar -xzvpf -) - _yup="TRUE" - echo "Extraction complete." + d*|D*) + install_disk + ;; + f*|F*) + install_ftp + ;; + t*|T*) + install_tape + ;; + c*|C*) + install_cdrom + ;; + n*|N*) + install_nfs ;; *) - echo "Skipping \"$_f\"." + echo "Invalid response: $resp" + resp="" ;; esac - done - ;; - *) - _yup="FALSE" - ;; - esac -else - _yup="FALSE" -fi + else + _yup="FALSE" # So we'll ask next time + fi -# Go on prodding for alternate locations -resp="" # force at least one iteration -while [ "X${resp}" = X"" ]; do - # If _yup is not FALSE, it means that we extracted sets above. - # If that's the case, bypass the menu the first time. - if [ X"$_yup" = X"FALSE" ]; then - echo -n "Install from (f)tp, (t)ape, (C)D-ROM, or (N)FS? [f] " - getresp "f" + # Give the user the opportunity to extract more sets. They + # don't necessarily have to come from the same media. + echo "" + echo -n "Extract more sets? [n] " + getresp "n" case "$resp" in - f*|F*) - install_ftp - ;; - - t*|T*) - install_tape - ;; - - c*|C*) - install_cdrom - ;; - - n*|N*) - install_nfs + y*|Y*) + # Force loop to repeat + resp="" ;; *) - echo "Invalid response: $resp" - resp="" ;; esac - else - _yup="FALSE" # So we'll ask next time - fi - - # Give the user the opportunity to extract more sets. They don't - # necessarily have to come from the same media. - echo "" - echo -n "Extract more sets? [n] " - getresp "n" - case "$resp" in - y*|Y*) - # Force loop to repeat - resp="" - ;; - - *) - ;; - esac -done + done } munge_fstab() { local _fstab local _fstab_shadow + local _dev + local _mp + local _fstype + local _rest + # Now that the 'real' fstab is configured, we munge it into a 'shadow' # fstab which we'll use for mounting and unmounting all of the target # filesystems relative to /mnt. Mount all filesystems. _fstab=$1 _fstab_shadow=$2 - awk '{ - if ($2 == "/") - printf("%s /mnt %s %s %s %s\n", $1, $3, $4, $5, $6) + ( while read _dev _mp _fstype _rest; do + # Skip comment lines + case "$_dev" in + \#*) continue;; + *) ;; + esac + # and some filesystem types (like there are swap,kernfs,...) + case "$_fstype" in + ffs|ufs|nfs) ;; + *) continue;; + esac + if [ "$_mp" = "/" ]; then + echo $_dev /mnt $_fstype $_rest else - printf("%s /mnt%s %s %s %s %s\n", $1, $2, $3, $4, $5, $6) - }' < $_fstab > $_fstab_shadow + echo $_dev /mnt$_mp $_fstype $_rest + fi + done ) < $_fstab > $_fstab_shadow } mount_fs() @@ -910,10 +1215,11 @@ mount_fs() _fstab=$1 ( while read line; do - _dev=`echo $line | awk '{print $1}'` - _mp=`echo $line | awk '{print $2}'` - _fstype=`echo $line | awk '{print $3}'` - _opt=`echo $line | awk '{print $4}'` + set -- $line + _dev=$1 + _mp=$2 + _fstype=$3 + _opt=$4 # If not the root filesystem, make sure the mount # point is present. @@ -943,24 +1249,40 @@ __mount_filesystems_1 unmount_fs() { # Unmount all filesystems and check their integrity. - # $1 is a file in fstab format + # Usage: [-fast] <fstab file> + local _fast local _fstab + local _pid - _fstab=$1 + if [ "$1" = "-fast" ]; then + _fast=1 + _fstab=$2 + else + _fast=0 + _fstab=$1 + fi + + if [ ! \( -f $_fstab -a -s $_fstab \) ]; then + echo "fstab empty" > /dev/tty + return + fi - echo -n "Syncing disks..." - pid=`twiddle` - sync; sleep 4; sync; sleep 2; sync; sleep 2 - kill $pid - echo "done." + if [ $_fast = 0 ]; then + echo -n "Syncing disks..." + _pid=`twiddle` + sync; sleep 4; sync; sleep 2; sync; sleep 2 + kill $_pid + echo "done." + fi ( _devs="" _mps="" # maintain reverse order while read line; do - _devs="`echo $line | awk '{print $1}'` ${_devs}" - _mps="`echo $line | awk '{print $2}'` ${_mps}" + set -- $line + _devs="$1 ${_devs}" + _mps="$2 ${_mps}" done echo -n "Umounting filesystems... " for _mp in ${_mps}; do @@ -969,6 +1291,9 @@ unmount_fs() done echo "Done." + if [ $_fast = 0 ]; then + exit + fi echo "Checking filesystem integrity..." for _dev in ${_devs}; do echo "${_dev}" @@ -990,8 +1315,9 @@ check_fs() _devs="" _mps="" while read line; do - _devs="`echo $line | awk '{print $1}'` ${_devs}" - _mps="`echo $line | awk '{print $2}'` ${_mps}" + set -- $line + _devs="$1 ${_devs}" + _mps="$2 ${_mps}" done echo "Checking filesystem integrity..." |