From 43bf3e379ce6836ea0b3ec68d2d2c48afbd86c6f Mon Sep 17 00:00:00 2001 From: Jephte CLAIN Date: Sun, 9 Feb 2014 23:05:42 +0400 Subject: [PATCH] =?UTF-8?q?supprimer=20ancien=20nom=20d'h=C3=B4te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ulib/debian | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ulib/debian b/ulib/debian index 3f3d692..5075113 100644 --- a/ulib/debian +++ b/ulib/debian @@ -860,20 +860,34 @@ function network_fix_postfix() { } function network_fix_hosts() { - local host="$1" hostname="${1%%.*}" ip="$2" - local shost="${host//./\\.}" + local host="$1" hostname="${1%%.*}"; local shost="${host//./\\.}" + local ip="$2"; local sip="${ip//./\\.}" + local oldhost="$3" oldhostname="${3%%.*}"; soldhost="${host//./\\.}" local tmpfile; ac_set_tmpfile tmpfile local modified - awkrun "$tmpfile" host="$host" hostname="$hostname" ip="$ip" ' + awkrun "$tmpfile" \ + host="$host" hostname="$hostname" \ + ip="$ip" \ + oldhost="$oldhost" oldhostname="$oldhostname" \ + ' /^[^# \t]/ { gsub("[ \\t]+" host "[ \\t]*", " ") gsub("[ \\t]+" hostname "[ \\t]*", " ") + gsub("[ \\t]+" oldhost "[ \\t]*", " ") + gsub("[ \\t]+" oldhostname "[ \\t]*", " ") if ($0 ~ /^[^ \t]+[ \t]*$/) next gsub(/[ \t]*$/, "") } { print }' - local sip="${ip//./\\.}" shost="${host//./\\.}" + if quietgrep "^$sip[ $TAB]\\+$shost[ $TAB]\\+$hostname" "$tmpfile"; then + sed -i "\ +s/\$/ / +/^[ $TAB]$oldhost[ $TAB]/d +/^[ $TAB]$oldhostname[ $TAB]/d +s/ \$// +" "$tmpfile" + fi if ! quietgrep "^$sip[ $TAB]\\+$shost[ $TAB]\\+$hostname" "$tmpfile"; then sed -i "/^$sip[ $TAB]/d" "$tmpfile" sed -i "1i\\ @@ -1079,9 +1093,7 @@ iface lo inet loopback network_fix_hostname "$host" network_fix_mailname "$host" - if [ -n "$mainip" ]; then - network_fix_hosts "$host" "$mainip" - fi + network_fix_hosts "$host" "$mainip" "$oldhost" eend fi