From d3e0d6908f98b3d876bd7d869e32d584a5361cd8 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 15 Mar 2025 13:44:47 -0700 Subject: [PATCH] more --- docker/root/custom-cont-init.d/defaults | 22 ++++++++++++++++++---- docker/root/defaults/cron | 4 ++-- docker/root/defaults/cron_wrapper | 2 +- docker/testing/docker-compose.yml | 1 + 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docker/root/custom-cont-init.d/defaults b/docker/root/custom-cont-init.d/defaults index 7ceae51b..0fb1789f 100644 --- a/docker/root/custom-cont-init.d/defaults +++ b/docker/root/custom-cont-init.d/defaults @@ -13,9 +13,6 @@ echo "Starting ytdl-sub..." mkdir -p "$DEFAULT_WORKSPACE/examples" && \ cp -r /defaults/examples/* "$DEFAULT_WORKSPACE/examples" -# always create cron log file -touch "$LOGS_TO_STDOUT" - # permissions chown -R ${PUID:-abc}:${PGID:-abc} \ /config @@ -39,7 +36,24 @@ if [ "$CRON_SCHEDULE" != "" ] ; then chown abc:abc "$CRON_SCRIPT" crontab -u abc /config/crontabs/abc + + CRON_SUCCESS=$? + if [ $CRON_SUCCESS -eq 0 ] ; then + echo "Cron enabled with schedule $CRON_SCHEDULE_CLEAN" + + if [ "$CRON_RUN_ON_START" = true ] ; then + echo "Running cron script on start" + . "$CRON_WRAPPER_SCRIPT" + fi + else + echo "Error in CRON_SCHEDULE definition, disabling cron." + fi else echo "CRON_SCHEDULE not specified, disabling cron." echo "# min hour day month weekday command" > /config/crontabs/abc -fi \ No newline at end of file + echo "" >> /config/crontabs/abc +fi + +# always create cron log file, after cron runs +# on start to not tail it again +echo "" > "$LOGS_TO_STDOUT" diff --git a/docker/root/defaults/cron b/docker/root/defaults/cron index 20690777..6fdbea71 100644 --- a/docker/root/defaults/cron +++ b/docker/root/defaults/cron @@ -1,4 +1,4 @@ echo "Beginning cron job..." -# Place your ytdl-sub command here -# ytdl-sub -h \ No newline at end of file +# Place your ytdl-sub command(s) here. +# This script is executed in the same relative path as this file. \ No newline at end of file diff --git a/docker/root/defaults/cron_wrapper b/docker/root/defaults/cron_wrapper index 6403cb67..6dd1c64e 100644 --- a/docker/root/defaults/cron_wrapper +++ b/docker/root/defaults/cron_wrapper @@ -2,4 +2,4 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin cd "$DEFAULT_WORKSPACE" -. "$CRON_SCRIPT" | tee "$LOGS_TO_STDOUT" \ No newline at end of file +. "$CRON_SCRIPT" | tee -a "$LOGS_TO_STDOUT" \ No newline at end of file diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml index 0b063d2b..600362d0 100644 --- a/docker/testing/docker-compose.yml +++ b/docker/testing/docker-compose.yml @@ -7,6 +7,7 @@ services: - PGID=1000 - TZ=America/Los_Angeles - CRON_SCHEDULE="*/1 * * * *" + - CRON_RUN_ON_START=false volumes: - ./volumes/ytdl-sub-gui:/config ports: