diff --git a/scripts/update.sh b/scripts/update.sh index 116307e..b8e714b 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -341,19 +341,21 @@ JAILEOF fi fi - # Postfix: Hostname in mydestination eintragen damit System-Mails (cron, PHP) - # nicht als Relay-Versuch gewertet werden und fail2ban die eigene IP nicht bannt - if command -v postconf >/dev/null 2>&1; then - local srv_host - srv_host=$(hostname -f 2>/dev/null || hostname 2>/dev/null || true) - if [[ -n "$srv_host" ]]; then - local current_dest - current_dest=$(postconf -h mydestination 2>/dev/null || true) - if ! echo "$current_dest" | grep -qF "$srv_host"; then - postconf -e "mydestination = $srv_host, localhost.localdomain, localhost" - postfix reload >/dev/null 2>&1 || true - echo "[✓] Postfix: $srv_host zu mydestination hinzugefügt (System-Mails lokal zugestellt)." - fi + # Postfix: myhostname + $myhostname in mydestination eintragen damit System-Mails + # (cron, PHP mail()) nicht als Relay-Versuch gewertet werden + local POSTCONF=/usr/sbin/postconf + local POSTFIX=/usr/sbin/postfix + if [[ -x "$POSTCONF" ]]; then + local pf_host + pf_host=$("$POSTCONF" -h myhostname 2>/dev/null || true) + local current_dest + current_dest=$("$POSTCONF" -h mydestination 2>/dev/null || true) + local need_update=0 + [[ -n "$pf_host" ]] && ! echo "$current_dest" | grep -qF "$pf_host" && need_update=1 + if [[ "$need_update" -eq 1 ]]; then + "$POSTCONF" -e "mydestination = $pf_host, \$myhostname, localhost.localdomain, localhost" + [[ -x "$POSTFIX" ]] && "$POSTFIX" reload >/dev/null 2>&1 || true + echo "[✓] Postfix: $pf_host zu mydestination hinzugefügt (System-Mails lokal zugestellt)." fi fi }