diff --git a/ulib/debian b/ulib/debian index cf66e9d..dcf86ff 100644 --- a/ulib/debian +++ b/ulib/debian @@ -122,9 +122,10 @@ function __network_backup() { function __network_hostname() { local hostname="${1%%.*}" + [ -f /etc/hostname ] || touch /etc/hostname if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then uecho "Setting /etc/hostname to $hostname" - else + elif [ "$(/etc/hostname fi @@ -132,20 +133,22 @@ function __network_hostname() { function __network_mailname() { local host="$1" + [ -f /etc/mailname ] || touch /etc/mailname if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then uecho "Setting /etc/mailname to $host" - else + elif [ "$(/etc/mailname fi } function __network_fix_exim4() { - local host="$1" + local host="$1" oldhost="$2" local tmpfile; ac_set_tmpfile tmpfile - "$tmpfile" + sed "$tmpfile" " +/^dc_other_hostnames=/c\\ +dc_other_hostnames='$host'" if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then if testdiff "$tmpfile" /etc/exim4/update-exim4.conf.conf; then uecho "Setting /etc/exim4/update-exim4.conf.conf to:" @@ -161,6 +164,33 @@ function __network_fix_exim4() { ac_clean "$tmpfile" } +function __network_fix_postfix() { + local host="$1" oldhost="$2" + local tmpfile; ac_set_tmpfile tmpfile + + awkrun "$tmpfile" host="$host" oldhost="$oldhost" ' +/^myhostname *=/ { $0 = "myhostname = " host } +/^mydestination *=/ { + gsub(" *" oldhost " *,? *", "") + if ($0 !~ (" *" host " *,? *")) { + sub(/^mydestination *= */, "mydestination = " host ", ") + } +} +{ print }' + if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then + if testdiff "$tmpfile" /etc/postfix/main.cf; then + uecho "Setting /etc/postfix/main.cf to:" + cat "$tmpfile" | sed 's/^/ /g' 1>&2 + else + uecho "/etc/postfix/main.cf: pas de modifications" + fi + elif testdiff "$tmpfile" /etc/postfix/main.cf; then + __network_backup /etc/postfix/main.cf + cat "$tmpfile" >/etc/postfix/main.cf + fi + ac_clean "$tmpfile" +} + function __network_hosts() { local host="$1" hostname="${1%%.*}" ip="$2" local shost="${host//./\\.}" @@ -979,12 +1009,6 @@ iface lo inet loopback __network_hostname "$host" estep "/etc/mailname" __network_mailname "$host" - if [ -f "/etc/exim4/update-exim4.conf.conf" ]; then - estep "/etc/exim4/update-exim4.conf.conf" - __network_fix_exim4 "$host" - fi - # XXX tester la présence de postfix, et si nécessaire, modifier la - # configuration if [ -n "$mainip" ]; then estep "/etc/hosts" __network_hosts "$host" "$mainip"