support de la reconfiguration de postfix
This commit is contained in:
parent
5c6b475917
commit
fb7a744e27
46
ulib/debian
46
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)" != "$hostname" ]; then
|
||||
__network_backup /etc/hostname
|
||||
echo "$hostname" >/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)" != "$host" ]; then
|
||||
__network_backup /etc/mailname
|
||||
echo "$host" >/etc/mailname
|
||||
fi
|
||||
}
|
||||
|
||||
function __network_fix_exim4() {
|
||||
local host="$1"
|
||||
local host="$1" oldhost="$2"
|
||||
local tmpfile; ac_set_tmpfile tmpfile
|
||||
|
||||
</etc/exim4/update-exim4.conf.conf sed '/^dc_other_hostnames=/c\
|
||||
'"dc_other_hostnames='$host'" >"$tmpfile"
|
||||
sed </etc/exim4/update-exim4.conf.conf >"$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 </etc/postfix/main.cf >"$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"
|
||||
|
|
Loading…
Reference in New Issue