diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2001-11-01 12:39:01 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2001-11-01 12:39:01 +0000 |
| commit | bd0a2a3f9328424125af40b651a7f84bfae05bd2 (patch) | |
| tree | 4de74fab1ec43ef702bd4219d257497b6bd2d3be /etc/network.subr | |
| parent | 41466b50c1d5bfd1cf6adaae547a579a75d7c04e (diff) | |
Notes
Diffstat (limited to 'etc/network.subr')
| -rw-r--r-- | etc/network.subr | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/etc/network.subr b/etc/network.subr index 1f50bea54b8d..1ca57d56db08 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} |
