diff --git a/.docker/scripts/entrypoint_mautic_cron.sh b/.docker/scripts/entrypoint_mautic_cron.sh index 4330c94e..657cc5bc 100644 --- a/.docker/scripts/entrypoint_mautic_cron.sh +++ b/.docker/scripts/entrypoint_mautic_cron.sh @@ -60,8 +60,16 @@ crontab -u www-data /opt/mautic/cron/mautic mkfifo /tmp/stdout chmod 777 /tmp/stdout -# ensure the PHP env vars are present during cronjobs -declare -p | grep 'PHP_INI_VALUE_' > /tmp/cron.env +# ensure the PHP env vars and database settings are present during cronjobs +# The cron daemon does not reliably inherit the container environment into each job, +# so the jobs need an explicit shell environment. +{ + declare -p | grep -E '^(declare -x (PHP_INI_VALUE_|MAUTIC_DB_|MAUTIC_SITE_URL))' + # Written verbatim to /tmp/cron.env and evaluated by the cron job, so the + # variables must NOT be expanded here. + # shellcheck disable=SC2016 + printf '%s\n' 'if [ -n "${MAUTIC_DB_NAME:-}" ] && [ -z "${MAUTIC_DB_DATABASE:-}" ]; then export MAUTIC_DB_DATABASE="$MAUTIC_DB_NAME"; fi' +} > /tmp/cron.env # wait until Mautic is installed # shellcheck disable=SC2016