فهرست منبع

[Dovecot] Replace hostname for quarantine notifications with mailcow hostname (broke after Docker 20.10 fix)

andryyy 4 سال پیش
والد
کامیت
16f87f07fa
2فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 1 0
      data/Dockerfiles/dovecot/docker-entrypoint.sh
  2. 2 1
      data/Dockerfiles/dovecot/quarantine_notify.py

+ 1 - 0
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/__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/__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/__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
 sed -i "s/__LOG_LINES__/${LOG_LINES}/g" /usr/local/bin/trim_logs.sh
 if [[ "${MASTER}" =~ ^([nN][oO]|[nN])+$ ]]; then
 if [[ "${MASTER}" =~ ^([nN][oO]|[nN])+$ ]]; then
 # Toggling MASTER will result in a rebuild of containers, so the quota script will be recreated
 # Toggling MASTER will result in a rebuild of containers, so the quota script will be recreated

+ 2 - 1
data/Dockerfiles/dovecot/quarantine_notify.py

@@ -26,6 +26,7 @@ while True:
     break
     break
 
 
 time_now = int(time.time())
 time_now = int(time.time())
+mailcow_hostname = '__MAILCOW_HOSTNAME__'
 
 
 max_score = float(r.get('Q_MAX_SCORE') or "9999.0")
 max_score = float(r.get('Q_MAX_SCORE') or "9999.0")
 if max_score == "":
 if max_score == "":
@@ -75,7 +76,7 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl, category):
   else:
   else:
     with open('/templates/quarantine.tpl') as file_:
     with open('/templates/quarantine.tpl') as file_:
       template = Template(file_.read())
       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)
   text = html2text.html2text(html)
   count = 0
   count = 0
   while count < 15:
   while count < 15: