From 75de6ebfe09ae77616858a5089c35139683405a1 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sun, 1 May 2022 22:01:34 -0700 Subject: [PATCH] addign ability to customize the scrutiny collector cron schedule using SCRUTINY_COLLECTOR_CRON_SCHEDULE env variable. similar to https://github.com/linuxserver/docker-scrutiny/pull/19 fixes https://github.com/linuxserver/docker-scrutiny/issues/17 fixes https://github.com/AnalogJ/scrutiny/issues/161 fixes https://github.com/AnalogJ/scrutiny/issues/66 fixes https://github.com/AnalogJ/scrutiny/issues/202 fixes https://github.com/AnalogJ/scrutiny/issues/121 --- docker/entrypoint-collector.sh | 4 ++++ rootfs/etc/cont-init.d/50-config | 4 ++++ rootfs/etc/cron.d/scrutiny | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 rootfs/etc/cont-init.d/50-config diff --git a/docker/entrypoint-collector.sh b/docker/entrypoint-collector.sh index 501c8d5..c94a67b 100755 --- a/docker/entrypoint-collector.sh +++ b/docker/entrypoint-collector.sh @@ -5,6 +5,10 @@ printenv | sed 's/^\(.*\)$/export \1/g' > /env.sh +# adding ability to customize the cron schedule. +SCRUTINY_COLLECTOR_CRON_SCHEDULE=${SCRUTINY_COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} +sed -i 's|{SCRUTINY_COLLECTOR_CRON_SCHEDULE}|'"${SCRUTINY_COLLECTOR_CRON_SCHEDULE}"'|g' /etc/cron.d/scrutiny + # now that we have the env start cron in the foreground echo "starting cron" su -c "cron -l 8 -f" root diff --git a/rootfs/etc/cont-init.d/50-config b/rootfs/etc/cont-init.d/50-config new file mode 100644 index 0000000..3c7cece --- /dev/null +++ b/rootfs/etc/cont-init.d/50-config @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash + +SCRUTINY_COLLECTOR_CRON_SCHEDULE=${SCRUTINY_COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} +sed -i 's|{SCRUTINY_COLLECTOR_CRON_SCHEDULE}|'"${SCRUTINY_COLLECTOR_CRON_SCHEDULE}"'|g' /etc/cron.d/scrutiny \ No newline at end of file diff --git a/rootfs/etc/cron.d/scrutiny b/rootfs/etc/cron.d/scrutiny index f464d04..9571f4b 100644 --- a/rootfs/etc/cron.d/scrutiny +++ b/rootfs/etc/cron.d/scrutiny @@ -11,5 +11,5 @@ MAILTO="" # correctly route collector logs (STDOUT & STDERR) to Cron foreground (collectable by Docker STDOUT) # cron schedule to run daily at midnight: '0 0 * * *' # System environmental variables are stripped by cron, source our dump of the docker environmental variables before each command (/env.sh) -0 0 * * * root . /env.sh; /scrutiny/bin/scrutiny-collector-metrics run >/proc/1/fd/1 2>/proc/1/fd/2 +{SCRUTINY_COLLECTOR_CRON_SCHEDULE} root . /env.sh; /scrutiny/bin/scrutiny-collector-metrics run >/proc/1/fd/1 2>/proc/1/fd/2 # An empty line is required at the end of this file for a valid cron file.