diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-03-14 15:55:40 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-03-14 15:55:40 +0000 |
commit | e5cf6cd809864ddb0a41187dca0bd93b7a95e213 (patch) | |
tree | 5c313735f4c7c7673c3937c7c93b2104f3c4deba | |
parent | b6a9bb077c0fda7e1f01eedc8b6dcc05b8696f45 (diff) |
Installed dhclient.conf is now all comments. Installed hosts is
now correct as is, since we don't add info to localhost lines. So
ditch comment-preserving dance through /tmp and just append our
new info to installed files. Shrinks scripts without changing
behaviour.
-rw-r--r-- | distrib/miniroot/install.sh | 34 | ||||
-rw-r--r-- | distrib/miniroot/install.sub | 15 |
2 files changed, 14 insertions, 35 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh index 0056fd73818..c7bd16e2bb8 100644 --- a/distrib/miniroot/install.sh +++ b/distrib/miniroot/install.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sh,v 1.163 2009/03/14 14:23:05 krw Exp $ +# $OpenBSD: install.sh,v 1.164 2009/03/14 15:55:39 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 @@ -362,16 +362,10 @@ echo -n "Saving configuration files..." ( cd /tmp hostname >myname -# Prepend localhost entries and add FQDN to /tmp/hosts entries, changing lines -# of the form '1.2.3.4 hostname' to '1.2.3.4 hostname.$FQDN hostname'. Leave -# untouched any lines containing 'localhost', domain information or aliases. The -# first should not have domain info and the latter the user added manually. - -cat >hosts.new <<__EOT -::1 localhost -127.0.0.1 localhost -__EOT - +# Append entries to installed hosts file, changing '1.2.3.4 hostname' +# to '1.2.3.4 hostname.$FQDN hostname'. Leave untouched lines containing +# domain information or aliases. These are lines the user added/changed +# manually. _dn=$(get_fqdn) while read _addr _hn _aliases; do if [[ -n $_aliases || $_hn != ${_hn%%.*} || -z $_dn ]]; then @@ -379,19 +373,17 @@ while read _addr _hn _aliases; do else echo "$_addr\t$_hn.$_dn $_hn" fi -done <hosts >>hosts.new -mv hosts.new hosts +done <hosts >>/mnt/etc/hosts +rm hosts -# Prepend interesting comments from installed hosts and dhclient.conf files -# to /tmp/hosts and /tmp/dhclient.conf. -save_comments hosts -save_comments dhclient.conf +# Append dhclient.conf to installed dhclient.conf. +_f=dhclient.conf +[[ -f $_f ]] && { cat $_f >>/mnt/etc/$_f ; rm $_f ; } -# Possible files: fstab hostname.* hosts kbdtype mygate myname ttys -# boot.conf dhclient.conf resolv.conf sysctl.conf -# resolv.conf.tail +# Possible files: fstab hostname.* kbdtype mygate myname ttys +# boot.conf resolv.conf sysctl.conf resolv.conf.tail # Save only non-empty (-s) regular (-f) files. -for _f in fstab host* kbdtype my* ttys *.conf *.tail; do +for _f in fstab hostname* kbdtype my* ttys *.conf *.tail; do [[ -f $_f && -s $_f ]] && mv $_f /mnt/etc/. done ) diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 9d4ed2afac4..27647656c71 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.449 2009/03/14 14:23:05 krw Exp $ +# $OpenBSD: install.sub,v 1.450 2009/03/14 15:55:39 krw Exp $ # $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1997-2007 Todd Miller, Theo de Raadt, Ken Westerback @@ -413,19 +413,6 @@ bsort() { bsort $_l } -# Add interesting/useful comments from mnt/etc/$1 to /tmp/$1. -# -# $1 == file in /tmp and /mnt/etc directories -save_comments() { - local _file=$1 - - if [[ -f /mnt/etc/$_file ]]; then - grep "^#" /mnt/etc/$_file >/tmp/$_file.new - [[ -f /tmp/$_file ]] && cat /tmp/$_file >>/tmp/$_file.new - mv /tmp/$_file.new /tmp/$_file - fi -} - # Offer to edit a file in /tmp and execute ${EDITOR} to do so if the user # accepts the offer. # |