From 3837223751e5455a5e5a397cdfe51285a2bbc2d1 Mon Sep 17 00:00:00 2001 From: Damien Chaumette Date: Mon, 19 Aug 2002 17:46:59 +0000 Subject: o remove old /etc/hosts entries for the hostname before adding new one --- perl-install/network/network.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'perl-install/network') diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 0a336ba6d..5d1e1c784 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -147,7 +147,12 @@ sub add2hosts { local *F; if (-e $file) { open F, $file or die "cannot open $file: $!"; - /\s*(\S+)(.*)/ and $l{$1} ||= $2 foreach ; + #/\s*(\S+)(.*)/ and $l{$1} ||= $2 foreach ; + foreach () { + m/\s*(\S+)(.*)/; + my ($ip, $host) = ($1, $2); + $l{$ip} ||= $host if $host !~ /^\s*$hostname\s*$/; + } } log::l("writing host information to $file"); open F, ">$file" or die "cannot write $file: $!"; -- cgit v1.2.1