mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2026-03-28 08:41:26 +01:00
chore: continue with Dovecot quota check
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
parent
1f0b8be0c0
commit
c3b727aa7f
@ -55,8 +55,8 @@ function _quota_show_for() {
|
||||
[[ ${ENABLE_QUOTAS} -ne 1 ]] && return 0
|
||||
|
||||
local QUOTA_INFO
|
||||
# Matches a line where the 3rd column is `type='STORAGE'` - returning the next three column values:
|
||||
IFS=' ' read -r -a QUOTA_INFO <<< "$(doveadm quota get -u "${MAIL_ACCOUNT}" | tail +2 | awk '{ if ($3 == "STORAGE") { print $4" "$5" "$6 } }')"
|
||||
# Matches a line where the 2nd column is `STORAGE` - returning the next three column values
|
||||
IFS=' ' read -r -a QUOTA_INFO <<< "$(doveadm quota get -u "${MAIL_ACCOUNT}" | tail +2 | awk '{ if ($2 == "STORAGE") { print $3" "$4" "$5 } }')"
|
||||
|
||||
local CURRENT_SIZE SIZE_LIMIT PERCENT_USED
|
||||
# Format the extracted quota storage columns:
|
||||
|
||||
@ -205,7 +205,9 @@ mail_plugins {
|
||||
|
||||
# Mailbox list indexes can be used to optimize IMAP STATUS commands. They are
|
||||
# also required for IMAP NOTIFY extension to be enabled.
|
||||
#mailbox_list_index = no
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#driver-count
|
||||
mailbox_list_index = yes
|
||||
|
||||
# The minimum number of mails in a mailbox before updates are done to cache
|
||||
# file. This allows optimizing Dovecot's behavior to do less disk writes at
|
||||
|
||||
@ -1,50 +1,88 @@
|
||||
plugin {
|
||||
# debug quota using `doveadm quota get -u user@domain`
|
||||
# recompute quota using `doveadm quota recalc -u user@domain`
|
||||
# Quota configuration
|
||||
#
|
||||
# ref: https://doc.dovecot.org/2.4.0/core/plugins/quota.html
|
||||
#
|
||||
# ## Commands
|
||||
#
|
||||
# - debug quota: doveadm quota get -u user@domain
|
||||
# - recompute quota: doveadm quota recalc -u user@domain
|
||||
|
||||
# Track the current quota usage in Dovecot’s index files.
|
||||
quota = count:User quota
|
||||
# The quota driver to use
|
||||
#
|
||||
# ref: https://doc.dovecot.org/2.4.0/core/plugins/quota.html#driver-count
|
||||
quota_driver = count
|
||||
|
||||
# Use virtual sizes for count
|
||||
quota_vsizes = yes
|
||||
# The maximum message size to be saved
|
||||
#
|
||||
# Sync this setting with Postfix.
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/summaries/settings.html#quota_mail_size
|
||||
quota_mail_size = 10000M
|
||||
|
||||
# define the maximum message size to be saved, sync with postfix
|
||||
quota_max_mail_size = 10000M
|
||||
# Default quota per mailbox
|
||||
#
|
||||
# Sync this setting with Postfix.
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#quota-limits
|
||||
quota_storage_size = 128M
|
||||
|
||||
# default quota per mailbox, sync with postfix
|
||||
quota_rule = *:storage=128M
|
||||
# Allow additional space when deleting messages
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#quota_storage_extra
|
||||
mailbox Trash {
|
||||
quota_storage_extra = 50M
|
||||
}
|
||||
|
||||
# allow user to delete messages
|
||||
quota_rule2 = Trash:storage=+50M
|
||||
# TODO describe
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#quota-grace
|
||||
quota_storage_grace = 10M
|
||||
|
||||
quota_grace = 10%%
|
||||
# 10% is the default
|
||||
quota_warning = storage=95%% quota-warning 95 %u %d
|
||||
quota_warning2 = storage=80%% quota-warning 80 %u %d
|
||||
quota_warning3 = -storage=100%% quota-warning below %u %d # user is no longer over quota
|
||||
# Warnings
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#quota-warning-scripts
|
||||
quota user {
|
||||
warning warn-80 {
|
||||
quota_storage_percentage = 80
|
||||
execute quota-warning {
|
||||
args = 80 %{user}
|
||||
}
|
||||
}
|
||||
|
||||
warning warn-95 {
|
||||
quota_storage_percentage = 95
|
||||
execute quota-warning {
|
||||
args = 95 %{user}
|
||||
}
|
||||
}
|
||||
|
||||
quota_status_success=DUNNO
|
||||
quota_status_nouser=DUNNO
|
||||
quota_status_overquota = "552 5.2.2 Mailbox is full"
|
||||
warning warn-under {
|
||||
quota_storage_percentage = 100
|
||||
# user is no longer over quota
|
||||
threshold = under
|
||||
execute quota-warning {
|
||||
args = below %{user}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
service quota-warning {
|
||||
executable = script /usr/local/bin/quota-warning
|
||||
user = dovecot
|
||||
group = dovecot
|
||||
unix_listener quota-warning {
|
||||
user = dovecot
|
||||
group = dovecot
|
||||
mode = 0660
|
||||
}
|
||||
}
|
||||
|
||||
# allow postfix to query quota
|
||||
# Allow postfix to query quota
|
||||
#
|
||||
# ref: https://doc.dovecot.org/main/core/plugins/quota.html#quota-service
|
||||
service quota-status {
|
||||
executable = quota-status -p postfix
|
||||
inet_listener {
|
||||
address = 127.0.0.1
|
||||
inet_listener quota-status {
|
||||
listen = 127.0.0.1
|
||||
port = 65265
|
||||
}
|
||||
client_limit = 1
|
||||
}
|
||||
|
||||
|
||||
@ -169,11 +169,11 @@ function _setup_dovecot_quota() {
|
||||
local MAILBOX_LIMIT_MB=$((POSTFIX_MAILBOX_SIZE_LIMIT / 1000000))
|
||||
|
||||
sedfile -i \
|
||||
"s|quota_max_mail_size =.*|quota_max_mail_size = ${MESSAGE_SIZE_LIMIT_MB}$([[ ${MESSAGE_SIZE_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
||||
"s|quota_mail_size =.*|quota_mail_size = ${MESSAGE_SIZE_LIMIT_MB}$([[ ${MESSAGE_SIZE_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
||||
/etc/dovecot/conf.d/90-quota.conf
|
||||
|
||||
sedfile -i \
|
||||
"s|quota_rule = \*:storage=.*|quota_rule = *:storage=${MAILBOX_LIMIT_MB}$([[ ${MAILBOX_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
||||
"s|quota_storage_size = .*|quota_storage_size = ${MAILBOX_LIMIT_MB}$([[ ${MAILBOX_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
||||
/etc/dovecot/conf.d/90-quota.conf
|
||||
|
||||
if [[ -d /tmp/docker-mailserver ]] && [[ ! -f /tmp/docker-mailserver/dovecot-quotas.cf ]]; then
|
||||
|
||||
@ -26,7 +26,7 @@ EOF
|
||||
|
||||
# service lmtp {
|
||||
# inet_listener lmtp {
|
||||
# address = 127.0.0.1
|
||||
# listen = 127.0.0.1
|
||||
# port = 24
|
||||
# }
|
||||
# }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user