summaryrefslogtreecommitdiff
path: root/distrib/miniroot
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2002-07-13 16:32:14 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2002-07-13 16:32:14 +0000
commitbbd71b0dcf62719b75605f8296564804f3cbd11f (patch)
treea7aa27bc2234c79a482f2b04ba39d7ee253c2b99 /distrib/miniroot
parent269b2e7d97a268a0c392a85d7533cbe23efb8da5 (diff)
Cleanup/Shrinkage.
1) Eliminate more if's in favour of 'cond || stmt' or 'cond && stmt' constructs. 2) Global _didnet -> DIDNET, make local _nam a local. 3) Display 'DHCP not supported' error every time user specifies 'dhcp' but the client is not present. 4) if if_extra is empty, that's ok, so just assign $resp to it whether $resp is empty or not. 5) Check for DIDNET inside donetconfig() instead of before each call to donetconfig. 6) Eliminate superfluous 'Aborting' comments, and let the user draw their own conclusion from getting the 'Extract more sets' message. 7) Minor code tweaks like not continually assigning $resp to a value in a loop, when all we want is the final value, and only displaying 'Skipping' message in tape installs if we are actually skipping files, etc.
Diffstat (limited to 'distrib/miniroot')
-rw-r--r--distrib/miniroot/install.sh6
-rw-r--r--distrib/miniroot/install.sub73
2 files changed, 32 insertions, 47 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index 33978852ca1..04e28790d1a 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: install.sh,v 1.106 2002/07/13 13:18:05 krw Exp $
+# $OpenBSD: install.sh,v 1.107 2002/07/13 16:32:13 krw Exp $
# $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $
#
# Copyright (c) 1997-2002 Todd Miller, Theo de Raadt, Ken Westerback
@@ -90,9 +90,7 @@ if [ -f /etc/fstab ]; then
else
# Install the shadowed disktab file; lets us write to it for temporary
# purposes without mounting the miniroot read-write.
- if [ -f /etc/disktab.shadow ]; then
- cp /etc/disktab.shadow /tmp/disktab.shadow
- fi
+ [ -f /etc/disktab.shadow ] && cp /etc/disktab.shadow /tmp/disktab.shadow
while : ; do
if [ -z "$ROOTDISK" ]; then
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index bf23bbde21e..506b53649fe 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.246 2002/07/13 13:18:05 krw Exp $
+# $OpenBSD: install.sub,v 1.247 2002/07/13 16:32:13 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2002 Todd Miller, Theo de Raadt, Ken Westerback
@@ -511,25 +511,20 @@ configure_ifs() {
_if_ip=$2
_if_mask=$3
- if [ $_up = "UP" ]; then
- ifconfig $_if_name delete down
- fi
+ [ $_up = "UP" ] && ifconfig $_if_name delete down
- if [ ! -x /sbin/dhclient ]; then
- echo "DHCP install not supported\n"
- else
- _dhcp_prompt=" (or 'dhcp')"
- fi
+ [ -x /sbin/dhclient ] && _dhcp_prompt=" (or 'dhcp')"
# Get IP address
resp=
while [ -z "$resp" ] ; do
ask "IP address${_dhcp_prompt}?" "$_if_ip"
if [ ! -x /sbin/dhclient -a "$resp" == "dhcp" ]; then
+ echo "DHCP is not supported."
resp=
fi
- _if_ip=$resp
done
+ _if_ip=$resp
# Get symbolic name
_hostname=`hostname`
@@ -559,10 +554,8 @@ __EOT
If the default is not satisfactory, and you wish to use another
media, copy that line from above (e.g. "media 100baseTX")
__EOT
- ask "Media directives?" "$_if_extra"
- if [ "$resp" ]; then
- _if_extra=$resp
- fi
+ ask "Media directives?"
+ _if_extra=$resp
fi
# Configure the interface. If it
@@ -669,7 +662,7 @@ enable_network() {
hostname=`cat /etc/myname`
hostname $hostname
- _didnet=1
+ DIDNET=y
# set the address for the loopback interface
ifconfig lo0 inet localhost
@@ -896,12 +889,12 @@ __EOT
get_get_files () {
local _files=$1 _src=$2
+ GET_FILES=
+
get_sets "$_files" "$_src"
[ "$SETS" ] || return
- GET_FILES=
-
cat << __EOT
You will now be asked which sets to ${MODE}. Some of these sets are required
@@ -914,9 +907,7 @@ __EOT
# $SETS contains only .tgz and .tar.gz file names and 'bsd'.
case $_f in
base*|bsd|comp*|etc*|game*|man*|misc*)
- if ! isin ${_f} ${SETSDONE}; then
- GET_FILES=`addel ${_f} ${GET_FILES}`
- fi
+ isin $_f $SETSDONE || GET_FILES=`addel $_f $GET_FILES`
;;
esac
done
@@ -989,7 +980,7 @@ encode_for_url() {
install_url() {
local _f _file_list _url_type=$1 _url_base _url_login _url_pass _oifs
- [ "$_didnet" ] || donetconfig
+ donetconfig
cat << __EOT
@@ -1195,7 +1186,7 @@ __EOT
echo "I/O error accessing $_drive; retrying"
sleep 10
else
- echo "Cannot access $_drive. Aborting."
+ echo "Cannot access $_drive."
return
fi
else
@@ -1250,7 +1241,7 @@ __EOT
# Mount the CD-ROM
if ! mount -t ${_fstype} -o ro /dev/${_drive}${_part} /mnt2 ; then
- echo "Cannot mount CD-ROM drive. Aborting."
+ echo "Cannot mount CD-ROM drive."
return
fi
@@ -1348,7 +1339,7 @@ __EOT
# Mount the disk read-only
if ! mount $_fstype -o ro,$_fsopts /dev/${_drive}${_partition} /mnt2; then
- echo "Cannot mount disk. Aborting."
+ echo "Cannot mount disk."
return 1
fi
@@ -1369,7 +1360,7 @@ install_nfs() {
return
fi
- [ "$_didnet" ] || donetconfig
+ donetconfig
# Get the IP address of the server
ask_until "Server IP address or hostname?" "$_nfs_server_ip"
@@ -1390,7 +1381,7 @@ install_nfs() {
# Mount the server
if ! mount_nfs $_nfs_tcp -o ro ${_nfs_server_ip}:${_nfs_server_path} /mnt2 ; then
- echo "Cannot mount NFS server. Aborting."
+ echo "Cannot mount NFS server."
return
fi
@@ -1412,16 +1403,14 @@ __EOT
TAPE=/dev/${resp##*/}
if [ ! -c $TAPE ]; then
echo "$TAPE does not exist or is not a character special file."
- echo "Aborting."
return
fi
export TAPE
# Rewind the tape device
- echo -n "Rewinding tape..."
+ echo -n "Rewinding ${TAPE} (mt rewind)..."
if ! mt rewind ; then
- echo "$TAPE may not be attached to the system or may not be"
- echo "a tape device. Aborting."
+ echo "FAILED."
return
fi
echo "done."
@@ -1441,14 +1430,14 @@ __EOT
done
# Skip to correct file.
- echo -n "Skipping to source file..."
if [ $_nskip -ne 0 ]; then
+ echo -n "Skipping to source file (mt fsf ${_nskip})..."
if ! mt fsf $_nskip ; then
- echo "Could not skip $_nskip files. Aborting."
+ echo "FAILED. Could not skip $_nskip files."
return
fi
+ echo "done."
fi
- echo "done."
cat << __EOT
@@ -1666,9 +1655,7 @@ munge_fstab() {
_opt="$(echo ${_opt} | \
sed -e 's/^softdep$//; s/^softdep,//; s/,softdep,/,/; s/,softdep$//;')"
- if [ "$_mp" = "/" ]; then
- _mp=
- fi
+ [ "$_mp" = "/" ] && _mp=
echo $_dev /mnt$_mp $_fstype $_opt $_rest
done < /tmp/fstab > /etc/fstab
@@ -1688,9 +1675,7 @@ mount_fs() {
while read _dev _mp _fstype _opt _rest; do
# If not the root filesystem, make sure the mount
# point is present.
- if [ "$_mp" != "/mnt" ]; then
- mkdir -p $_mp
- fi
+ [ "$_mp" = "/mnt" ] || mkdir -p $_mp
# Mount the filesystem. If the mount fails, exit.
if ! mount -v -t $_fstype $_async -o $_opt $_dev $_mp ; then
@@ -1792,12 +1777,14 @@ get_fqdn() {
}
donetconfig() {
- _didnet=1
+ local _nam
+
+ [ "$DIDNET" ] && return
+
+ DIDNET=y
_nam=
- if [ -f /tmp/myname ]; then
- _nam=`cat /tmp/myname`
- fi
+ [ -f /tmp/myname ] && _nam=`cat /tmp/myname`
ask_until "Enter system hostname (short form, e.g. 'foo'):" "$_nam"
hostname $resp