summaryrefslogtreecommitdiff
path: root/distrib/miniroot
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2002-04-09 01:01:20 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2002-04-09 01:01:20 +0000
commit44d60a2d3497543c1b58ab515848b5ba597d73a3 (patch)
tree309fb2bdbfd127e93378c3b9ca2e86c37147eb85 /distrib/miniroot
parenta08ef1f48b2a18b491ed4ad6a97c024f76154108 (diff)
More reorganizations, fixes and shrinkage.
a) Make [ -z "$var" ] standard idiom, replacing many variants on [ X"$var" = X"" ]. b) Factor out three large chunks of repeated code for finding sets, getting user to select sets and then installing the sets. This creates get_sets_list(), get_get_files_list() and install_get_files_list(). c) Eliminate unneeded dir_has_sets() function. d) Indent last large functions that were not properly indented. e) Replace most if not all 'test' invocations with [], replacing a few if statements along the way. f) Use ${MODE} a lot more to make messages appear more relevant to process. g) Fix erroneous display of $local_sets_dir so the error for a non-existant dir actually displays the user input, not an empty string. h) Eliminate the 'list' option in selecting sets. It was not possible to actually select anything except what was already displayed, so bring verbiage and options into line with code. i) Replace a number of '\"' and "\'" with just plain 's or "s as appropriate. j) Replace ". " with ". ". k) Use some more "OpenBSD {$VERSION_MAJOR}.${VERSION_MINOR}" to make more messages correct and current. l) Various typos fixed. Net shrinkage approximately 2K. ok millert@ deraadt@
Diffstat (limited to 'distrib/miniroot')
-rw-r--r--distrib/miniroot/install.sh20
-rw-r--r--distrib/miniroot/install.sub1655
-rw-r--r--distrib/miniroot/upgrade.sh22
3 files changed, 813 insertions, 884 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index 98b5d401f0c..bb1f9e058fc 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: install.sh,v 1.92 2002/04/05 02:51:59 krw Exp $
+# $OpenBSD: install.sh,v 1.93 2002/04/09 01:01:19 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
@@ -107,7 +107,7 @@ if [ ! -f /etc/fstab ]; then
fi
# Deal with disklabels, including editing the root disklabel
- # and labeling additional disks. This is machine-dependent since
+ # and labeling additional disks. This is machine-dependent since
# some platforms may not be able to provide this functionality.
md_prep_disklabel ${DISK}
@@ -118,7 +118,7 @@ if [ ! -f /etc/fstab ]; then
You will now have the opportunity to enter filesystem information for ${DISK}.
You will be prompted for the mount point (full path, including the prepending
-'/' character) for each BSD partition on ${DISK}. Enter "none" to skip a
+'/' character) for each BSD partition on ${DISK}. Enter "none" to skip a
partition or "done" when you are finished.
__EOT
@@ -152,7 +152,7 @@ __EOT
_npartitions=$(( ${_npartitions} + 1 ))
done
- # Now prompt the user for the mount points. Loop until "done"
+ # Now prompt the user for the mount points. Loop until "done"
echo
_i=0
resp=X
@@ -187,7 +187,7 @@ __EOT
# Now write it out
_i=0
- while test $_i -lt $_npartitions; do
+ while [ $_i -lt $_npartitions ] ; do
if [ -n "${_mount_points[${_i}]}" ]; then
echo "${DISK}${_partitions[${_i}]} ${_mount_points[${_i}]}" >> ${FILESYSTEMS}
_mount_points[${_i}]=
@@ -242,7 +242,7 @@ fi
# root filesystem later.
cat << __EOT
-You will now be given the opportunity to configure the network. This will be
+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, HTTP, or NFS.
Even if you choose not to transfer installation sets that way, this information
will be preserved and copied into the new root filesystem.
@@ -290,7 +290,7 @@ echo '\nPlease enter the initial password that the root account will have.'
_oifs=$IFS
IFS=
resp=
-while [ "X${resp}" = X"" ]; do
+while [ -z "$resp" ]; do
echo -n "Password (will not echo): "
stty -echo
getresp -n
@@ -323,8 +323,10 @@ if [ -f /etc/dhclient.conf ]; then
cat /etc/dhclient.conf >> /mnt/etc/dhclient.conf
echo "lookup file bind" > /mnt/etc/resolv.conf.tail
cp /var/db/dhclient.leases /mnt/var/db/.
- # Don't install mygate for dhcp installations
- cfgfiles=`echo $cfgfiles | sed -e 's/ mygate//'`
+ # Don't install mygate for dhcp installations.
+ # Note that mygate should not be the first or last file
+ # in cfgfiles or this won't work.
+ cfgfiles=`echo $cfgfiles | sed -e 's/ mygate / /'`
echo "done."
fi
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 5270322dc4e..ab683287252 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: install.sub,v 1.199 2002/04/05 23:44:54 krw Exp $
+# $OpenBSD: install.sub,v 1.200 2002/04/09 01:01:19 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
@@ -95,10 +95,10 @@ getresp() {
set -o noglob
valid=
- while [ "X$valid" = "X" ]; do
+ while [ -z "$valid" ]; do
read resp
if [ ${_no_shell} -eq 1 ]; then
- test -z "$resp" && resp=$1
+ [ -z "$resp" ] && resp=$1
else
case $resp in
"") resp=$1
@@ -118,7 +118,7 @@ getresp() {
}
isin() {
-# test the first argument against the remaining ones, return success on a match
+ # test the first argument against the remaining ones, return success on a match
local _a=$1
shift
@@ -130,8 +130,8 @@ isin() {
}
addel() {
-# add first argument to list formed by the remaining arguments
-# adds to the tail if the element does not already exist
+ # add first argument to list formed by the remaining arguments
+ # adds to the tail if the element does not already exist
local _a=$1 _seen=
shift
@@ -142,13 +142,13 @@ addel() {
fi
shift
done
- if [ "X$_seen" = "X" ]; then
+ if [ -z "$_seen" ]; then
echo "$_a"
fi
}
rmel() {
-# remove first argument from list formed by the remaining arguments
+ # remove first argument from list formed by the remaining arguments
local _a=$1
shift
@@ -161,7 +161,7 @@ rmel() {
}
cutword () {
-# read lines on stdin, return Nth element of each line, like cut(1)
+ # read lines on stdin, return Nth element of each line, like cut(1)
local _a _n _oifs=$IFS
# optional field separator
@@ -172,14 +172,14 @@ cutword () {
_n=$1
while read _a; do
set -- $_a
- test -z "$1" && break
+ [ -z "$1" ] && break
eval echo \$$_n
done
IFS=$_oifs
}
cutlast () {
-# read a line of data, return last element. Equiv. of awk '{print $NF}'.
+ # read a line of data, return last element. Equiv. of awk '{print $NF}'.
local _a _oifs=$IFS
# optional field separator
@@ -189,13 +189,13 @@ cutlast () {
read _a; set -- $_a
IFS=$_oifs
- if [ "$1" = "" ]; then return; fi
+ [ -z "$1" ] && return
while [ "$#" -gt 10 ]; do shift 10; done
eval echo \$$#
}
firstchar () {
-# return first character of argument
+ # return first character of argument
local _a=$1
while [ ${#_a} != 1 ]; do
@@ -207,7 +207,7 @@ firstchar () {
basename () {
local _oifs
- if [ "$1" = "" ]; then return; fi
+ [ -z "$1" ] && return
_oifs=$IFS
IFS=/
set -- $1
@@ -264,53 +264,32 @@ bsort() {
# for cutlast or cutword, by outputting blanks only when $_l
# has values to sort.
- if [[ "X$_l" != "X" ]] ; then
+ if [[ -n "$_l" ]] ; then
echo -n " "
bsort $_l
fi
}
-dir_has_sets() {
- # return true when the directory $1 contains a set for $2...$n
- local _dir=$1 _file
-
- shift
- for _file in $*
- do
- if [ -f "$_dir/${_file}${VERSION}.tar.gz" ]; then
- return 0
- fi
- # Try for stupid msdos convention
- if [ -f "$_dir/${_file}${VERSION}.tgz" ]; then
- return 0
- fi
- # Special check for kernel
- if [ $_file = "kernel" -a -f "$_dir/bsd" ]; then
- return 0
- fi
- done
- return 1
-}
-
list_has_sets() {
- # return true when the list $1 contains a set, given dir $2 for $3...$n
- local _list=$1 _file
+ # return true when the list $1 contains a set also in one of $2 ... $n
+ local _list=$1 _f
shift
- for _file in $*
+ for _f in $*
do
- if isin ${_file}${VERSION}.tar.gz $_list; then
+ if isin ${_f}${VERSION}.tar.gz $_list; then
return 0
fi
# Try for stupid msdos convention
- if isin ${_file}${VERSION}.tgz $_list; then
+ if isin ${_f}${VERSION}.tgz $_list; then
return 0
fi
# Special check for kernel
- if test $_file = "kernel" && isin bsd $_list; then
+ if [ "$_f" = "kernel" ] && isin bsd $_list; then
return 0
fi
done
+
return 1
}
@@ -347,32 +326,32 @@ get_localdir() {
esac
fi
- if dir_has_sets "$_mp/$_dir" $THESETS
+ if list_has_sets "`ls -l ${_mp}/${_dir}`" $THESETS
then
local_sets_dir=$_mp/$_dir
break
- else
- cat << __EOT
-The directory \"$local_sets_dir\" does not exist, or does not hold any of the
-upgrade sets.
-__EOT
- echo -n "Re-enter pathname? [y] "
- getresp y
- case $resp in
- y*|Y*) ;;
- *) local_sets_dir=
- break
- ;;
- esac
fi
+
+ cat << __EOT
+The directory "${_mp}/${_dir}" does not exist, or does not hold any
+OpenBSD ${VERSION_MAJOR}.${VERSION_MINOR} ${MODE} sets.
+__EOT
+ echo -n "Re-enter pathname? [y] "
+ getresp y
+ case $resp in
+ y*|Y*) ;;
+ *) local_sets_dir=
+ break
+ ;;
+ esac
done
}
getanotherdisk() {
cat << __EOT
-Now you can select another disk to initialize. (Do not re-select a disk
-you have already entered information for). Available disks are:
+Now you can select another disk to initialize. (Do not re-select a disk
+you have already entered information for). Available disks are:
$_DKDEVS
@@ -421,7 +400,7 @@ addhostent() {
# $1 - IP address
# $2 - symbolic name
- # Create an entry in the hosts file. If an entry with the
+ # Create an entry in the hosts file. If an entry with the
# same symbolic name already exists, delete it.
sed "/ $2\$/d" < /tmp/hosts > /tmp/hosts.new
@@ -463,7 +442,7 @@ marked with [X] have been successfully configured):
__EOT
for _ifs in $_IFS; do
- if [ "X${_ouranswer}" = "X" ]; then
+ if [ -z "$_ouranswer" ]; then
_ouranswer=$_ifs
fi
if isin $_ifs $_ifsdone ; then
@@ -490,7 +469,7 @@ __EOT
_ouranswer=
fi
else
- echo "Invalid response: \"$resp\" is not in list"
+ echo "Invalid response: '$resp' is not in list"
fi
_reprompt=1
;;
@@ -530,7 +509,7 @@ configure_ifs() {
# Get IP address
resp=
- while [ "X${resp}" = X"" ]; do
+ while [ -z "$resp" ] ; do
echo -n "IP address${_dhcp_prompt}? [$_if_ip] "
getresp "$_if_ip"
if [ ! -x /sbin/dhclient -a "X$resp" == "Xdhcp" ]; then
@@ -542,7 +521,7 @@ configure_ifs() {
# Get symbolic name
_hostname=`hostname`
resp=
- while [ "X${resp}" = X"" ]; do
+ while [ -z "$resp" ] ; do
echo -n "Symbolic (host) name? [$_hostname] "
getresp "$_hostname"
_if_symname=$resp
@@ -551,10 +530,10 @@ configure_ifs() {
# Get netmask
if [ "$_if_ip" != "dhcp" ]; then
resp=
- if [ "X${_if_mask}" = X"" ]; then
+ if [ -z "$_if_mask" ]; then
_if_mask=255.255.255.0
fi
- while [ "X${resp}" = X"" ]; do
+ while [ -z "$resp" ]; do
echo -n "Netmask? [$_if_mask] "
getresp "$_if_mask"
_if_mask=$resp
@@ -564,7 +543,7 @@ configure_ifs() {
if [ -n "`ifconfig -m ${_if_name} | sed -n '/media/p'`" ]; then
cat << __EOT
Your use of the network interface may require non-default
-media directives. The default media is:
+media directives. The default media is:
__EOT
ifconfig -m ${_if_name} | sed -n '
/supported/D
@@ -576,21 +555,21 @@ __EOT
/media/p'
cat << __EOT
If the default is not satisfactory, and you wish to use another
-media, copy that line from above (e.g. \"media 100baseTX\")
+media, copy that line from above (e.g. "media 100baseTX")
__EOT
echo -n "Media directives? [$_if_extra] "
getresp "$_if_extra"
- if [ "X${resp}" != X"" ]; then
+ if [ -n "$resp" ]; then
_if_extra=$resp
fi
fi
- # Configure the interface. If it
+ # Configure the interface. If it
# succeeds, add it to the permanent
# network configuration info.
if [ "$_if_ip" = "dhcp" ]; then
ifconfig ${_if_name} down ${_if_extra}
-cat > /etc/dhclient.conf << __EOT
+ cat > /etc/dhclient.conf << __EOT
initial-interval 1;
send host-name "$_hostname";
request subnet-mask, broadcast-address, routers,
@@ -704,13 +683,13 @@ enable_network() {
# Strip off /mnt/etc/hostname. prefix
if=${hn#/mnt/etc/hostname.}
- # Interface names must be alphanumeric only. We check to avoid
+ # Interface names must be alphanumeric only. We check to avoid
# configuring backup or temp files, and to catch the "*" case.
if ! isalphanumeric "$if"; then
continue
fi
ifconfig $if > /dev/null 2>&1
- if [ "$?" != "0" ]; then
+ if [ $? -ne 0 ]; then
continue
fi
@@ -843,13 +822,13 @@ get_selection() {
esac
}
-# Do globbing on the selection and parse +/-, sets _get_files and _setsdone
-# (which must exist in the local namespace) as side effects.
+# Do globbing on the selection and parse +/-, sets the global
+# _get_files and _setsdone appropriately.
glob_selection() {
- local _selection=$1 _parent_dir=$2 _sets=$3
+ local _selection=$1 _src=$2 _sets=$3
local _action _matched _tfile _f
- if [ "X${_selection}" = X"" ]; then
+ if [ -z "$_selection" ]; then
return
fi
@@ -898,8 +877,11 @@ __EOT
if [ $_matched -eq 0 ]; then
cat << __EOT
-File $_parent_dir/$_selection does not exist. Check to make
-sure you entered the information properly or enter 'list' for a file list.
+The file
+
+ '${_src}/${_selection}'
+
+does not exist. Check to make sure you entered the name properly.
__EOT
fi
}
@@ -917,9 +899,9 @@ __EOT
display_selection_msg() {
cat << __EOT
-The following sets are available. Enter a filename, 'list' for a list of
-all files, 'all' to select all the sets, or 'done'. You may de-select
-a set by prepending a '-' to its name.
+The following sets are available. Enter a filename, 'all' to select
+all the sets, or 'done'. You may de-select a set by prepending a '-'
+to its name.
__EOT
}
@@ -928,16 +910,162 @@ display_extract_msg() {
cat << __EOT
-You will now be asked for files to extract. In addition to the files
-listed, you may select any .tgz or .tar.gz archive located at
+You will now be asked which sets to ${MODE}. Some of these sets are required
+for your ${MODE} and some are optional. You will want at least the
+base and bsd sets. Consult the installation notes if you are not sure
+which sets are required!
+__EOT
+
+}
+
+# Set global _sets to either
+# 1) a list of sets found in both $1 and $THESETS, where
+# $2 is the location that generated the list of files in $1.
+# or
+# 2) a list of .tgz or .tar.gz files found in $2
+
+get_sets_list () {
+ local _f _file_list=$1 _src=$2
+
+ _sets=
+
+ for _f in $THESETS ; do
+ if [ "X${_f}" = "Xkernel" ]; then
+ if isin bsd $_file_list; then
+ _sets="$_sets bsd"
+ fi
+ elif isin ${_f}${VERSION}.tar.gz $_file_list; then
+ _sets="$_sets ${_f}${VERSION}.tar.gz"
+ elif isin ${_f}${VERSION}.tgz $_file_list; then
+ _sets="$_sets ${_f}${VERSION}.tgz"
+ fi
+ done
- $1
+ if [ -z "$_sets" ]; then
+ cat << __EOT
+The directory
-Some of these sets are required for your ${MODE} and some are
-optional. You will want at least the base and bsd sets. Consult the
-installation notes if you are not sure which sets are required!
+ '${_src}'
+
+contains no OpenBSD ${VERSION_MAJOR}.${VERSION_MINOR} ${MODE} sets.
__EOT
+ echo -n "Search for other *.tar.gz and *.tgz files? [y] "
+ getresp y
+ case $resp in
+ n*|N*) return ;;
+ esac
+ # *.tar.gz and *.tgz are possible sets
+ for _f in $_file_list ; do
+ case $_f in
+ *.tar.gz|*.tgz) _sets="$_sets ${_f}"
+ esac
+ done
+ fi
+ if [ -z "$_sets" ]; then
+ eval echo "There are no *.tar.gz or *.tgz files in ${_src}."
+ echo -n "See a directory listing? [y] "
+ getresp y
+ case $resp in
+ n*|N*) return ;;
+ esac
+ echo "\n${_file_list}\n"
+ return
+ fi
+}
+
+# Set global _get_files to the list of sets requested by the user
+# from $1. Add this list to _setsdone after saving current value
+# of _setsdone.
+
+get_get_files_list () {
+ local _src=$1
+
+ _get_files=
+ _osetsdone=$_setsdone
+
+ # Set the default list of files
+ for _f in $_sets ; do
+ # $_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}`
+ _setsdone=`addel ${_f} ${_setsdone}`
+ fi
+ ;;
+ esac
+ done
+
+ # Allow the user to select/de-select additional sets
+ while : ; do
+
+ display_selection_msg
+
+ get_selection "$_sets"
+
+ if [ "X${resp}" = "Xdone" ]; then
+ break
+ fi
+
+ glob_selection "$resp" "$_src" "$_sets"
+ done
+}
+
+# Install the list of files in the global _get_files from the source
+# in $1, aka $2. For mounted file system installs $1==file:$2. For URL
+# installs $1 == $_url_base and $2 == $1 w/o passwords, etc.
+#
+# Return 0 if install was attempted, 1 if user aborted before install
+# was tried.
+install_get_files_list () {
+ local _f _failed_files _src=$1 _public_src=$2
+
+ echo -n "Ready to ${MODE} sets? [y] "
+ getresp y
+ case $resp in
+ y*|Y*) ;;
+ *) _setsdone=$_osetsdone
+ return 1
+ ;;
+ esac
+
+ # Install/Upgrade the sets one at a time. Keep track of which
+ # ones fail.
+ while [ -n "${_get_files}" ] ; do
+ _failed_files=
+ echo
+ for _f in $_get_files ; do
+ echo "Getting ${_f} ..."
+ case $_f in
+ *.tar.gz|*.tgz)
+ ftp ${_ftp_active} -o - -V -m "${_src}/${_f}" | tar zxpf - -C /mnt
+ ;;
+ *)
+ ftp ${_ftp_active} -o "/mnt/${_f}" -V -m "${_src}/${_f}"
+ ;;
+ esac
+ if [ $? -ne 0 ]; then
+ # Mark xfer as having failed,.
+ _setsdone=`rmel $_f $_setsdone`
+ _failed_files="${_failed_files} ${_f}"
+ fi
+ done
+
+ # Offer the option of re-fetching failed files.
+ _get_files=
+ while [ -n "${_failed_files}" ] ; do
+ display_failure_msg
+
+ get_selection "$_failed_files"
+
+ if [ "X${resp}" = X"done" ]; then
+ break
+ fi
+
+ glob_selection "$resp" "$_public_src" "$_failed_files"
+ done
+ done
}
encode_for_url() {
@@ -955,467 +1083,246 @@ encode_for_url() {
}
install_url() {
-# Get several parameters from the user, and xfer
-# files from the server.
-# Note: _ftp_server_ip, _ftp_server_dir, _ftp_server_login,
-# _ftp_server_password, and _ftp_active must be global.
-
-local _sets _kernel _f _file_list _get_files _failed_files _osetsdone
-local _url_type _url_base _url_login _url_pass _oifs
-
-# Parse arguments, shell style
-case $1 in
--ftp) _url_type=ftp ;;
--http) _url_type=http ;;
-esac
+ # Get several parameters from the user, and xfer
+ # files from the server.
+ # Note: _ftp_server_ip, _ftp_server_dir, _ftp_server_login,
+ # _ftp_server_password, and _ftp_active must be global.
-cat << __EOT
+ local _f _file_list _url_type _url_base _url_login _url_pass _oifs
+
+ # Parse arguments, shell style
+ case $1 in
+ -ftp) _url_type=ftp ;;
+ -http) _url_type=http ;;
+ esac
+
+ cat << __EOT
This is an automated ${_url_type}-based installation process. You will be asked
questions and then the files will be retrieved iteratively via ${_url_type}.
__EOT
-# Proxy the connections?
-if [ "X${_proxy_host}" = X"" ]; then
- _proxy_host=none
-fi
-echo -n "HTTP/FTP proxy URL? (e.g. \"http://proxy:8080\", or \"none\") [${_proxy_host}] "
-getresp "$_proxy_host"
-if [ "X${resp}" = X"none" ]; then
- unset _proxy_host ftp_proxy http_proxy
-else
- _proxy_host=$resp
- export ftp_proxy=${_proxy_host}
- export http_proxy=${_proxy_host}
-fi
-if [ "${_url_type}" = "ftp" -a "X$ftp_proxy" = "X" ]; then
- # Use active mode ftp? (irrelevant if using a proxy)
- case $_ftp_active in
- -A) resp=y ;;
- *) resp=n ;;
- esac
+ # Proxy the connections?
+ if [ -z "$_proxy_host" ]; then
+ _proxy_host=none
+ fi
+ echo -n "HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [${_proxy_host}] "
+ getresp "$_proxy_host"
+ if [ "X${resp}" = X"none" ]; then
+ unset _proxy_host ftp_proxy http_proxy
+ else
+ _proxy_host=$resp
+ export ftp_proxy=${_proxy_host}
+ export http_proxy=${_proxy_host}
+ fi
+ if [ "${_url_type}" = "ftp" -a -z "$ftp_proxy" ]; then
+ # Use active mode ftp? (irrelevant if using a proxy)
+ case $_ftp_active in
+ -A) resp=y ;;
+ *) resp=n ;;
+ esac
- cat << __EOT
+ cat << __EOT
By default, ftp will attempt a passive connection and fall back to a normal
-(active) connection if that doesn't work. However, there are some very
+(active) connection if that does not work. However, there are some very
old ftp servers that claim to support passive mode, but really do not.
In this case, you should explicitly request an active session.
__EOT
- echo -n "Do you want to use active ftp? [${resp}] "
- getresp "$resp"
- case $resp in
- y*|Y*) _ftp_active=-A ;;
- *) unset _ftp_active ;;
- esac
-fi
-
-# Provide a list of possible servers
-test -z "$_ftp_getlist" && _ftp_getlist=y
-echo -n "Do you want a list of potential ${_url_type} servers? [${_ftp_getlist}] "
-getresp "$_ftp_getlist"
-case $resp in
-n*|N*) _ftp_getlist=n
- ;;
-*)
- _ftp_getlist=y
- ftphost=129.128.5.191
- if [ "X${_resolver_enabled}" = X"TRUE" ]; then
- ftphost=ftp.openbsd.org
+ echo -n "Do you want to use active ftp? [${resp}] "
+ getresp "$resp"
+ case $resp in
+ y*|Y*) _ftp_active=-A ;;
+ *) unset _ftp_active ;;
+ esac
fi
- ftp ${_ftp_active} -V -a -o /tmp/ftplist ftp://${ftphost}/pub/OpenBSD/${VERSION_MAJOR}.${VERSION_MINOR}/ftplist > /dev/null
- cat /tmp/ftplist | grep "^${_url_type}:" | cat -n | less -XE
- ;;
-esac
-# Get server IP address
-resp=
-while [ "X${resp}" = X"" ]; do
- if [ -f /tmp/ftplist ]; then
- eval echo -n "Server IP address, hostname, or list#? [\$_${_url_type}_server_ip]\ "
- else
- eval echo -n "Server IP address, or hostname? [\$_${_url_type}_server_ip]\ "
- fi
- eval getresp "\$_${_url_type}_server_ip"
- if [ "X$resp" = "X?" -a -f /tmp/ftplist ]; then
+ # Provide a list of possible servers
+ [ -z "$_ftp_getlist" ] && _ftp_getlist=y
+ echo -n "Do you want a list of potential ${_url_type} servers? [${_ftp_getlist}] "
+ getresp "$_ftp_getlist"
+ case $resp in
+ n*|N*) _ftp_getlist=n
+ ;;
+ *)
+ _ftp_getlist=y
+ ftphost=129.128.5.191
+ if [ "X${_resolver_enabled}" = X"TRUE" ]; then
+ ftphost=ftp.openbsd.org
+ fi
+ ftp ${_ftp_active} -V -a -o /tmp/ftplist ftp://${ftphost}/pub/OpenBSD/${VERSION_MAJOR}.${VERSION_MINOR}/ftplist > /dev/null
cat /tmp/ftplist | grep "^${_url_type}:" | cat -n | less -XE
- resp=
- elif [ -n "$resp" \
- -a `isnumeric $resp` -eq 1 \
- -a ${resp:-0} -ge 1 \
- -a -f /tmp/ftplist ]
- then
- maxlines=`grep "^${_url_type}:" /tmp/ftplist | cat -n |
- sed -n -e '$p' | cutword 1`
- if [ $maxlines -lt $resp ]; then
- echo "There is no ${resp}th line in the list."
+ ;;
+ esac
+
+ # Get server IP address
+ resp=
+ while [ -z "$resp" ] ; do
+ if [ -f /tmp/ftplist ]; then
+ eval echo -n "Server IP address, hostname, or list#? [\$_${_url_type}_server_ip]\ "
+ else
+ eval echo -n "Server IP address, or hostname? [\$_${_url_type}_server_ip]\ "
+ fi
+ eval getresp "\$_${_url_type}_server_ip"
+ if [ "X$resp" = "X?" -a -f /tmp/ftplist ]; then
+ cat /tmp/ftplist | grep "^${_url_type}:" | cat -n | less -XE
resp=
- continue
+ elif [ -n "$resp" \
+ -a `isnumeric $resp` -eq 1 \
+ -a ${resp:-0} -ge 1 \
+ -a -f /tmp/ftplist ]
+ then
+ maxlines=`grep "^${_url_type}:" /tmp/ftplist | cat -n |
+ sed -n -e '$p' | cutword 1`
+ if [ $maxlines -lt $resp ]; then
+ echo "There is no ${resp}th line in the list."
+ resp=
+ continue
+ fi
+ tline=`grep "^${_url_type}:" /tmp/ftplist | sed -n -e "${resp}p"`
+ url=`echo $tline | sed -e "s/^${_url_type}:\/\///" |
+ cutword -t' ' 1 | cutword -t' ' 1`
+ host=`echo $url | cutword -t/ 1`
+ path=`echo $url | sed -e "s/^${host}\///"`
+ path=${path}/${VERSION_MAJOR}.${VERSION_MINOR}/${ARCH}
+ eval _${_url_type}_server_ip=$host
+ eval _${_url_type}_server_dir=$path
+ # do it again, just to double check
+ resp=
+ echo "Using $tline"
+ else
+ eval _${_url_type}_server_ip=$resp
fi
- tline=`grep "^${_url_type}:" /tmp/ftplist | sed -n -e "${resp}p"`
- url=`echo $tline | sed -e "s/^${_url_type}:\/\///" |
- cutword -t' ' 1 | cutword -t' ' 1`
- host=`echo $url | cutword -t/ 1`
- path=`echo $url | sed -e "s/^${host}\///"`
- path=${path}/${VERSION_MAJOR}.${VERSION_MINOR}/${ARCH}
- eval _${_url_type}_server_ip=$host
- eval _${_url_type}_server_dir=$path
- # do it again, just to double check
- resp=
- echo "Using $tline"
- else
- eval _${_url_type}_server_ip=$resp
- fi
-done
+ done
-# Get server directory
-if [ "${_url_type}" = "ftp" -a "X${_ftp_server_dir}" = X"" ]; then
- # Default ftp dir
- _ftp_server_dir=pub/OpenBSD/${VERSION_MAJOR}.${VERSION_MINOR}/${ARCH}
-fi
-resp=
-while [ "X${resp}" = X"" ]; do
- eval echo -n "Server directory? [\$_${_url_type}_server_dir]\ "
- eval getresp "\$_${_url_type}_server_dir"
- eval _${_url_type}_server_dir=$resp
-done
-
-if [ "${_url_type}" = "ftp" ]; then
- # Need default values even if we proxy ftp...
- if [ "X${_ftp_server_login}" = X"" ]; then
- _ftp_server_login=anonymous
+ # Get server directory
+ if [ "${_url_type}" = "ftp" -a -z "$_ftp_server_dir" ] ; then
+ # Default ftp dir
+ _ftp_server_dir=pub/OpenBSD/${VERSION_MAJOR}.${VERSION_MINOR}/${ARCH}
fi
- if [ "X${_ftp_server_password}" = X"" ]; then
- _ftp_server_password=root@`hostname`.${FQDN}
- fi
-
- # Get login name, setting IFS to nothing so trailing or
- # embedded blanks are preserved!
- _oifs=$IFS
- IFS=
resp=
- while [ "X${resp}" = X"" ]; do
- echo -n "Login? [${_ftp_server_login}] "
- getresp "$_ftp_server_login"
- _ftp_server_login=$resp
+ while [ -z "$resp" ] ; do
+ eval echo -n "Server directory? [\$_${_url_type}_server_dir]\ "
+ eval getresp "\$_${_url_type}_server_dir"
+ eval _${_url_type}_server_dir=$resp
done
- # Get password unless anonymous
- if [ "${_ftp_server_login}" != "anonymous" ]; then
+ if [ "${_url_type}" = "ftp" ]; then
+ # Need default values even if we proxy ftp...
+ if [ -z "$_ftp_server_login" ] ; then
+ _ftp_server_login=anonymous
+ fi
+ if [ -z "$_ftp_server_password" ] ; then
+ _ftp_server_password=root@`hostname`.${FQDN}
+ fi
+
+ # Get login name, setting IFS to nothing so trailing or
+ # embedded blanks are preserved!
+ _oifs=$IFS
+ IFS=
resp=
- while [ "X${resp}" = X"" ]; do
- echo -n "Password (will not echo): "
- stty -echo
- getresp -n "$_ftp_server_password"
- stty echo
- echo
- _ftp_server_password=$resp
+ while [ -z "$resp" ] ; do
+ echo -n "Login? [${_ftp_server_login}] "
+ getresp "$_ftp_server_login"
+ _ftp_server_login=$resp
done
- else
- # only used by ftp_list_files()
- _ftp_server_password=root@`hostname`.${FQDN}
- fi
- IFS=$_oifs
-fi
-
-# Build up the base url since it is so nasty...
-if [ "${_url_type}" = "ftp" -a "${_ftp_server_login}" != "anonymous" ]; then
- _url_login=`encode_for_url "${_ftp_server_login}"`
- _url_pass=`encode_for_url "${_ftp_server_password}"`
- _url_base=ftp://${_url_login}:${_url_pass}@${_ftp_server_ip}/${_ftp_server_dir}
-else
- eval _url_base=${_url_type}://\$_${_url_type}_server_ip/\$_${_url_type}_server_dir
-fi
-
-# Get list of files from the server.
-# XXX - check for nil $_file_list and deal
-if [ "${_url_type}" = "ftp" -a "X${ftp_proxy}" = X"" ]; then
- _file_list=`ftp_list_files "$_ftp_server_ip" "$_ftp_server_login" "$_ftp_server_password" "$_ftp_server_dir"`
-else
- # Assumes index file is "index.txt" for http (or proxy)
- # We can't use index.html since the format is server-dependent
- _file_list=`ftp -o - -V "${_url_base}/index.txt" | sed 's/ //'`
-fi
-_sets=
-if list_has_sets "$_file_list" $THESETS; then
- for _f in $THESETS ; do
- if [ "X${_f}" = "Xkernel" ]; then
- if isin bsd $_file_list; then
- _kernel=bsd
- fi
- elif isin ${_f}${VERSION}.tar.gz $_file_list; then
- _sets="$_sets ${_f}${VERSION}.tar.gz"
- elif isin ${_f}${VERSION}.tgz $_file_list; then
- _sets="$_sets ${_f}${VERSION}.tgz"
+ # Get password unless anonymous
+ if [ "${_ftp_server_login}" != "anonymous" ]; then
+ resp=
+ while [ -z "$resp" ] ; do
+ echo -n "Password (will not echo): "
+ stty -echo
+ getresp -n "$_ftp_server_password"
+ stty echo
+ echo
+ _ftp_server_password=$resp
+ done
+ else
+ # only used by ftp_list_files()
+ _ftp_server_password=root@`hostname`.${FQDN}
fi
- done
-else
- eval echo "There are no OpenBSD install sets available in \"\$_${_url_type}_server_dir\"."
- echo -n "Search for *.tar.gz and *.tgz files? [y] "
- getresp y
- case $resp in
- n*|N*) return ;;
- esac
- # *.tar.gz and *.tgz are possible sets
- _sets=
- _kernel=
- for _f in ${_file_list} ; do
- case $_f in
- *.tar.gz|*.tgz) _sets="$_sets ${_f}"
- esac
- done
- if [ "X${_sets}" = X"" ]; then
- echo "There are no *.tar.gz or *.tgz files in that dir."
- echo -n "See a directory listing? [y] "
- getresp y
- case $resp in
- n*|N*) return ;;
- esac
- echo "\n${_file_list}\n"
- return
- else
- echo "Adding *.tar.gz and *.tgz files to selector."
+ IFS=$_oifs
fi
-fi
-
- display_extract_msg "$(eval echo ${_url_type}://\$_${_url_type}_server_ip/\$_${_url_type}_server_dir)"
-
-_osetsdone=$_setsdone
-# Set the minimal default
-for _f in $_sets $_kernel; do
- # From logic above, $_sets contains only .tgz and .tar.gz
- # file names, and $_kernel is empty or 'bsd'.
- case $_f in
- base*|bsd|comp*|etc*|game*|man*|misc*)
- if ! isin ${_f} ${_setsdone}; then
- _get_files=`addel ${_f} ${_get_files}`
- _setsdone=`addel ${_f} ${_setsdone}`
- fi
- ;;
- esac
-done
-
-# Allow the user to select/de-select additional sets
-while : ; do
-
- display_selection_msg
- get_selection "$_sets $_kernel"
+ # Build up the base url since it is so nasty...
+ if [ "${_url_type}" = "ftp" -a "${_ftp_server_login}" != "anonymous" ]; then
+ _url_login=`encode_for_url "${_ftp_server_login}"`
+ _url_pass=`encode_for_url "${_ftp_server_password}"`
+ _url_base=ftp://${_url_login}:${_url_pass}@${_ftp_server_ip}/${_ftp_server_dir}
+ else
+ eval _url_base=${_url_type}://\$_${_url_type}_server_ip/\$_${_url_type}_server_dir
+ fi
- if [ "X${resp}" = X"done" ]; then
- break
- elif [ "X${resp}" = X"list" ]; then
- eval echo "\n\$_${_url_type}_server_dir:"
- echo "${_file_list}"
- continue
+ # Get list of files from the server.
+ # XXX - check for nil $_file_list and deal
+ if [ "${_url_type}" = "ftp" -a -z "$ftp_proxy" ] ; then
+ _file_list=`ftp_list_files "$_ftp_server_ip" "$_ftp_server_login" "$_ftp_server_password" "$_ftp_server_dir"`
+ else
+ # Assumes index file is "index.txt" for http (or proxy)
+ # We can't use index.html since the format is server-dependent
+ _file_list=`ftp -o - -V "${_url_base}/index.txt" | sed 's/ //'`
fi
- eval glob_selection \"$resp\" \$_${_url_type}_server_dir \"$_sets $_kernel\"
-done
+ get_sets_list "$_file_list" "`eval echo \\$_${_url_type}_server_dir`"
-# User may have said "done" without selecting any files
-if [ "X${_get_files}" = X"" ]; then
- return
-fi
+ [ -z "$_sets" ] && return
-# Stash the fact that we configured and downloaded via this url method
-eval _installed_via_${_url_type}=1
+ display_extract_msg
-echo "\nFetching files via ${_url_type} may take a long time, especially over a slow network"
-echo -n "connection. Ready to download files? [y] "
-getresp y
-case $resp in
-y*|Y*) ;;
-*) _setsdone=$_osetsdone
- return
- ;;
-esac
+ get_get_files_list "`eval echo \\$_${_url_type}_server_dir`"
-# Download the files one at a time and keep track of which ones failed
-while test -n "${_get_files}" ; do
- _failed_files=
- echo
- for _f in $_get_files ; do
- echo "Getting ${_f} ..."
- if [ "X${_f}" = "X${_kernel}" ]; then
- ( cd /mnt ; ftp ${_ftp_active} -V -m "${_url_base}/${_f}" )
- else
- ( cd /mnt ; ftp ${_ftp_active} -o - -V -m "${_url_base}/${_f}" | tar zxpf - )
- fi
- if [ $? -ne 0 ]; then
- # Mark xfer as having failed,.
- _setsdone=`rmel $_f $_setsdone`
- _failed_files="${_failed_files} ${_f}"
- fi
- done
+ # User may have selected no files
+ [ -z "$_get_files" ] && return
- # Give them the option of refetching failed files.
- _get_files=
- while test -n "${_failed_files}" ; do
- display_failure_msg
-
- get_selection "$_failed_files"
+ cat << __EOT
- if [ "X${resp}" = X"done" ]; then
- break
- elif [ "X${resp}" = X"list" ]; then
- eval echo "\n\$_${_url_type}_server_dir:"
- echo "${_file_list}\n"
- continue
- fi
+Fetching files via ${_url_type} may take a long time, especially over a slow
+network connection.
+__EOT
- eval glob_selection \"$resp\" \$_${_url_type}_server_dir \"$_failed_files\"
- done
-done
+ install_get_files_list "$_url_base" "`eval echo \$_${_url_type}_server_dir`"
+ if [ $? -eq 0 ] ; then
+ # Stash the fact that we configured and downloaded via this url method
+ eval _installed_via_${_url_type}=1
+ fi
}
install_from_mounted_fs() {
-# $1 - directory containing installation sets
-local _sets= _kernel _f _get_files _failed_files _osetsdone
+ # $1 - directory containing installation sets
+ local _f _get_files _file_list
-if [ ! -d "$1" ]; then
- echo "No such directory: '$1'"
- return
-fi
-
-if dir_has_sets "$1" $THESETS; then
- for _f in $THESETS ; do
- if [ "X${_f}" = "Xkernel" ]; then
- if [ -f "$1/bsd" ]; then
- _kernel=bsd
- fi
- elif [ -f "$1/${_f}${VERSION}.tar.gz" ]; then
- _sets="$_sets ${_f}${VERSION}.tar.gz"
- elif [ -f "$1/${_f}${VERSION}.tgz" ]; then
- _sets="$_sets ${_f}${VERSION}.tgz"
- fi
- done
-else
- echo "There are no OpenBSD install sets available in \"$1\"."
- echo -n "Search for *.tar.gz and *.tgz files? [y] "
- getresp y
- case $resp in
- n*|N*) return ;;
- esac
- # *.tar.gz and *.tgz are possible sets
- _sets=
- _kernel=
- _sets=`cd "$1" ; echo *.tar.gz *.tgz`
- if [ "X${_sets}" = X'*.tar.gz *.tgz' ]; then
- echo "There are no *.tar.gz or *.tgz files in that dir."
- echo -n "See a directory listing? [y] "
- getresp y
- case $resp in
- n*|N*) return ;;
- esac
- echo
- ( cd "$1" && ls )
- echo
+ if [ ! -d "$1" ]; then
+ echo "No such directory: '$1'"
return
- else
- echo "Adding *.tar.gz and *.tgz files to selector."
fi
-fi
-display_extract_msg "$1"
-
-_osetsdone=$_setsdone
-# Set a minimal default
-for _f in $_sets $_kernel; do
- case $_f in
- # From logic above, $_sets contains only .tgz and .tar.gz
- # file names, and $_kernel is empty or 'bsd'.
- base*|bsd|comp*|etc*|game*|man*|misc*)
- if ! isin ${_f} ${_setsdone}; then
- _get_files=`addel ${_f} ${_get_files}`
- _setsdone=`addel ${_f} ${_setsdone}`
- fi
- ;;
- esac
-done
+ _file_list=`ls -l ${1}`
-# Allow the user to select/de-select additional sets
-while : ; do
+ get_sets_list "$_file_list" "$1"
- display_selection_msg
+ [ -z "$_sets" ] && return
- get_selection "$_sets $_kernel"
+ display_extract_msg
- if [ "X${resp}" = X"done" ]; then
- break
- elif [ "X${resp}" = X"list" ]; then
- echo "\n${1}:"
- ( cd $1 && ls )
- continue
- fi
-
- glob_selection "$resp" "$1" "$_sets $_kernel"
-done
+ get_get_files_list "$1"
-# User may have said "done" without selecting any files
-if [ "X${_get_files}" = X"" ]; then
- return
-fi
+ # User may have selected no files
+ [ -z "$_get_files" ] && return
-echo -n "\nReady to extract selected file sets? [y] "
-getresp y
-case $resp in
-y*|Y*) ;;
-*) _setsdone=$_osetsdone
- return
- ;;
-esac
-
-# Extract the files one at a time and keep track of which ones failed
-while test -n "${_get_files}" ; do
- _failed_files=
- echo
- for _f in $_get_files ; do
- echo "$1/${_f}:"
- if [ "X${_f}" = "X${_kernel}" ]; then
- ftp -V -m -o /mnt/$_f file:$1/$_f
- else
- ftp -V -m -o - file:$1/$_f | (cd /mnt; tar -zxpf -)
- fi
- if [ $? -ne 0 ]; then
- # Mark xfer as having failed,.
- _setsdone=`rmel $_f $_setsdone`
- _failed_files="${_failed_files} ${_f}"
- fi
- done
-
- # Give them the option of retrying failed files.
- _get_files=
- while test -n "${_failed_files}" ; do
- display_failure_msg
-
- get_selection "$_failed_files"
-
- if [ "X${resp}" = X"done" ]; then
- break
- elif [ "X${resp}" = X"list" ]; then
- echo "\n${1}:"
- ( cd $1 && ls )
- echo
- continue
- fi
-
- glob_selection "$resp" "$1" "$_failed_files"
- done
-done
+ install_get_files_list "file:$1" "$1"
}
install_cdrom() {
-local _drive _range _part _fstype _directory _n
+ local _drive _range _part _fstype _directory _n
-# Get the cdrom device info
-if [ "X${_CDDEVS}" = X"" ]; then
- echo "No CD-ROM devices were found. Aborting."
- return
-fi
+ # Get the cdrom device info
+ if [ -z "$_CDDEVS" ]; then
+ echo "No CD-ROM devices were found. Aborting."
+ return
+ fi
-cat << __EOT
+ cat << __EOT
The following CD-ROM devices are installed on your system.
Please make sure the CD is in the CD-ROM drive and select
@@ -1424,113 +1331,116 @@ the device containing the CD with the installation sets:
$_CDDEVS
__EOT
-_drive=`echo $_CDDEVS | cutword 1`
-echo -n "Which CD-ROM contains the installation media? [$_drive] "
-getresp "$_drive"
-case $resp in
-abort) echo "Aborting."
- return
- ;;
-*) if isin $resp $_CDDEVS ; then
- _drive=$resp
- else
- echo "\nThe CD-ROM $resp does not exist.\nAborting."
- return
- fi
- ;;
-esac
-# If it is an ISO9660 CD-ROM, we don't need to ask any other questions
-_n=0
-until disklabel $_drive >/tmp/label.$_drive 2>&1; do
- # Try up to 6 times to access the CD
- if egrep -q '(Input/output error)|(sector size 0)' /tmp/label.$_drive; then
- _n=$(( $_n + 1 ))
- if [ _n -le 5 ]; then
- echo "I/O error accessing $_drive; retrying"
- sleep 10
+ _drive=`echo $_CDDEVS | cutword 1`
+ echo -n "Which CD-ROM contains the installation media? [$_drive] "
+ getresp "$_drive"
+ case $resp in
+ abort) echo "Aborting."
+ return
+ ;;
+ *) if isin $resp $_CDDEVS ; then
+ _drive=$resp
else
- echo "Cannot access $_drive. Aborting."
+ echo "\nThe CD-ROM $resp does not exist.\nAborting."
return
fi
- else
- break
- fi
-done
-echo
-if grep -q '^ *c: .*ISO9660' /tmp/label.$_drive; then
- _fstype=cd9660
- _part=c
-else
- # Get partition from user
- _range=`md_get_partition_range`
- resp=
- while [ "X${resp}" = X"" ]; do
- echo -n 'CD-ROM partition to mount? (normally "c") [c] '
- getresp c
- case $resp in
- $_range)
- _part=$resp
- ;;
- *) echo "Invalid response: $resp"
- # force loop to repeat
- resp=
- ;;
- esac
+ ;;
+ esac
+
+ # If it is an ISO9660 CD-ROM, we don't need to ask any other questions
+ _n=0
+ until disklabel $_drive >/tmp/label.$_drive 2>&1; do
+ # Try up to 6 times to access the CD
+ if egrep -q '(Input/output error)|(sector size 0)' /tmp/label.$_drive; then
+ _n=$(( $_n + 1 ))
+ if [ _n -le 5 ]; then
+ echo "I/O error accessing $_drive; retrying"
+ sleep 10
+ else
+ echo "Cannot access $_drive. Aborting."
+ return
+ fi
+ else
+ break
+ fi
done
- # Ask for filesystem type
- cat << __EOT
+ echo
+ if grep -q '^ *c: .*ISO9660' /tmp/label.$_drive; then
+ _fstype=cd9660
+ _part=c
+ else
+ # Get partition from user
+ _range=`md_get_partition_range`
+ resp=
+ while [ -z "$resp" ] ; do
+ echo -n 'CD-ROM partition to mount? (normally "c") [c] '
+ getresp c
+ case $resp in
+ $_range)
+ _part=$resp
+ ;;
+ *) echo "Invalid response: $resp"
+ # force loop to repeat
+ resp=
+ ;;
+ esac
+ done
+
+ # Ask for filesystem type
+ cat << __EOT
There are two CD-ROM filesystem types currently supported by this program:
cd9660 ISO-9660
ffs Berkeley Fast Filesystem
__EOT
- resp=
- while [ "X${resp}" = X"" ]; do
- echo -n "Which filesystem type? [cd9660] "
- getresp cd9660
- case $resp in
- cd9660|ffs)
- _fstype=$resp
- ;;
- *) echo "Invalid response: $resp"
- # force loop to repeat
- resp=
- ;;
- esac
- done
-fi
-rm -f /tmp/label.$_drive
+ resp=
+ while [ -z "$resp" ] ; do
+ echo -n "Which filesystem type? [cd9660] "
+ getresp cd9660
+ case $resp in
+ cd9660|ffs)
+ _fstype=$resp
+ ;;
+ *) echo "Invalid response: '$resp'"
+ # force loop to repeat
+ resp=
+ ;;
+ esac
+ done
+ fi
-# Mount the CD-ROM
-if ! mount -t ${_fstype} -o ro /dev/${_drive}${_part} /mnt2 ; then
- echo "Cannot mount CD-ROM drive. Aborting."
- return
-fi
+ rm -f /tmp/label.$_drive
+
+ # Mount the CD-ROM
+ if ! mount -t ${_fstype} -o ro /dev/${_drive}${_part} /mnt2 ; then
+ echo "Cannot mount CD-ROM drive. Aborting."
+ return
+ fi
-# Get the directory where the file lives
-resp=
-_directory=${VERSION_MAJOR}.${VERSION_MINOR}/${ARCH}
-echo "Enter the directory relative to the mount point that contains"
-echo -n "the file: [${_directory}] "
+ # Get the directory where the file lives
+ resp=
+ _directory=${VERSION_MAJOR}.${VERSION_MINOR}/${ARCH}
+ echo "Enter the directory relative to the mount point that contains"
+ echo -n "the file: [${_directory}] "
-getresp "$_directory"
+ getresp "$_directory"
-install_from_mounted_fs "/mnt2/${resp}"
-umount -f /mnt2 > /dev/null 2>&1
+ install_from_mounted_fs "/mnt2/${resp}"
+ 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.
+ # Mount a disk on /mnt2. The set of disk devices to choose from
+ # is $_DKDEVS.
+ # returns 0 on failure.
-local _drive _def_partition _partition_range _partition _fstype
-local _fsopts _md_fstype _md_fsopts
+ local _drive _def_partition _partition_range _partition _fstype
+ local _fsopts _md_fstype _md_fsopts
-cat << __EOT
+ cat << __EOT
The following disk devices are installed on your system; please select
the disk device containing the partition with the installation sets:
@@ -1539,106 +1449,109 @@ $_DKDEVS
__EOT
-echo -n "Which is the disk with the installation sets? [abort] "
-getresp abort
+ echo -n "Which is the disk with the installation sets? [abort] "
+ getresp abort
-case $resp in
-abort) echo "Aborting."
- return 0
- ;;
-*) if isin $resp $_DKDEVS ; then
- _drive=$resp
- else
- echo "\nThe disk $resp does not exist.\nAborting."
+ case $resp in
+ abort) echo "Aborting."
return 0
- fi
- ;;
-esac
+ ;;
+ *) if isin $resp $_DKDEVS ; then
+ _drive=$resp
+ else
+ echo "\nThe disk $resp does not exist.\nAborting."
+ return 0
+ fi
+ ;;
+ esac
-# Get partition
-cat << __EOT
+ # Get partition
+ cat << __EOT
The following partitions have been found on $_drive:
__EOT
-disklabel $_drive 2>/dev/null | grep '^ .:'
-echo
-_likely_partition_range=`disklabel $_drive 2>/dev/null | \
- sed -n -e '/swap/s/.*//' -e '/unused/s/.*//' \
- -e '/^ .:/{s/^ \(.\).*/\1/;H;}' \
- -e '${g;s/\n//g;s/^/[/;s/$/]/p;}'`
-_partition_range=`disklabel $_drive 2>/dev/null | \
- sed -n -e '/^ .:/{s/^ \(.\).*/\1/;H;}' \
- -e '${g;s/\n//g;s/^/[/;s/$/]/p;}'`
-_def_partition=`echo $_likely_partition_range | \
- sed -n 's/^\[\(.\).*\]/\1/p'`
-if [ -z "$_def_partition" ]; then
- _def_partition=`echo $_partition_range | \
+ disklabel $_drive 2>/dev/null | grep '^ .:'
+ echo
+ _likely_partition_range=`disklabel $_drive 2>/dev/null | \
+ sed -n -e '/swap/s/.*//' -e '/unused/s/.*//' \
+ -e '/^ .:/{s/^ \(.\).*/\1/;H;}' \
+ -e '${g;s/\n//g;s/^/[/;s/$/]/p;}'`
+ _partition_range=`disklabel $_drive 2>/dev/null | \
+ sed -n -e '/^ .:/{s/^ \(.\).*/\1/;H;}' \
+ -e '${g;s/\n//g;s/^/[/;s/$/]/p;}'`
+ _def_partition=`echo $_likely_partition_range | \
sed -n 's/^\[\(.\).*\]/\1/p'`
if [ -z "$_def_partition" ]; then
- echo "There are no usable partitions on that disk"
- return 0
+ _def_partition=`echo $_partition_range | \
+ sed -n 's/^\[\(.\).*\]/\1/p'`
+ if [ -z "$_def_partition" ]; then
+ echo "There are no usable partitions on that disk"
+ return 0
+ fi
fi
-fi
-resp=
-while [ "X${resp}" = X"" ]; do
- echo -n "Partition? [$_def_partition] "
- getresp "$_def_partition"
- case $resp in
- $_partition_range)
- _partition=$resp
- ;;
- *) echo "Invalid response: $resp"
- # force loop to repeat
- resp=
- ;;
- esac
-done
-# Ask for filesystem type
-cat << __EOT
+ resp=
+ while [ -z "$resp" ]; do
+ echo -n "Partition? [$_def_partition] "
+ getresp "$_def_partition"
+ case $resp in
+ $_partition_range)
+ _partition=$resp
+ ;;
+ *) echo "Invalid response: $resp"
+ # force loop to repeat
+ resp=
+ ;;
+ esac
+ done
+
+ # Ask for filesystem type
+ cat << __EOT
The following filesystem types are supported:
default (deduced from the disklabel)
ffs
__EOT
-_md_fstype=`md_native_fstype`
-_md_fsopts=`md_native_fsopts`
-if [ ! -z "$_md_fstype" ]; then
- echo " $_md_fstype"
-else
- _md_fstype=_undefined_
-fi
-resp=
-while [ "X${resp}" = X"" ]; do
- echo -n "Which filesystem type? [default] "
- getresp default
- case $resp in
- default)
- _fstype=
- _fsopts=ro
- ;;
- ffs) _fstype="-t $resp"
- _fsopts=async,ro
- ;;
- $_md_fstype)
- _fstype="-t $resp"
- _fsopts=$_md_fsopts
- ;;
- *) echo "Invalid response: $resp"
- # force loop to repeat
- resp=
- ;;
- esac
-done
-# Mount the disk
-if ! mount $_fstype -o $_fsopts /dev/${_drive}${_partition} /mnt2; then
- echo "Cannot mount disk. Aborting."
- return 0
-fi
+ _md_fstype=`md_native_fstype`
+ _md_fsopts=`md_native_fsopts`
+ if [ -n "$_md_fstype" ]; then
+ echo " $_md_fstype"
+ else
+ _md_fstype=_undefined_
+ fi
+
+ resp=
+ while [ -z "$resp" ]; do
+ echo -n "Which filesystem type? [default] "
+ getresp default
+ case $resp in
+ default)
+ _fstype=
+ _fsopts=ro
+ ;;
+ ffs) _fstype="-t $resp"
+ _fsopts=async,ro
+ ;;
+ $_md_fstype)
+ _fstype="-t $resp"
+ _fsopts=$_md_fsopts
+ ;;
+ *) echo "Invalid response: $resp"
+ # force loop to repeat
+ resp=
+ ;;
+ esac
+ done
-return 1
+ # Mount the disk
+ if ! mount $_fstype -o $_fsopts /dev/${_drive}${_partition} /mnt2; then
+ echo "Cannot mount disk. Aborting."
+ return 0
+ fi
+
+ return 1
}
install_disk() {
@@ -1658,7 +1571,7 @@ install_disk() {
install_nfs() {
# Get the IP address of the server
resp=
- while [ "X${resp}" = X"" ]; do
+ while [ -z "$resp" ] ; do
echo -n "Server IP address or hostname? [${_nfs_server_ip}] "
getresp "$_nfs_server_ip"
done
@@ -1666,7 +1579,7 @@ install_nfs() {
# Get server path to mount
resp=
- while [ "X${resp}" = X"" ]; do
+ while [ -z "$resp" ]; do
echo -n "Filesystem on server to mount? [${_nfs_server_path}] "
getresp "$_nfs_server_path"
done
@@ -1691,7 +1604,7 @@ install_nfs() {
# Get the directory where the file lives
resp=
- while [ "X${resp}" = X"" ]; do
+ while [ -z "$resp" ]; do
echo "Enter the directory relative to the mount point that"
echo -n "contains the file: [.] "
getresp
@@ -1702,63 +1615,63 @@ install_nfs() {
}
install_tape() {
-local _xcmd
+ local _xcmd
-# Get the name of the tape from the user.
-cat << __EOT
+ # Get the name of the tape from the user.
+ cat << __EOT
-The installation program needs to know which tape device to use. Make
+The installation program needs to know which tape device to use. Make
sure you use a "no rewind on close" device.
__EOT
-_tape=`basename $TAPE`
-resp=
-while [ "X${resp}" = X"" ]; do
- echo -n "Name of tape device? [${_tape}]"
- getresp "$_tape"
-done
-_tape=`basename $resp`
-TAPE=/dev/${_tape}
-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..."
-if ! mt rewind ; then
- echo "$TAPE may not be attached to the system or may not be"
- echo "a tape device. Aborting."
- return
-fi
-echo "done."
-
-# Get the file number
-resp=
-while [ "X${resp}" = X"" ]; do
- echo -n "File number? "
- getresp
- case $resp in
- [1-9]*) _nskip=$(( $resp - 1 ))
- ;;
- *) echo "Invalid file number ${resp}."
- # force loop to repeat
- resp=
- ;;
- esac
-done
+ _tape=`basename $TAPE`
+ resp=
+ while [ -z "$resp" ]; do
+ echo -n "Name of tape device? [${_tape}]"
+ getresp "$_tape"
+ done
+ _tape=`basename $resp`
+ TAPE=/dev/${_tape}
+ if [ ! -c $TAPE ]; then
+ echo "$TAPE does not exist or is not a character special file."
+ echo "Aborting."
+ return
+ fi
+ export TAPE
-# Skip to correct file.
-echo -n "Skipping to source file..."
-if [ "X${_nskip}" != X"0" ]; then
- if ! mt fsf $_nskip ; then
- echo "Could not skip $_nskip files. Aborting."
+ # Rewind the tape device
+ echo -n "Rewinding tape..."
+ if ! mt rewind ; then
+ echo "$TAPE may not be attached to the system or may not be"
+ echo "a tape device. Aborting."
return
fi
-fi
-echo "done."
+ echo "done."
+
+ # Get the file number
+ resp=
+ while [ -z "$resp" ]; do
+ echo -n "File number? "
+ getresp
+ case $resp in
+ [1-9]*) _nskip=$(( $resp - 1 ))
+ ;;
+ *) echo "Invalid file number ${resp}."
+ # force loop to repeat
+ resp=
+ ;;
+ esac
+ done
+
+ # Skip to correct file.
+ echo -n "Skipping to source file..."
+ if [ "X${_nskip}" != X"0" ]; then
+ if ! mt fsf $_nskip ; then
+ echo "Could not skip $_nskip files. Aborting."
+ return
+ fi
+ fi
+ echo "done."
cat << __EOT
@@ -1768,99 +1681,100 @@ There are 2 different ways the file can be stored on tape:
2) a standard tar image
__EOT
-resp=
-while [ "X${resp}" = X"" ]; do
- echo -n "Which way is it? [1] "
- getresp 1
- case $resp in
- 1) _xcmd="tar -zxvpf -"
- ;;
- 2) _xcmd="tar -xvpf -"
- ;;
- *) echo "Invalid response: $resp."
- # force loop to repeat
- resp=
- ;;
- esac
- ( cd /mnt; dd if=$TAPE | $_xcmd )
-done
-echo "Extraction complete."
+
+ resp=
+ while [ -z "$resp" ]; do
+ echo -n "Which way is it? [1] "
+ getresp 1
+ case $resp in
+ 1) _xcmd="tar -zxvpf -"
+ ;;
+ 2) _xcmd="tar -xvpf -"
+ ;;
+ *) echo "Invalid response: $resp."
+ # force loop to repeat
+ resp=
+ ;;
+ esac
+ ( cd /mnt; dd if=$TAPE | $_xcmd )
+ done
+ echo "Extraction complete."
}
get_timezone() {
-local _zoneroot=/mnt/usr/share/zoneinfo/ _zonepath
+ local _zoneroot=/mnt/usr/share/zoneinfo/ _zonepath
-# If the timezone directory structure is not
-# available, return immediately.
+ # If the timezone directory structure is not
+ # available, return immediately.
-[ ! -d $_zoneroot ] && return
+ [ ! -d $_zoneroot ] && return
-cat << __EOT
+ cat << __EOT
Select a time zone for your location. Timezones are represented on the system
by a directory structure rooted in "/usr/share/timezone". Most timezones can
-be selected by entering a token like "CET" or "GMT-6". Other zones are
+be selected by entering a token like "CET" or "GMT-6". Other zones are
grouped by continent or country, with detailed zone information separated by
a slash ("/"), e.g. "US/Pacific" or "Canada/Mountain".
__EOT
-if [ -L /mnt/etc/localtime ]; then
- TZ=`ls -l /mnt/etc/localtime 2>/dev/null | cutlast`
- TZ=${TZ#${_zoneroot#/mnt}}
-fi
-
-[ -z $TZ ] && TZ=GMT
-
-while : ; do
- _zonepath=$_zoneroot
+ if [ -L /mnt/etc/localtime ]; then
+ TZ=`ls -l /mnt/etc/localtime 2>/dev/null | cutlast`
+ TZ=${TZ#${_zoneroot#/mnt}}
+ fi
- echo -n "What timezone are you in? (\`?' for list) [$TZ] "
- getresp "$TZ"
+ [ -z "$TZ" ] && TZ=GMT
- if [ "$resp" = "?" ]; then
- ls -F ${_zonepath}
- continue;
- fi
+ while : ; do
+ _zonepath=$_zoneroot
- _zonepath=${_zonepath}${resp}
+ echo -n "What timezone are you in? ('?' for list) [$TZ] "
+ getresp "$TZ"
- while [ -d ${_zonepath} ]; do
- echo -n "Select a sub-timezone of "
- echo -n "'${_zonepath#$_zoneroot}' (\`?' for list): "
- getresp
if [ "$resp" = "?" ]; then
ls -F ${_zonepath}
- else
- _zonepath=${_zonepath}/${resp}
+ continue;
fi
- done
- if [ -f ${_zonepath} ]; then
- TZ=${_zonepath#$_zoneroot}
- echo "You have selected timezone '$TZ'".
- ln -sf /usr/share/zoneinfo/$TZ /mnt/etc/localtime
- return
- fi
+ _zonepath=${_zonepath}${resp}
+
+ while [ -d ${_zonepath} ]; do
+ echo -n "Select a sub-timezone of "
+ echo -n "'${_zonepath#$_zoneroot}' ('?' for list): "
+ getresp
+ if [ "$resp" = "?" ]; then
+ ls -F ${_zonepath}
+ else
+ _zonepath=${_zonepath}/${resp}
+ fi
+ done
- echo -n "'${_zonepath#$_zoneroot}'"
- echo " is not a valid timezone on this system."
-done
+ if [ -f ${_zonepath} ]; then
+ TZ=${_zonepath#$_zoneroot}
+ echo "You have selected timezone '$TZ'".
+ ln -sf /usr/share/zoneinfo/$TZ /mnt/etc/localtime
+ return
+ fi
+
+ echo -n "'${_zonepath#$_zoneroot}'"
+ echo " is not a valid timezone on this system."
+ done
}
sane_install() {
if [ ! -s /mnt/bsd ]; then
cat << __EOT
-Warning, no kernel (/mnt/bsd) installed! You did not unpack a file set
-containing a kernel--this is needed to boot. Please note that the install
+Warning, no kernel (/mnt/bsd) installed! You did not unpack a file set
+containing a kernel -- this is needed to boot. Please note that the install
kernel is *not* suitable for general use.
__EOT
elif [ ! -f /mnt/bin/cat ]; then
cat << __EOT
You still do not have a /bin/cat in your filesystem (i.e. a sample random file
-which you probably want). This seems to indicate that you are still missing
+which you probably want). This seems to indicate that you are still missing
important distribution files.
__EOT
elif [ ! -x /mnt/dev/MAKEDEV ]; then
@@ -1881,7 +1795,7 @@ __EOT
cat << __EOT
-You will now be given the chance to install the missing set(s). You can
+You will now be given the chance to install the missing set(s). You can
enter '!' at the prompt to escape to a shell and fix things by hand if you wish.
__EOT
@@ -1890,90 +1804,90 @@ __EOT
}
install_sets() {
-local _yup=FALSE _have_nfs
+ local _yup=FALSE _have_nfs
-# Can we do an NFS install?
-test -f /sbin/mount_nfs && _have_nfs=true
+ # Can we do an NFS install?
+ [ -f /sbin/mount_nfs ] && _have_nfs=true
-# Ask the user which media to load the distribution from.
-cat << __EOT
-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. 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.
+ # Ask the user which media to load the distribution from.
+ cat << __EOT
+
+You must now specify where the ${MODE} sets you want to use are. They
+must either be on a local device (disk, tape, or CD-ROM), an
+accessible NFS filesystem or an accessible ftp or http network
+server. You will have the chance to repeat this step or to extract
+sets from several places, so you do not have to try to load all the
+sets in one try and can recover from some errors.
__EOT
-if [ "X$local_sets_dir" != "X" ]; then
- install_from_mounted_fs "${local_sets_dir}"
- if [ X"$_setsdone" != X ]; then
- _yup=TRUE
+ if [ -n "$local_sets_dir" ]; then
+ install_from_mounted_fs "${local_sets_dir}"
+ [ -n "$_setsdone" ] && _yup=TRUE
fi
-fi
-# Go on prodding for alternate locations
-resp=
-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, (h)ttp, (t)ape, (C)D-ROM"
- test -n "$_have_nfs" && echo -n ", (N)FS"
- echo -n " or local (d)isk? "
- getresp
- case $resp in
- d*|D*) install_disk
- resp=d
- ;;
- f*|F*) test -n "$_didnet" || donetconfig
- install_url -ftp
- resp=f
- ;;
- h*|H*) test -n "$_didnet" || donetconfig
- install_url -http
- resp=h
- ;;
- t*|T*) install_tape
- resp=t
- ;;
- c*|C*) install_cdrom
- resp=c
- ;;
- n*|N*) test -n "$_didnet" || donetconfig
- if [ -n "$_have_nfs" ]; then
- install_nfs
- resp=n
- else
- echo "Invalid response: $resp"
+ # Go on prodding for alternate locations
+ resp=
+ while [ -z "$resp" ]; 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, (h)ttp, (t)ape, (C)D-ROM"
+ [ -n "$_have_nfs" ] && echo -n ", (N)FS"
+ echo -n " or local (d)isk? "
+ getresp
+ case $resp in
+ d*|D*) install_disk
+ resp=d
+ ;;
+ f*|F*) [ -n "$_didnet" ] || donetconfig
+ install_url -ftp
+ resp=f
+ ;;
+ h*|H*) [ -n "$_didnet" ] || donetconfig
+ install_url -http
+ resp=h
+ ;;
+ t*|T*) install_tape
+ resp=t
+ ;;
+ c*|C*) install_cdrom
+ resp=c
+ ;;
+ n*|N*) [ -n "$_didnet" ] || donetconfig
+ if [ -n "$_have_nfs" ]; then
+ install_nfs
+ resp=n
+ else
+ echo "Invalid response: $resp"
+ resp=
+ fi
+ ;;
+ *) echo "Invalid response: $resp"
resp=
- fi
- ;;
- *) echo "Invalid response: $resp"
- resp=
- ;;
- esac
- else
- # So we'll ask next time
- _yup=FALSE
- fi
+ ;;
+ esac
+ else
+ # So we'll ask next time
+ _yup=FALSE
+ fi
- # Perform sanity checks...
- if sane_install; then
- # Give the user the opportunity to extract more sets. They
- # don't necessarily have to come from the same media.
- echo -n "\nExtract more sets? [n] "
- getresp n
- case $resp in
- y*|Y*) # Force loop to repeat
+ # Perform sanity checks...
+ if sane_install; then
+ # Give the user the opportunity to extract more sets. They
+ # don't necessarily have to come from the same media.
+ echo -n "\nExtract more sets? [n] "
+ getresp n
+ case $resp in
+ y*|Y*) # Force loop to repeat
+ resp=
+ ;;
+ esac
+ else
+ # Not sane, don't exit loop.
resp=
- ;;
- esac
- else
- # Not sane, don't exit loop.
- resp=
- fi
-done
+ fi
+ done
}
munge_fstab() {
@@ -2001,7 +1915,7 @@ munge_fstab() {
_opt="$(echo ${_opt} | sed 's/,softdep,/,/; s/,softdep//; s/softdep,//')"
if [ "$_mp" = "/" ]; then
- _mp=""
+ _mp=
fi
echo $_dev /mnt$_mp $_fstype $_opt $_rest
@@ -2025,7 +1939,7 @@ mount_fs() {
# In addition to the error message displayed by mount ...
cat << __EOT
-FATAL ERROR: Cannot mount filesystems. Double-check your configuration
+FATAL ERROR: Cannot mount filesystems. Double-check your configuration
and restart the ${MODE}.
__EOT
@@ -2106,7 +2020,7 @@ get_fqdn() {
-e '${g;p;}' $1`
fi
- if [ -f "$2" -a "X$FQDN" != "X" ]; then
+ if [ -f "$2" -a -n "$FQDN" ]; then
# Add FQDN to hosts file entries created by addhostent, changing
# lines like
# 1.2.3.4 hostname
@@ -2115,7 +2029,7 @@ get_fqdn() {
sed "s/\\(.*\\)[[:space:]]\\(.*\\)\$/\\1 \\2.$FQDN \\2/" < $2 > $2.new
mv $2.new $2
else
- echo -n "Enter DNS domain name (e.g. \"bar.com\"): [$FQDN] "
+ echo -n "Enter DNS domain name (e.g. 'bar.com'): [$FQDN] "
getresp "$FQDN"
FQDN=$resp
fi
@@ -2130,8 +2044,8 @@ donetconfig() {
fi
resp=
- while [ "X${resp}" = X"" ]; do
- echo -n "Enter system hostname (short form, e.g. \"foo\"): [$_nam] "
+ while [ -z "$resp" ] ; do
+ echo -n "Enter system hostname (short form, e.g. 'foo'): [$_nam] "
getresp "$_nam"
done
hostname $resp
@@ -2185,11 +2099,11 @@ __EOT
resp=`route -n show |
grep '^default' |
sed -e 's/^default *//' -e 's/ .*//'`
- if [ "X${resp}" = "X" ]; then
+ if [ -z "$resp" ] ; then
resp=none
if [ -f /tmp/mygate ]; then
resp=`cat /etc/mygate`
- if [ "X${resp}" = "X" ]; then
+ if [ -z "$resp" ]; then
resp=none
fi
fi
@@ -2209,7 +2123,7 @@ __EOT
for n in `grep '^nameserver ' /tmp/resolv.conf | \
sed -e 's/^nameserver //'`
do
- if [ "X${resp}" = "X" ]; then
+ if [ -z "$resp" ] ; then
resp=$n
else
resp="$resp $n"
@@ -2253,8 +2167,8 @@ __EOT
cat << __EOT
You will now be given the opportunity to escape to the command shell to do
-any additional network configuration you may need. This may include adding
-additional routes, if needed. In addition, you might take this opportunity
+any additional network configuration you may need. This may include adding
+additional routes, if needed. In addition, you might take this opportunity
to redo the default route in the event that it failed above.
__EOT
echo -n "Escape to shell? [n] "
@@ -2285,7 +2199,9 @@ finish_up() {
md_installboot ${ROOTDISK}
populateusrlocal
- test -x /mnt/${MODE}.site && /mnt/usr/sbin/chroot /mnt /${MODE}.site
+
+ # XXXXX - what is this for?
+ [ -x /mnt/${MODE}.site ] && /mnt/usr/sbin/chroot /mnt /${MODE}.site
# Unmount filesystems, etc. Disable trap that would do same on exit.
# Do this manually rather than through the trap so md_congrats is
@@ -2299,11 +2215,15 @@ finish_up() {
exit 0
}
+########################################################################
+#
# Initial actions common to both installs and upgrades.
#
-# Some may require machine dependend routines, which may
-# call functions defined above, so it's easiest to put this
+# Some may require machine dependent routines, which may
+# call functions defined above, so it's safest to put this
# code here rather than at the top of the file.
+#
+########################################################################
ROOTDISK=
VERSION=31
@@ -2319,11 +2239,15 @@ _CDDEVS=`md_get_cddevs`
# upgrade.
THESETS="base etc misc comp man game xbase xshare xfont xserv site $MDSETS"
-# Path searched for sets by install_sets on the local filesystems
+# Global variable using during sets installation
local_sets_dir=
+_sets=
+_setsdone=
+_osetsdone=
+_get_files=
# decide upon an editor
-if [ "X$EDITOR" = X ]; then
+if [ -z "$EDITOR" ] ; then
EDITOR=ed
if [ -x /usr/bin/vi ]; then
EDITOR=vi
@@ -2346,11 +2270,12 @@ You can skip the disk preparation steps and continue,
or you can reboot and start over.
__EOT
- echo -n "Skip disk initialization and "
-
+ echo -n "Skip disk initialization and p"
+else
+ echo -n "P"
fi
-echo -n "Proceed with ${MODE}? [n] "
+echo -n "roceed with ${MODE}? [n] "
getresp n
case $resp in
y*|Y*) echo "\nCool! Let's get to it...\n"
diff --git a/distrib/miniroot/upgrade.sh b/distrib/miniroot/upgrade.sh
index 6031948cc6a..7ae5d119479 100644
--- a/distrib/miniroot/upgrade.sh
+++ b/distrib/miniroot/upgrade.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: upgrade.sh,v 1.29 2002/04/05 02:51:59 krw Exp $
+# $OpenBSD: upgrade.sh,v 1.30 2002/04/09 01:01:19 krw Exp $
# $NetBSD: upgrade.sh,v 1.2.4.5 1996/08/27 18:15:08 gwr Exp $
#
# Copyright (c) 1997-2002 Todd Miller, Theo de Raadt, Ken Westerback
@@ -51,7 +51,9 @@ MODE=upgrade
. install.sub
# Remove 'etc' set from THESETS. It should be installed
-# manually, after the upgrade.
+# manually, after the upgrade. Note that etc should not
+# be the first or last set in THESETS, or this won't
+# work!
THESETS=`echo $THESETS | sed -e 's/ etc / /'`
# XXX Work around vnode aliasing bug (thanks for the tip, Chris...)
@@ -61,8 +63,8 @@ while [ "X${ROOTDISK}" = "X" ]; do
getrootdisk
done
-# Assume partition 'a' of $ROOTDISK is for the root filesystem. Confirm
-# this with the user. Check and mount the root filesystem.
+# Assume partition 'a' of $ROOTDISK is for the root filesystem. Confirm
+# this with the user. Check and mount the root filesystem.
resp=
while [ "X${resp}" = "X" ]; do
echo -n "Root filesystem? [${ROOTDISK}a] "
@@ -103,8 +105,8 @@ done
# uses.
cat << __EOT
-The upgrade program would now like to enable the network. It will use the
-configuration already stored on the root filesystem. This is required
+The upgrade program would now like to enable the network. It will use the
+configuration already stored on the root filesystem. This is required
if you wish to use the network installation capabilities of this program.
__EOT
@@ -120,8 +122,8 @@ y*|Y*)
cat << __EOT
You will now be given the opportunity to escape to the command shell to
-do any additional network configuration you may need. This may include
-adding additional routes, if needed. In addition, you might take this
+do any additional network configuration you may need. This may include
+adding additional routes, if needed. In addition, you might take this
opportunity to redo the default route in the event that it failed above.
__EOT
@@ -140,7 +142,7 @@ cat /tmp/fstab
cat << __EOT
-You may wish to edit the fstab. For example, you may need to resolve
+You may wish to edit the fstab. For example, you may need to resolve
dependencies in the order which the filesystems are mounted.
NOTE: 1) this fstab is used only during the upgrade. It will not be
@@ -213,7 +215,7 @@ install_sets $THESETS
(
if [ -f /mnt/etc/sendmail.cf -a ! -f /mnt/etc/mail/sendmail.cf ]; then
echo "Moving /etc/sendmail.cf -> /etc/mail/sendmail.cf"
- test -d /mnt/etc/mail || mkdir /mnt/etc/mail
+ [ -d /mnt/etc/mail ] || mkdir /mnt/etc/mail
mv /mnt/etc/sendmail.cf /mnt/etc/mail/sendmail.cf
ed - /mnt/etc/rc << __EOT
1,$s/etc\/sendmail.cf/etc\/mail\/sendmail.cf/g