summaryrefslogtreecommitdiff
path: root/distrib/miniroot
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-05-06 01:00:15 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-05-06 01:00:15 +0000
commitd2d02591f73007145827efe56a9850d7315fa375 (patch)
tree01eeda9152e882d9fe74d6f9fa6ac81edb7800ed /distrib/miniroot
parent5d2f74cc38c217e87db8f031adc363d6121d8629 (diff)
De-uglify disk configuration in the non-auto layout cases. Trust
disklabel(8) to prevent duplicate mount points, and the user to enter all their mountpoint info in disklabel(8). Proceed directly to disk formatting after the last disk is configured. Do not pass go. ok deraadt@
Diffstat (limited to 'distrib/miniroot')
-rw-r--r--distrib/miniroot/install.sh101
-rw-r--r--distrib/miniroot/install.sub30
2 files changed, 15 insertions, 116 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index 2e7c47fe17b..c47b30eb08a 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sh,v 1.182 2009/05/05 00:38:02 deraadt Exp $
+# $OpenBSD: install.sh,v 1.183 2009/05/06 01:00:14 krw Exp $
# $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -84,7 +84,7 @@ if [[ ! -f /etc/fstab ]]; then
else
# Force the user to think and type in a disk name by
# making 'done' the default choice.
- ask_which "disk" "do you wish to initialize" "$_DKDEVS" done "No more disks to initialize"
+ ask_which "disk" "do you wish to initialize" "$_DKDEVS" done
[[ $resp == done ]] && break
fi
@@ -100,7 +100,7 @@ if [[ ! -f /etc/fstab ]]; then
md_prep_disklabel $DISK
# Get the lists of BSD and swap partitions.
- unset _partitions _psizes _mount_points
+ unset _partitions _mount_points
_i=0
disklabel $DISK 2>&1 | sed -ne '/^ *[a-p]: /p' >/tmp/disklabel.$DISK
while read _dev _size _offset _type _rest; do
@@ -119,22 +119,12 @@ if [[ ! -f /etc/fstab ]]; then
fi
_partitions[$_i]=$_pp
- _psizes[$_i]=$_size
# Set _mount_points[$_i].
- if [[ -f /tmp/fstab.$DISK ]]; then
- while read _pp _mp _rest; do
- [[ $_pp == "/dev/${_partitions[$_i]}" ]] || continue
- # Ignore mount points that have already been specified.
- [[ -n $(grep " $_mp\$" $FILESYSTEMS) ]] && break
- isin $_mp ${_mount_points[*]} && break
- # Ignore '/' for any partition but ROOTDEV. Check just
- # in case ROOTDEV isn't first partition processed.
- [[ $_mp == '/' ]] && break
- # Otherwise, record user specified mount point.
- _mount_points[$_i]=$_mp
- done </tmp/fstab.$DISK
- fi
+ while read _pp _mp _rest; do
+ [[ $_pp == /dev/${_partitions[$_i]} ]] && \
+ { _mount_points[$_i]=$_mp ; break ; }
+ done </tmp/fstab.$DISK
: $(( _i += 1 ))
done </tmp/disklabel.$DISK
@@ -147,83 +137,20 @@ if [[ ! -f /etc/fstab ]]; then
# If there are no BSD partitions go on to next disk.
(( ${#_partitions[*]} > 0 )) || continue
- # Now prompt the user for the mount points.
+ # Ignore mount points that have already been specified.
_i=0
- while :; do
- _pp=${_partitions[$_i]}
+ while (( _i < ${#_mount_points[*]} )); do
_mp=${_mount_points[$_i]}
- _size=$(stdsize ${_psizes[$_i]})
-
- if [[ $AUTOROOT == y ]]; then
- # No need to disturb the user.
- resp=""
- else
- # Get the mount point from the user.
- ask "Mount point for $_pp ($_size)? (or 'none' or 'done')" "$_mp"
- fi
-
- case $resp in
- "") ;;
- none) _mp=
- ;;
- done) break
- ;;
- /*) set -- $(grep " $resp\$" $FILESYSTEMS)
- _pp=$1
- if [[ -z $_pp ]]; then
- # Mount point wasn't specified on a
- # previous disk. Has it been specified
- # on this one?
- _j=0
- for _pp in ${_partitions[*]} ""; do
- if [[ $_i -ne $_j ]]; then
- [[ $resp == ${_mount_points[$_j]} ]] && break
- fi
- : $(( _j += 1 ))
- done
- fi
- if [[ -n $_pp ]]; then
- echo "Invalid response: $_pp is already being mounted at $resp."
- continue
- fi
- _mp=$resp
- ;;
- *) echo "Invalid response: mount point must be an absolute path!"
- continue
- ;;
- esac
+ grep -q " $_mp$" $FILESYSTEMS && continue
- _mount_points[$_i]=$_mp
+ # Append mount information to $FILESYSTEMS
+ _pp=${_partitions[$_i]}
+ echo "$_pp $_mp" >>$FILESYSTEMS
: $(( _i += 1))
- if [[ $_i -ge ${#_partitions[*]} ]]; then
- [[ $AUTOROOT == y ]] && break
- _i=0
- fi
- done
-
- # Append mount information to $FILESYSTEMS
- _i=0
- for _pp in ${_partitions[*]}; do
- _mp=${_mount_points[$_i]}
- [ "$_mp" ] && echo "$_pp $_mp" >>$FILESYSTEMS
- : $(( _i += 1 ))
done
done
- if [[ $AUTOROOT == n ]]; then
- cat <<__EOT
-
-OpenBSD filesystems:
-$(<$FILESYSTEMS)
-
-The next step *DESTROYS* all existing data on these partitions!
-__EOT
-
- ask_yn "Are you really sure that you're ready to proceed?"
- [[ $resp == n ]] && { echo "Ok, try again later." ; exit ; }
- fi
-
# Read $FILESYSTEMS, creating a new filesystem on each listed
# partition and saving the partition and mount point information
# for subsequent sorting by mount point.
@@ -239,7 +166,7 @@ __EOT
: $(( _i += 1 ))
done <$FILESYSTEMS
- # Write fstab entries to /tmp/fstab in mount point alphabetic order
+ # Write fstab entries to /tmp/fstab in mount point alphabetic order
# to enforce a rational mount order.
for _mp in $(bsort ${_mount_points[*]}); do
_pp=${_mp##*!}
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index d6597cc032e..08df8d10dd9 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.530 2009/05/05 21:26:09 deraadt Exp $
+# $OpenBSD: install.sub,v 1.531 2009/05/06 01:00:14 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -218,34 +218,6 @@ mount_mnt2() {
mount -o ro,$_opts /dev/$_dev$resp /mnt2
}
-# Translate block count into human readable byte count.
-# N.B.: Assumes blocks being counted are 512 bytes!
-# N.B.: ksh arithmetic is 32 bits so can't just calculate!
-stdsize () {
- local _p= _s= _sz=$1
-
- set -- " " K M G T P E Z Y
-
- while (( ${#_sz} > 4 )); do
- shift
- _p=${_sz%[0-9][0-9][0-9]}
- _s=${_sz#$_p}
- _s=${_s##+(0)}
- _sz=$_p
- done
-
- _sz=$(( _sz * 512))
- if (( ${#_sz} > 3 )); then
- shift
- _p=${_sz%[0-9][0-9][0-9]}
- _s=${_sz#$_p}
- _s=${_s##+(0)}
- _sz=$_p
- fi
-
- echo "${_sz} ${1}Bytes"
-}
-
# Ask for a password, saving the input in $resp.
# Display $1 as the prompt.
# *Don't* allow the '!' options that ask does.