Files
docker-mail/include/docker-entrypoint.sh
Jon Lockwood 43f6a356bd fix(sa-learn): amavis can't do bayes check if not mask 777
Service amavis even though part of group vmail who has mark 770
on '/var/spool/spamassassin', can't write lockfile to do a bayes
check.

Set '/var/spool/spamassassin' mask to be `777` with owner
`debian-spamd:vmail` recursive. so that amavis bayes check works.

MR !9
2022-02-19 11:21:04 +09:30

124 lines
2.6 KiB
Bash

#!/bin/bash
set -e
if [ "0$POST_MASTER_EMAIL" != "0" ]; then export MAILTO="$POST_MASTER_EMAIL"; fi
# Populate this file so cron has access to env vars. thanks to https://stackoverflow.com/a/41938139
printenv | grep -v "no_proxy" > /etc/environment
if [ -f "/var/run/amavis/amavisd.pid" ]; then rm /var/run/amavis/amavisd.pid; fi
if [ "$1" == "" ]; then
echo "Setup server type ($SERVERTYPE)"
echo "[Information] starting supervisor daemon"
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
bash
fi
# compile sieve scripts
for file in /etc/dovecot/sieve/*.sieve ;
do
sievec $file;
done
mkdir -p /var/lock/fetchmail
chown debian-spamd:vmail -R /var/spool/spamassassin
chmod 777 /var/spool/spamassassin
if [ "$1" == "setup" ]; then
if [ ! -f /certs/amavis/dkim/example.org.dkim.pem ]; then
echo "[WARNING] Creating DKIM Cert, example.org. Consider Creating your own";
amavisd-new genrsa /certs/amavis/dkim/example.org.dkim.pem 4096;
chmod g+r /certs/amavis/dkim/example.org.dkim.pem;
chgrp amavis /certs/amavis/dkim/example.org.dkim.pem;
amavisd-new showkeys example.org;
fi
supervisorctl start amavis;
postconf -e "myhostname = $(`echo hostname -f`)"
if [ ! -f /certs/dovecot/key.pem ]; then
echo "[WARNING] Creating Self-signed TLS Cert. Consider using letsencrypt or another trusted CA"
openssl req -nodes -new -x509 -keyout /certs/dovecot/key.pem -out /certs/dovecot/cert.pem -subj '/CN=localhost'
fi
if [ ! -f /certs/dovecot/dh.pem ]; then
echo "[Information] Creating DHPEM Key"
openssl dhparam -out /certs/dovecot/dh.pem 2048
fi
echo "[Information] Start dovecot"
supervisorctl start dovecot
sed -i -r -e 's/^manpage_directory/#manpage_directory/' /etc/postfix/main.cf.proto
sed -i -r -e 's/^\$manpage_directory/#$manpage_directory/' /etc/postfix/postfix-files
sed -i -r -e 's/^\$manpage_directory/#$manpage_directory/' /etc/postfix/postfix-files.d/*
if [ ! -f /certs/postfix/key.pem ]; then
echo "[WARNING] Creating Self-signed TLS Cert. Consider using letsencrypt or another trusted CA"
openssl req -nodes -new -x509 -keyout /certs/postfix/key.pem -out /certs/postfix/cert.pem -subj '/CN=localhost'
fi
echo "[Information] set postfix permissions"
postfix set-permissions create-missing
postmap /etc/postfix/header_checks_outbound
postmap /etc/postfix/header_checks_privacy
echo "[Information] start postfix"
# supervisorctl start amavis
supervisorctl start postfix
else
exec "$@"
fi