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