Small Cleanup and bug fixes Not done Yet!
Not done yet. Dont merge. See comment in issue #747
This commit is contained in:
parent
6f267cfe4a
commit
fdb0601f4f
|
@ -193,7 +193,7 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem > /et
|
||||||
|
|
||||||
COPY ./target/bin /usr/local/bin
|
COPY ./target/bin /usr/local/bin
|
||||||
# Start-mailserver script
|
# Start-mailserver script
|
||||||
COPY ./target/check_for_changes.sh ./target/start-mailserver.sh ./target/fail2ban-wrapper.sh ./target/postfix-wrapper.sh ./target/docker-configomat/configomat.sh /usr/local/bin/
|
COPY ./target/check-for-changes.sh ./target/start-mailserver.sh ./target/fail2ban-wrapper.sh ./target/postfix-wrapper.sh ./target/docker-configomat/configomat.sh /usr/local/bin/
|
||||||
RUN chmod +x /usr/local/bin/*
|
RUN chmod +x /usr/local/bin/*
|
||||||
|
|
||||||
# Configure supervisor
|
# Configure supervisor
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -171,7 +171,7 @@ fixtures:
|
||||||
docker cp "`pwd`/test/config/sieve/dovecot.sieve" mail:/var/mail/localhost.localdomain/user1/.dovecot.sieve
|
docker cp "`pwd`/test/config/sieve/dovecot.sieve" mail:/var/mail/localhost.localdomain/user1/.dovecot.sieve
|
||||||
docker exec mail /bin/sh -c "maildirmake.dovecot /var/mail/localhost.localdomain/user1/.INBOX.spam"
|
docker exec mail /bin/sh -c "maildirmake.dovecot /var/mail/localhost.localdomain/user1/.INBOX.spam"
|
||||||
docker exec mail /bin/sh -c "chown 5000:5000 -R /var/mail/localhost.localdomain/user1/.INBOX.spam"
|
docker exec mail /bin/sh -c "chown 5000:5000 -R /var/mail/localhost.localdomain/user1/.INBOX.spam"
|
||||||
sleep 20
|
sleep 30
|
||||||
# Sending test mails
|
# Sending test mails
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-spam.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-virus.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/amavis-virus.txt"
|
||||||
|
@ -194,7 +194,7 @@ fixtures:
|
||||||
|
|
||||||
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||||
# Wait for mails to be analyzed
|
# Wait for mails to be analyzed
|
||||||
sleep 75
|
sleep 80
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
# Start tests
|
# Start tests
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
# create date for log output
|
||||||
|
log_date=$(date +"%Y-%m-%d %H:%M:%S ")
|
||||||
# Prevent a start too early
|
# Prevent a start too early
|
||||||
sleep 5
|
sleep 5
|
||||||
|
echo "${log_date} Start check-for-changes script."
|
||||||
|
|
||||||
# change directory
|
# change directory
|
||||||
cd /tmp/docker-mailserver
|
cd /tmp/docker-mailserver
|
||||||
|
|
||||||
# Check postfix-accounts.cf exist else break
|
# Check postfix-accounts.cf exist else break
|
||||||
if [ ! -f postfix-accounts.cf ]; then
|
if [ ! -f postfix-accounts.cf ]; then
|
||||||
echo 'postfix-accounts.cf is missing! This should not run! Exit!'
|
echo "${log_date} postfix-accounts.cf is missing! This should not run! Exit!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update / generate after start
|
# Update / generate after start
|
||||||
echo 'Makeing new chksum'
|
echo "${log_date} Makeing new checksum file."
|
||||||
if [ -f postfix-virtual.cf ]; then
|
if [ -f postfix-virtual.cf ]; then
|
||||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||||
else
|
else
|
||||||
|
@ -22,6 +25,9 @@ fi
|
||||||
# Run forever
|
# Run forever
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
|
# recreate logdate
|
||||||
|
log_date=$(date +"%Y-%m-%d %H:%M:%S ")
|
||||||
|
|
||||||
# Get chksum and check it.
|
# Get chksum and check it.
|
||||||
chksum=$(sha512sum -c chksum)
|
chksum=$(sha512sum -c chksum)
|
||||||
resu_acc=${chksum:21:2}
|
resu_acc=${chksum:21:2}
|
||||||
|
@ -32,7 +38,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
||||||
echo "CHANGE DETECT"
|
echo "${log_date} Change detected"
|
||||||
#regen postfix accounts.
|
#regen postfix accounts.
|
||||||
echo -n > /etc/postfix/vmailbox
|
echo -n > /etc/postfix/vmailbox
|
||||||
echo -n > /etc/dovecot/userdb
|
echo -n > /etc/dovecot/userdb
|
||||||
|
@ -117,7 +123,7 @@ if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
||||||
supervisorctl restart dovecot
|
supervisorctl restart dovecot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo 'Update chksum'
|
echo "${log_date} Update checksum"
|
||||||
if [ -f postfix-virtual.cf ]; then
|
if [ -f postfix-virtual.cf ]; then
|
||||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||||
else
|
else
|
|
@ -120,4 +120,4 @@ autostart=false
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
command=/usr/local/bin/check_for_changes.sh
|
command=/usr/local/bin/check-for-changes.sh
|
||||||
|
|
Loading…
Reference in New Issue