diff --git a/README.md b/README.md index a6319431..e3492dbb 100644 --- a/README.md +++ b/README.md @@ -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 `. 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 `. Make sure to mount the correct configuration directory. +1. Use `setup.sh`: `./setup.sh email add ` +2. Run the command directly in the container: `docker exec -ti setup email add ` You can then proceed by creating the postmaster alias and by creating DKIM keys. diff --git a/target/scripts/startup/setup-stack.sh b/target/scripts/startup/setup-stack.sh index b54c410e..e838a9bd 100644 --- a/target/scripts/startup/setup-stack.sh +++ b/target/scripts/startup/setup-stack.sh @@ -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