From 5749c906b92b6470ea71892330836dbd5717bf4d Mon Sep 17 00:00:00 2001 From: henmohr Date: Thu, 3 Sep 2026 17:50:49 -0300 Subject: [PATCH 1/2] fix: export mautic db vars to cron jobs (cherry picked from commit e71d349fa6a904eb48e0bc160f18dc3ce4c4b143) Signed-off-by: henmohr --- .docker/scripts/entrypoint_mautic_cron.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.docker/scripts/entrypoint_mautic_cron.sh b/.docker/scripts/entrypoint_mautic_cron.sh index 4330c94e..586359c7 100644 --- a/.docker/scripts/entrypoint_mautic_cron.sh +++ b/.docker/scripts/entrypoint_mautic_cron.sh @@ -60,8 +60,13 @@ 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))' + 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 From e51dee8f9a071059f17c582cfa219a03afd458cc Mon Sep 17 00:00:00 2001 From: henmohr Date: Thu, 10 Sep 2026 16:02:30 -0300 Subject: [PATCH 2/2] fix(shellcheck): silence SC2016 for the cron env fallback line The line is written verbatim into /tmp/cron.env and evaluated later by the cron job, so the variables must not be expanded at generation time. ShellCheck flags the single-quoted string as SC2016. Suppress it explicitly, as already done for the mautic install check below. Signed-off-by: henmohr --- .docker/scripts/entrypoint_mautic_cron.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.docker/scripts/entrypoint_mautic_cron.sh b/.docker/scripts/entrypoint_mautic_cron.sh index 586359c7..657cc5bc 100644 --- a/.docker/scripts/entrypoint_mautic_cron.sh +++ b/.docker/scripts/entrypoint_mautic_cron.sh @@ -65,6 +65,9 @@ chmod 777 /tmp/stdout # 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