diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2002-04-02 01:25:35 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2002-04-02 01:25:35 +0000 |
commit | 1bf2dc2cf2bfd7424cf4affdfbf3c1ed7ad46151 (patch) | |
tree | 00c8d60e478bd3d099827eff34492d2d882f7589 | |
parent | b9609863a7ea432e6113f92dbd38105be6560857 (diff) |
Do not copy /etc/mygate to install'ed systems if dhcp is specified
for one or more network interfaces.
Rework timezone logic to shrink it and make it more clear. Don't
bother checking for /usr/share/zoneinfo as it is never there, just
look for /mnt/usr/share/zoneinfo.
Eliminate spurious early call to get_timezone() that
(accidentally?) made GMT the default timezone during
installs. Instead rely on the /etc/localtime that is installed
from etcXX.gz. Currently this means the default timezone is the
historically resonant US/Pacific.
Ideas if not code details ok deraadt@ and millert@
-rw-r--r-- | distrib/miniroot/install.sh | 44 | ||||
-rw-r--r-- | distrib/miniroot/install.sub | 94 | ||||
-rw-r--r-- | distrib/miniroot/upgrade.sh | 6 |
3 files changed, 62 insertions, 82 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh index 0cb99ed279a..54725f1f190 100644 --- a/distrib/miniroot/install.sh +++ b/distrib/miniroot/install.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: install.sh,v 1.90 2002/03/31 15:30:42 krw Exp $ +# $OpenBSD: install.sh,v 1.91 2002/04/02 01:25:34 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 @@ -131,9 +131,6 @@ echo # Deal with terminal issues md_set_term -# Get timezone info -get_timezone - if [ ! -f /etc/fstab ]; then # Install the shadowed disktab file; lets us write to it for temporary # purposes without mounting the miniroot read-write. @@ -364,39 +361,34 @@ md_questions install_sets $THESETS # Copy in configuration information and make devices in target root. -echo -cd /tmp -echo -n "Copying " -for file in fstab hostname.* hosts myname mygate resolv.conf; do - if [ -f $file ]; then - echo -n "$file " - cp $file /mnt/etc/$file - rm -f $file - fi -done -echo "...done." +cfgfiles="fstab hostname.* hosts myname mygate resolv.conf" +echo if [ -f /etc/dhclient.conf ]; then echo -n "Saving dhclient configuration..." 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//'` echo "done." fi -# If no zoneinfo on the installfs, give them a second chance -if [ ! -e /usr/share/zoneinfo ]; then - get_timezone -fi -if [ ! -e /mnt/usr/share/zoneinfo ]; then - echo "Cannot install timezone link." -else - echo "Installing timezone link." - rm -f /mnt/etc/localtime - ln -s /usr/share/zoneinfo/$TZ /mnt/etc/localtime -fi +cd /tmp +echo -n "Copying... " +for file in $cfgfiles; do + if [ -f $file ]; then + echo -n "$file " + cp $file /mnt/etc/$file + rm -f $file + fi +done +echo "...done." +# Get timezone info +get_timezone +# Make devices if [ ! -x /mnt/dev/MAKEDEV ]; then echo "No /dev/MAKEDEV installed, something is wrong here..." exit diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 8ab7f78363a..420ab4629c4 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: install.sub,v 1.196 2002/03/31 15:30:42 krw Exp $ +# $OpenBSD: install.sub,v 1.197 2002/04/02 01:25:34 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 @@ -156,7 +156,7 @@ cutword () { _n=$1 while read _a; do set -- $_a - test "$1" = "" && break + test -z "$1" && break eval echo \$$_n done IFS=$_oifs @@ -1762,21 +1762,12 @@ echo "Extraction complete." } get_timezone() { -local _a _zonepath +local _zoneroot=/mnt/usr/share/zoneinfo/ _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 +# If the timezone directory structure is not +# available, return immediately. + +[ ! -d $_zoneroot ] && return cat << __EOT @@ -1786,47 +1777,48 @@ 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". -To get a listing of what's available in /usr/share/zoneinfo, enter "?" -at the prompts below. - __EOT -if [ X$TZ = X ]; then + +if [ -L /mnt/etc/localtime ]; then TZ=`ls -l /mnt/etc/localtime 2>/dev/null | cutlast` - TZ=${TZ#/usr/share/zoneinfo/} + TZ=${TZ#${_zoneroot#/mnt}} fi + +[ -z $TZ ] && TZ=GMT + while : ; do + _zonepath=$_zoneroot + echo -n "What timezone are you in? (\`?' for list) [$TZ] " getresp "$TZ" - case $resp in - "") echo "Timezone defaults to GMT" - TZ=GMT - break - ;; - "?") ls -F ${_zonepath}/usr/share/zoneinfo - ;; - *) _a=$resp - 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 -F ${_zonepath}/usr/share/zoneinfo/$_a ;; - *) _a=${_a}/${resp} - if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then - break - fi - ;; - esac - done - if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then - TZ=$_a - echo "You have selected timezone \"$_a\"". - return + + if [ "$resp" = "?" ]; then + ls -F ${_zonepath} + continue; + 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 - echo "'/usr/share/zoneinfo/$_a' is not a valid timezone on this system." - ;; - esac + 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 } @@ -2159,7 +2151,7 @@ donetconfig() { resp=`route -n show | grep '^default' | - sed -e 's/^default //' -e 's/ .*//'` + sed -e 's/^default *//' -e 's/ .*//'` if [ "X${resp}" = "X" ]; then resp=none if [ -f /tmp/mygate ]; then diff --git a/distrib/miniroot/upgrade.sh b/distrib/miniroot/upgrade.sh index a61ed2bfea7..b95272e7696 100644 --- a/distrib/miniroot/upgrade.sh +++ b/distrib/miniroot/upgrade.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: upgrade.sh,v 1.27 2002/03/31 15:30:42 krw Exp $ +# $OpenBSD: upgrade.sh,v 1.28 2002/04/02 01:25:34 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 @@ -251,10 +251,6 @@ get_timezone # Copy in configuration information and make devices in target root. ( - echo "Installing timezone link." - rm -f /mnt/etc/localtime - ln -s /usr/share/zoneinfo/$TZ /mnt/etc/localtime - 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 |