fix(install): correct SpamAssassin service name and resolve PowerDNS port 53 conflict

On Ubuntu 24.04 the SpamAssassin service unit is 'spamd', not 'spamassassin'.
The old 'systemctl enable spamassassin' call exited with an error because the
unit file does not exist, killing the install due to set -euo pipefail.

Also moved the systemd-resolved stub listener disable to a dedicated step that
runs before the package installation step. Previously it ran inside the PowerDNS
config block — after apt had already tried (and failed) to restart pdns during
post-install because systemd-resolved was still holding port 53.
This commit is contained in:
NixReaper
2026-04-11 08:19:49 -05:00
parent 87edf902a1
commit eebcce027b
+15 -8
View File
@@ -146,6 +146,18 @@ if ! step_done "nodejs"; then
fi
success "Node.js $(node --version) ready"
# ── Disable systemd-resolved stub listener (frees port 53 for PowerDNS) ─────
step "Freeing port 53 for PowerDNS"
if ! step_done "resolved_stub"; then
# Ubuntu 24.04 runs systemd-resolved with a stub listener on 127.0.0.53:53.
# PowerDNS's apt post-install restart fails if this is still active.
sed -i 's/#DNSStubListener=yes/DNSStubListener=no/' /etc/systemd/resolved.conf 2>/dev/null || true
sed -i 's/^DNSStubListener=yes/DNSStubListener=no/' /etc/systemd/resolved.conf 2>/dev/null || true
systemctl restart systemd-resolved 2>/dev/null || true
mark_done "resolved_stub"
fi
success "Port 53 freed"
# ── Install all services in one pass ─────────────────────────────────────────
step "Installing web stack (Apache, PHP, Exim, Dovecot, PowerDNS, MariaDB)"
if ! step_done "packages"; then
@@ -344,10 +356,6 @@ setuid=pdns
setgid=pdns
PDNS
# Disable systemd-resolved on port 53 to avoid conflict
sed -i 's/#DNSStubListener=yes/DNSStubListener=no/' /etc/systemd/resolved.conf 2>/dev/null || true
systemctl restart systemd-resolved 2>/dev/null || true
systemctl enable pdns
systemctl start pdns
@@ -431,10 +439,9 @@ success "Dovecot configured"
# ── Configure SpamAssassin ────────────────────────────────────────────────────
step "Configuring SpamAssassin"
if ! step_done "spamassassin"; then
sed -i 's/ENABLED=0/ENABLED=1/' /etc/default/spamassassin 2>/dev/null || true
sed -i 's/CRON=0/CRON=1/' /etc/default/spamassassin 2>/dev/null || true
systemctl enable spamassassin
systemctl start spamassassin
# Ubuntu 24.04: service unit is 'spamd', not 'spamassassin'
systemctl enable spamd
systemctl start spamd
mark_done "spamassassin"
fi
success "SpamAssassin configured"