Skip to content

[FR] Enhanced all-in-one ./setup.sh email list (with quotas, disk usage and aliases) #1892

@tdeseez

Description

@tdeseez

Feature Request

Display a enhanced all-in-one ./setup.sh email list with quotas, disk usage and aliases for each user with one single command.

Context

Common usage. The aim is to have more info with one glimpse.

Is your Feature Request related to a Problem?

No. Simply an enhancement proposal.

Describe the Solution you'd like

The ./setup.sh email list command could display users info like this :

Are you going to implement it?

Yes, because I know the probability of someone else doing it is low and I can learn from it.

What are you going to contribute??

Here is sample bash script which runs fine from my docker-compose working directory ;

#! /bin/bash

# shellcheck source=../scripts/helper-functions.sh
#. /usr/local/bin/helper-functions.sh

#DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-virtual.cf}
DATABASE="config/postfix-accounts.cf"
ALIASES="config/postfix-virtual.cf"
QUOTAS="config/dovecot-quotas.cf"
DOCKER_MAILDATA="/var/lib/docker/volumes/docker-mailserver_maildata/_data/"
set user_found, user_data_dir, user_quota

#[[ -f ${DATABASE} ]] || errex "Error: No postfix-virtual.cf file"
#[[ -s ${DATABASE} ]] || errex "Error: Empty postfix-virtual.cf - no aliases have been added"

#grep -v "^\s*$\|^\s*\#" "${DATABASE}"
#{ grep -v "^\s*$\|^\s*\#" "${DATABASE}" || true ; } | awk -F '|' '{ print $1; }'

while read line
do
    user_found=$(echo "${line}" | awk -F '|' '{ print $1; }')
    user_data_dir=`echo "${DOCKER_MAILDATA}"$(echo "${user_found}" | awk -F '@' '{ print $2; }')/$(echo "${user_found}" | awk -F '@' '{ print $1; }')/cur`
    user_quota="~"

    # Display disk usage and quotas for specific mailbox user
    if grep -q "${user_found}" "${QUOTAS}"
    then
       user_quota=$(grep "${user_found}" "${QUOTAS}" | awk -F ':' '{ print $2; }') ;
    fi

    echo "* ${user_found} (" $(du -sh "${user_data_dir}" | awk '{ print $1; }') / "${user_quota} )"

    # Display available aliases for specific mailbox user
    echo -e "    [ aliases ->" $(grep "${user_found}" "${ALIASES}" | awk '{print $1;}' | sed ':a;N;$!ba;s/\n/, /g') "]\n"
done < "${DATABASE}"

exit 0

Additional context

Not sure i want/have skill to "commit" directly in the project, but I think this script can be helpful (though it's certainly not perfect as it is).

Alternatives you've considered

Who will that Feature be useful to?

Everyone running and managing docker-mailserver.

What have you done already?

a sample bash script !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions