32 lines
1.7 KiB
Bash
Executable File
32 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Starts rspamd (under its own unprivileged system user, created by the rspamd .deb's
|
|
# own postinst) in the background, then hands off to mailgoserver — also dropped to its
|
|
# own unprivileged user — as the container's main (foreground) process. This script
|
|
# itself keeps running as root only long enough to create/chown the persistent
|
|
# directories below and drop privileges for each child; neither rspamd nor mailgoserver
|
|
# ever run as root themselves (mailgoserver's binary carries just the
|
|
# CAP_NET_BIND_SERVICE file capability it needs for ports 25/465/80 — see the
|
|
# Dockerfile — which a non-root exec of it still picks up).
|
|
#
|
|
# rspamd's own persistent state (fuzzy storage, DNS/maps cache — its "dbdir") is
|
|
# redirected into server_data/rspamd so the whole container only has one thing to
|
|
# volume-mount: server_data/, matching mailgoserver's own layout.
|
|
mkdir -p /app/server_data/rspamd
|
|
chown -R rspamd:rspamd /app/server_data/rspamd
|
|
|
|
# ponytail: no supervisor / restart-on-crash for rspamd here — if it dies mid-run, mail
|
|
# keeps flowing without the extra scoring rather than the container crashing (the
|
|
# built-in heuristic score in internal/mailstore/spam.go always runs regardless, and
|
|
# CheckRspamd swallows connection errors rather than rejecting mail over them — see
|
|
# internal/mailstore/rspamd.go). Add s6-overlay or supervisord if unattended rspamd
|
|
# uptime matters more than that.
|
|
runuser -u rspamd -- rspamd -f &
|
|
|
|
# Give rspamd's normal worker a moment to bind :11333 before the first message can
|
|
# possibly arrive — purely cosmetic, mailgoserver degrades gracefully either way.
|
|
sleep 1
|
|
|
|
exec runuser -u mailgoserver -- mailgoserver --host 0.0.0.0 "$@"
|