public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Dovecot] Fix quarantine bcc, use socket for LUA API
cf4baa00
data/Dockerfiles/dovecot/docker-entrypoint.sh | 25 ++++++++++++++++++++++---
data/Dockerfiles/dovecot/quarantine_notify.py | 2 +-
2 files changed, 23 insertions(+), 4 deletions(-)
Diff
diff --git a/data/Dockerfiles/dovecot/docker-entrypoint.sh b/data/Dockerfiles/dovecot/docker-entrypoint.sh
index 5ce1553e..b61bc840 100755
--- a/data/Dockerfiles/dovecot/docker-entrypoint.sh
+++ b/data/Dockerfiles/dovecot/docker-entrypoint.sh
@@ -19,18 +19,23 @@ done
DBPASS=$(echo ${DBPASS} | sed 's/"/\\"/g')
# Create quota dict for Dovecot
+if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
+ QUOTA_TABLE=quota2
+else
+ QUOTA_TABLE=quota2replica
+fi
cat <<EOF > /etc/dovecot/sql/dovecot-dict-sql-quota.conf
# Autogenerated by mailcow
connect = "host=/var/run/mysqld/mysqld.sock dbname=${DBNAME} user=${DBUSER} password=${DBPASS}"
map {
pattern = priv/quota/storage
- table = quota2
+ table = ${QUOTA_TABLE}
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
- table = quota2
+ table = ${QUOTA_TABLE}
username_field = username
value_field = messages
}
@@ -136,7 +141,7 @@ end
function script_init()
mysql = require "luasql.mysql"
env = mysql.mysql()
- con = env:connect("__DBNAME__","__DBUSER__","__DBPASS__","mysql")
+ con = env:connect("__DBNAME__","__DBUSER__","__DBPASS__","localhost")
return 0
end
@@ -222,6 +227,14 @@ sed -i "s/__DBUSER__/${DBUSER}/g" /usr/local/bin/imapsync_cron.pl /usr/local/bin
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/__LOG_LINES__/${LOG_LINES}/g" /usr/local/bin/trim_logs.sh
+if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
+# Toggling MASTER will result in a rebuild of containers, so the quota script will be recreated
+cat <<'EOF' > /usr/local/bin/quota_notify.py
+#!/usr/bin/python3
+import sys
+sys.exit()
+EOF
+fi
# 401 is user dovecot
if [[ ! -s /mail_crypt/ecprivkey.pem || ! -s /mail_crypt/ecpubkey.pem ]]; then
@@ -259,6 +272,7 @@ chmod +x /usr/lib/dovecot/sieve/rspamd-pipe-ham \
/usr/local/sbin/stop-supervisor.sh \
/usr/local/bin/quota_notify.py
+if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
# Setup cronjobs
echo '* * * * * root /usr/local/bin/imapsync_cron.pl 2>&1 | /usr/bin/logger' > /etc/cron.d/imapsync
#echo '30 3 * * * vmail /usr/local/bin/doveadm quota recalc -A' > /etc/cron.d/dovecot-sync
@@ -270,6 +284,11 @@ echo '*/20 * * * * vmail /usr/local/bin/quarantine_notify.py >> /dev/console 2>&
echo '15 4 * * * vmail /usr/local/bin/clean_q_aged.sh >> /dev/console 2>&1' > /etc/cron.d/clean_q_aged
# Fix more than 1 hardlink issue
touch /etc/crontab /etc/cron.*/*
+else
+echo '25 * * * * vmail /usr/local/bin/maildir_gc.sh >> /dev/console 2>&1' > /etc/cron.d/maildir_gc
+echo '30 1 * * * root /usr/local/bin/sa-rules.sh >> /dev/console 2>&1' > /etc/cron.d/sa-rules
+echo '0 2 * * * root /usr/bin/curl http://solr:8983/solr/dovecot-fts/update?optimize=true >> /dev/console 2>&1' > /etc/cron.d/solr-optimize
+fi
# Clean old PID if any
[[ -f /var/run/dovecot/master.pid ]] && rm /var/run/dovecot/master.pid
diff --git a/data/Dockerfiles/dovecot/quarantine_notify.py b/data/Dockerfiles/dovecot/quarantine_notify.py
index f79776c4..a4a67f91 100755
--- a/data/Dockerfiles/dovecot/quarantine_notify.py
+++ b/data/Dockerfiles/dovecot/quarantine_notify.py
@@ -84,7 +84,7 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl):
msg.attach(text_part)
msg.attach(html_part)
msg['To'] = str(rcpt)
- bcc = r.get('Q_GLOBAL_RCPT') or ""
+ bcc = r.get('Q_BCC') or ""
text = msg.as_string()
server.sendmail(msg['From'], [str(rcpt)] + [str(bcc)], text)
server.quit()