diff --git a/docker/entrypoint-collector.sh b/docker/entrypoint-collector.sh index 97a6eda..d51e5e3 100755 --- a/docker/entrypoint-collector.sh +++ b/docker/entrypoint-collector.sh @@ -1,9 +1,9 @@ #!/bin/bash + # Cron runs in its own isolated environment (usually using only /etc/environment ) # So when the container starts up, we will do a dump of the runtime environment into a .env file that we -# will then source into the crontab file (/etc/cron.d/scrutiny.sh) - -printenv | sed 's/^\(.*\)$/export \1/g' > /env.sh +# will then source into the crontab file (/etc/cron.d/scrutiny) +(set -o posix; export -p) > /env.sh # adding ability to customize the cron schedule. COLLECTOR_CRON_SCHEDULE=${COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} @@ -11,6 +11,7 @@ COLLECTOR_CRON_SCHEDULE=${COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} # if the cron schedule has been overridden via env variable (eg docker-compose) we should make sure to strip quotes [[ "${COLLECTOR_CRON_SCHEDULE}" == \"*\" || "${COLLECTOR_CRON_SCHEDULE}" == \'*\' ]] && COLLECTOR_CRON_SCHEDULE="${COLLECTOR_CRON_SCHEDULE:1:-1}" +# replace placeholder with correct value sed -i 's|{COLLECTOR_CRON_SCHEDULE}|'"${COLLECTOR_CRON_SCHEDULE}"'|g' /etc/cron.d/scrutiny # now that we have the env start cron in the foreground diff --git a/rootfs/etc/cont-init.d/50-config b/rootfs/etc/cont-init.d/50-cron-config similarity index 55% rename from rootfs/etc/cont-init.d/50-config rename to rootfs/etc/cont-init.d/50-cron-config index 53fd249..eaf1923 100644 --- a/rootfs/etc/cont-init.d/50-config +++ b/rootfs/etc/cont-init.d/50-cron-config @@ -1,5 +1,11 @@ #!/usr/bin/with-contenv bash +# Cron runs in its own isolated environment (usually using only /etc/environment ) +# So when the container starts up, we will do a dump of the runtime environment into a .env file that we +# will then source into the crontab file (/etc/cron.d/scrutiny) +(set -o posix; export -p) > /env.sh + +# adding ability to customize the cron schedule. COLLECTOR_CRON_SCHEDULE=${COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} # if the cron schedule has been overridden via env variable (eg docker-compose) we should make sure to strip quotes diff --git a/rootfs/etc/services.d/cron/run b/rootfs/etc/services.d/cron/run index 767d1a3..0c6025f 100755 --- a/rootfs/etc/services.d/cron/run +++ b/rootfs/etc/services.d/cron/run @@ -1,10 +1,4 @@ #!/usr/bin/with-contenv bash -# Cron runs in its own isolated environment (usually using only /etc/environment ) -# So when the container starts up, we will do a dump of the runtime environment into a .env file that we -# will then source into the crontab file (/etc/cron.d/scrutiny.sh) - -(set -o posix; export -p) > /env.sh - echo "starting cron" cron -f -L 15