From 16f87f07faac2eeace07346c546059aead1fb517 Mon Sep 17 00:00:00 2001 From: andryyy Date: Fri, 11 Dec 2020 10:05:05 +0100 Subject: [PATCH] [Dovecot] Replace hostname for quarantine notifications with mailcow hostname (broke after Docker 20.10 fix) --- data/Dockerfiles/dovecot/docker-entrypoint.sh | 1 + data/Dockerfiles/dovecot/quarantine_notify.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/data/Dockerfiles/dovecot/docker-entrypoint.sh b/data/Dockerfiles/dovecot/docker-entrypoint.sh index 2bd160fe..9c626fa9 100755 --- a/data/Dockerfiles/dovecot/docker-entrypoint.sh +++ b/data/Dockerfiles/dovecot/docker-entrypoint.sh @@ -271,6 +271,7 @@ fi sed -i "s/__DBUSER__/${DBUSER}/g" /usr/local/bin/imapsync_cron.pl /usr/local/bin/quarantine_notify.py /usr/local/bin/clean_q_aged.sh /etc/dovecot/lua/app-passdb.lua sed -i "s/__DBPASS__/${DBPASS}/g" /usr/local/bin/imapsync_cron.pl /usr/local/bin/quarantine_notify.py /usr/local/bin/clean_q_aged.sh /etc/dovecot/lua/app-passdb.lua sed -i "s/__DBNAME__/${DBNAME}/g" /usr/local/bin/imapsync_cron.pl /usr/local/bin/quarantine_notify.py /usr/local/bin/clean_q_aged.sh /etc/dovecot/lua/app-passdb.lua +sed -i "s/__MAILCOW_HOSTNAME__/${MAILCOW_HOSTNAME}/g" /usr/local/bin/quarantine_notify.py sed -i "s/__LOG_LINES__/${LOG_LINES}/g" /usr/local/bin/trim_logs.sh if [[ "${MASTER}" =~ ^([nN][oO]|[nN])+$ ]]; then # Toggling MASTER will result in a rebuild of containers, so the quota script will be recreated diff --git a/data/Dockerfiles/dovecot/quarantine_notify.py b/data/Dockerfiles/dovecot/quarantine_notify.py index ae0a42f2..adf3171c 100755 --- a/data/Dockerfiles/dovecot/quarantine_notify.py +++ b/data/Dockerfiles/dovecot/quarantine_notify.py @@ -26,6 +26,7 @@ while True: break time_now = int(time.time()) +mailcow_hostname = '__MAILCOW_HOSTNAME__' max_score = float(r.get('Q_MAX_SCORE') or "9999.0") if max_score == "": @@ -75,7 +76,7 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl, category): else: with open('/templates/quarantine.tpl') as file_: template = Template(file_.read()) - html = template.render(meta=meta_query, username=rcpt, counter=msg_count, hostname=socket.gethostname(), quarantine_acl=quarantine_acl) + html = template.render(meta=meta_query, username=rcpt, counter=msg_count, hostname=mailcow_hostname, quarantine_acl=quarantine_acl) text = html2text.html2text(html) count = 0 while count < 15: