setup: added grace period for account creation (#2531)

This commit is contained in:
Georg Lauterbach 2022-04-18 10:48:48 +02:00 committed by GitHub
parent 3cb5668b6f
commit 412f675bfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View File

@ -131,10 +131,10 @@ NAME
#### Starting for the first time
On first start, you will likely see an error stating that there are no mail accounts and the container will exit. You must now do one of two things:
On first start, you will need to add at least one email account (unless you're using LDAP). You have two minutes to do so, otherwise DMS will shutdown and restart. You can add accounts with the following two methods:
1. Use `setup.sh` to help you: `./setup.sh email add <user@domain> <password>`. You may need the `-c` option to provide the local path for persisting configuration (_a directory that mounts to `/tmp/docker-mailserver` inside the container_). This will spin up a new container, mount your configuration volume, and create your first account.
2. Execute the complete command yourself: `docker run --rm -v "${PWD}/docker-data/dms/config/:/tmp/docker-mailserver/" docker.io/mailserver/docker-mailserver setup email add <user@domain> <password>`. Make sure to mount the correct configuration directory.
1. Use `setup.sh`: `./setup.sh email add <user@domain>`
2. Run the command directly in the container: `docker exec -ti <CONTAINER NAME> setup email add <user@domain>`
You can then proceed by creating the postmaster alias and by creating DKIM keys.

View File

@ -290,19 +290,26 @@ function _setup_dovecot_local_user
_log 'debug' 'Setting up Dovecot Local User'
_create_accounts
[[ ${ENABLE_LDAP} -eq 1 ]] && return 0
if [[ ! -f /tmp/docker-mailserver/postfix-accounts.cf ]]
then
_log 'trace' "'/tmp/docker-mailserver/postfix-accounts.cf' is not provided. No mail account created."
_log 'trace' "'/tmp/docker-mailserver/postfix-accounts.cf' not provided, no mail account created"
fi
if ! grep '@' /tmp/docker-mailserver/postfix-accounts.cf 2>/dev/null | grep -q '|'
then
if [[ ${ENABLE_LDAP} -eq 0 ]]
local SLEEP_PERIOD='10'
for (( COUNTER = 11 ; COUNTER >= 0 ; COUNTER-- ))
do
if [[ $(grep -cE '.+@.+\|' /tmp/docker-mailserver/postfix-accounts.cf) -ge 1 ]]
then
_shutdown 'Unless using LDAP, you need at least 1 email account to start Dovecot'
return 0
else
_log 'warn' "You need at least one email account to start Dovecot ($(( ( COUNTER + 1 ) * SLEEP_PERIOD ))s left for account creation before shutdown)"
sleep "${SLEEP_PERIOD}"
fi
fi
done
_shutdown 'No accounts provided - Dovecot could not be started'
}
function _setup_ldap