consolidate mail state to fix #191

This commit is contained in:
Thorsten von Eicken 2016-05-23 23:21:18 -07:00
parent c8169c0a34
commit 4ca39f9144
2 changed files with 25 additions and 0 deletions

View file

@ -19,11 +19,13 @@ run:
docker run -d --name mail \ docker run -d --name mail \
-v "`pwd`/test/config":/tmp/docker-mailserver \ -v "`pwd`/test/config":/tmp/docker-mailserver \
-v "`pwd`/test":/tmp/docker-mailserver-test \ -v "`pwd`/test":/tmp/docker-mailserver-test \
-v "`pwd`/test/onedir":/var/mail-state \
-e SA_TAG=1.0 \ -e SA_TAG=1.0 \
-e SA_TAG2=2.0 \ -e SA_TAG2=2.0 \
-e SA_KILL=3.0 \ -e SA_KILL=3.0 \
-e SASL_PASSWD=testing \ -e SASL_PASSWD=testing \
-e ENABLE_MANAGESIEVE=1 \ -e ENABLE_MANAGESIEVE=1 \
-e ONE_DIR=1 \
-h mail.my-domain.com -t $(NAME) -h mail.my-domain.com -t $(NAME)
sleep 20 sleep 20
docker run -d --name mail_pop3 \ docker run -d --name mail_pop3 \

View file

@ -268,6 +268,29 @@ test -z "$ENABLE_FAIL2BAN" && rm -f /etc/logrotate.d/fail2ban
# Fix cron.daily for spamassassin # Fix cron.daily for spamassassin
sed -i -e 's/invoke-rc.d spamassassin reload/\/etc\/init\.d\/spamassassin reload/g' /etc/cron.daily/spamassassin sed -i -e 's/invoke-rc.d spamassassin reload/\/etc\/init\.d\/spamassassin reload/g' /etc/cron.daily/spamassassin
# Consolidate all state that should be persisted across container restarts into one mounted
# directory
statedir=/var/mail-state
if [ "$ONE_DIR" = 1 -a -d $statedir ]; then
echo "Consolidating all state onto $statedir"
for d in /var/spool/postfix /var/lib/postfix /var/lib/amavis /var/lib/clamav /var/lib/spamassasin /var/lib/fail2ban; do
dest=$statedir/`echo $d | sed -e 's/.var.//; s/\//-/g'`
if [ -d $dest ]; then
echo " Destination $dest exists, linking $d to it"
rm -rf $d
ln -s $dest $d
elif [ -d $d ]; then
echo " Moving contents of $d to $dest:" `ls $d`
mv $d $dest
ln -s $dest $d
else
echo " Linking $d to $dest"
mkdir -p $dest
ln -s $dest $d
fi
done
fi
echo "Starting daemons" echo "Starting daemons"
cron cron
/etc/init.d/rsyslog start /etc/init.d/rsyslog start