fix(listmailuser): Don't query quota, if ENABLE_QUOTAS is not 1

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
Casper 2021-11-01 12:09:47 +01:00 committed by GitHub
parent 71082cb19e
commit c7dec1e330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 27 deletions

View file

@ -3,6 +3,9 @@
# shellcheck source=../scripts/helper-functions.sh
. /usr/local/bin/helper-functions.sh
# suppress error output, e.g. when listmailuser runs in a fresh container (DMS not running)
. /etc/dms-settings 2> /dev/null
function dovecot_quota_to_hr()
{
if [ "${1}" == "-" ]
@ -23,12 +26,16 @@ while read -r LINE
do
USER=$(echo "${LINE}" | cut -d'|' -f1)
# ${QUOTA[0]} => current size
# ${QUOTA[1]} => configured size limit
# ${QUOTA[2]} => usage in percent
IFS=' ' read -r -a QUOTA <<< "$(doveadm quota get -u "${USER}" | tail +2 | awk '{ if ($3 == "STORAGE") { print $4" "$5" "$6 } }')"
echo "* ${USER} ( $(dovecot_quota_to_hr "${QUOTA[0]}") / $(dovecot_quota_to_hr "${QUOTA[1]}") ) [${QUOTA[2]}%]"
if [[ "${ENABLE_QUOTAS}" -eq 1 ]]
then
# ${QUOTA[0]} => current size
# ${QUOTA[1]} => configured size limit
# ${QUOTA[2]} => usage in percent
IFS=' ' read -r -a QUOTA <<< "$(doveadm quota get -u "${USER}" | tail +2 | awk '{ if ($3 == "STORAGE") { print $4" "$5" "$6 } }')"
echo "* ${USER} ( $(dovecot_quota_to_hr "${QUOTA[0]}") / $(dovecot_quota_to_hr "${QUOTA[1]}") ) [${QUOTA[2]}%]"
else
echo "* ${USER}"
fi
if [[ -f ${ALIASES} ]] && grep -q "${USER}" "${ALIASES}"
then