43 lines
2.0 KiB
Bash
43 lines
2.0 KiB
Bash
# emailwiz - SpamAssassin (spamd), fail2ban, TLS hooks and maintenance timers
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# shellcheck shell=sh
|
|
|
|
spamd_render() {
|
|
[ "$SPAM_FILTER" = spamc ] || return 0
|
|
# /etc/default/spamd is a Debian conffile: change only the OPTIONS line.
|
|
_f=/etc/default/spamd
|
|
[ -f "$_f" ] || die "$_f missing (is spamd installed?)"
|
|
_opts="--create-prefs --max-children $SPAMD_MAX_CHILDREN --helper-home-dir"
|
|
awk -v o="OPTIONS=\"$_opts\"" '
|
|
/^OPTIONS=/ { if (!done) print o; done = 1; next }
|
|
{ print }
|
|
END { if (!done) print o }' "$_f" | stage_file "$_f" 644 root root spamd
|
|
}
|
|
|
|
fail2ban_render() {
|
|
[ "$FAIL2BAN" = yes ] || return 0
|
|
# Same file name as upstream emailwiz's jail, which it replaces: that one
|
|
# also enabled [sieve], which matches no journal entries on Debian 13.
|
|
render_template fail2ban-jail.local | stage_file /etc/fail2ban/jail.d/emailwiz.local 644 root root fail2ban
|
|
}
|
|
|
|
timers_render() {
|
|
[ "$EMAILWIZ_TIMERS" = yes ] || return 0
|
|
for _u in emailwiz-certcheck.service emailwiz-certcheck.timer \
|
|
emailwiz-backup.service emailwiz-backup.timer; do
|
|
render_template "$_u" | stage_file "/etc/systemd/system/$_u" 644 root root timers
|
|
done
|
|
}
|
|
|
|
# Files from releases 1.x, published under the name "mailwiz". Retiring them
|
|
# (with a backup copy) is what upgrades such a host to the emailwiz names.
|
|
legacy_render() {
|
|
stage_retire /etc/fail2ban/jail.d/mailwiz.local fail2ban "mailwiz 1.x name; now emailwiz.local"
|
|
stage_retire /etc/postfix/mailwiz_outbound_header_checks postfix "mailwiz 1.x name; now emailwiz_outbound_header_checks"
|
|
stage_retire /etc/letsencrypt/renewal-hooks/deploy/mailwiz-reload - "mailwiz 1.x name; now emailwiz-reload"
|
|
stage_retire /etc/systemd/system/spamd.service.d/mailwiz.conf spamd-restart "mailwiz 1.0.0 drop-in; stock unit is used"
|
|
for _u in mailwiz-certcheck.timer mailwiz-certcheck.service mailwiz-backup.timer mailwiz-backup.service; do
|
|
stage_retire "/etc/systemd/system/$_u" timers "mailwiz 1.x unit; now e$_u"
|
|
done
|
|
}
|