summaryrefslogtreecommitdiff
path: root/distrib
diff options
context:
space:
mode:
Diffstat (limited to 'distrib')
-rw-r--r--distrib/miniroot/install.sub92
1 files changed, 57 insertions, 35 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index b514d2e2b4b..66c8ec3d31e 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: install.sub,v 1.171 2001/10/31 01:33:24 krw Exp $
+# $OpenBSD: install.sub,v 1.172 2001/11/17 20:23:23 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997,1998 Todd Miller, Theo de Raadt
@@ -455,17 +455,13 @@ addhostent() {
# $1 - IP address
# $2 - symbolic name
- # Create an entry in the hosts table. If no host table
- # exists, create one. If the symbolic name already exists,
- # replace its entry.
- if [ ! -f /tmp/hosts ]; then
- echo "127.0.0.1 localhost" > /tmp/hosts
- fi
+ # Create an entry in the hosts file. If an entry with the
+ # same symbolic name already exists, delete it.
- sed "/ $2.$FQDN $2\$/d" < /tmp/hosts > /tmp/hosts.new
+ sed "/ $2\$/d" < /tmp/hosts > /tmp/hosts.new
mv /tmp/hosts.new /tmp/hosts
- echo "$1 $2.$FQDN $2" >> /tmp/hosts
+ echo "$1 $2" >> /tmp/hosts
}
addifconfig() {
@@ -485,7 +481,7 @@ addifconfig() {
fi
}
-configurenetwork() {
+configure_all_interfaces() {
local _ifsdone= _ifs _ouranswer= _reprompt=1
_IFS=`get_ifdevs`
@@ -2209,6 +2205,9 @@ local _fstab=$1
}
get_fqdn() {
+ # $1 = resolv.conf file to search for FQDN
+ # $2 = hosts file to add FQDN information to
+
# Find LAST instance of DOMAIN or SEARCH and extract first domain name
# on that line as FQDN. Then ask user, just to be sure.
@@ -2219,13 +2218,19 @@ get_fqdn() {
-e '${g;p;}' $1`
fi
- resp= # force at least one iteration
- while [ "X${resp}" = X"" ]; do
+ if [ -f "$2" -a "X$FQDN" != "X" ]; then
+ # Add FQDN to hosts file entries created by addhostent, changing
+ # lines like
+ # 1.2.3.4 hostname
+ # to
+ # 1.2.3.4 hostname.$FQDN hostname
+ 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] "
getresp "$FQDN"
- done
-
- FQDN=$resp
+ FQDN=$resp
+ fi
}
donetconfig() {
@@ -2242,21 +2247,48 @@ donetconfig() {
hostname $resp
echo $resp > /tmp/myname
+ # Always create new hosts file. If install.sh has been
+ # restarted, an existing one may contain information which
+ # will conflict with the information about to be entered.
+ # Also ensures logic to put FQDN in hosts file will create
+ # hosts file lines in correct format.
+ echo "::1 localhost\n127.0.0.1 localhost" > /tmp/hosts
+
+ # Remove any existing hostname.* files. If install.sh has
+ # been restarted, this ensures a correct list of configured
+ # interfaces is displayed, and gives the user a chance to
+ # change which interfaces are to be configured.
+ rm -f /tmp/hostname.*
+
+ # Revoke any previous decision on whether or not to use
+ # a nameserver during installation.
+ rm -f /tmp/resolv.conf.shadow
+
echo
- echo "If you have any devices being configured by a DHCP server"
- echo "it is recommended that you do not enter a default route or"
- echo "any name servers."
+ echo "If any interfaces will be configured using a DHCP server"
+ echo "it is recommended that you do not enter a DNS domain name,"
+ echo "a default route, or any name servers."
echo
- # Get FQDN before creation of hosts file entries in addhostent()
+ FQDN=""
+ get_fqdn /tmp/resolv.conf
+
+ configure_all_interfaces
+
+ # As dhclient will populate /etc/resolv.conf, a symbolic link to
+ # /tmp/resolv.conf.shadow, mv any such file to /tmp/resolv.conf
+ # so it will eventually be copied to /mnt/etc/resolv.conf and will
+ # not in the meantime remove the user's ability to choose to use it
+ # or not, during the rest of the install.
if [ -f /tmp/resolv.conf.shadow ]; then
- get_fqdn /tmp/resolv.conf.shadow
- else
- # If install is being re-run, save a few keystrokes
- get_fqdn /tmp/resolv.conf
+ mv /tmp/resolv.conf.shadow /tmp/resolv.conf
fi
- configurenetwork
+ # Get any DHCP supplied FQDN, and in any case apply FQDN to
+ # the host names in /tmp/hosts, all without asking for any more
+ # user confirmation. This means DHCP supplied information will
+ # override a user supplied (or previous DHCP supplied) FQDN.
+ get_fqdn /tmp/resolv.conf /tmp/hosts
resp=`route -n show |
grep '^default' |
@@ -2280,17 +2312,7 @@ donetconfig() {
fi
resp="none"
- if [ -f /etc/resolv.conf ]; then
- resp=
- for n in `grep '^nameserver ' /etc/resolv.conf | \
- sed -e 's/^nameserver //'`; do
- if [ "X${resp}" = "X" ]; then
- resp="$n"
- else
- resp="$resp $n"
- fi
- done
- elif [ -f /tmp/resolv.conf ]; then
+ if [ -f /tmp/resolv.conf ]; then
resp=
for n in `grep '^nameserver ' /tmp/resolv.conf | \
sed -e 's/^nameserver //'`; do