diff --git a/docker/Dockerfile b/docker/Dockerfile index e9015270..89fe6f84 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -55,6 +55,8 @@ RUN mkdir -p /config && \ # CONTAINER CONFIGS ENV EDITOR="nano" \ -HOME="/config" +HOME="/config" \ +DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \ +LOGS_TO_STDOUT=/config/cron_logs.txt VOLUME /config \ No newline at end of file diff --git a/docker/Dockerfile.gui b/docker/Dockerfile.gui index bd745f0e..6689300f 100644 --- a/docker/Dockerfile.gui +++ b/docker/Dockerfile.gui @@ -81,7 +81,8 @@ RUN mkdir -p /config && \ ENV YTDL_SUB_TYPE="gui" \ EDITOR="nano" \ HOME="/config" \ -DOCKER_MODS=linuxserver/mods:universal-cron \ +DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \ +LOGS_TO_STDOUT=/config/ytdl-sub-configs/cron_logs.txt \ DEFAULT_WORKSPACE=/config/ytdl-sub-configs VOLUME /config \ No newline at end of file diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index 798e07a3..2c37edf6 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -81,6 +81,8 @@ RUN mkdir -p /config && \ # CONTAINER CONFIGS ENV EDITOR="nano" \ -HOME="/config" +HOME="/config" \ +DOCKER_MODS=linuxserver/mods:universal-stdout-logs|linuxserver/mods:universal-cron \ +LOGS_TO_STDOUT=/config/cron_logs.txt VOLUME /config \ No newline at end of file diff --git a/docker/root/custom-cont-init.d/defaults-gui b/docker/root/custom-cont-init.d/defaults-gui index 01affd47..38cece86 100644 --- a/docker/root/custom-cont-init.d/defaults-gui +++ b/docker/root/custom-cont-init.d/defaults-gui @@ -18,6 +18,41 @@ echo "Checking ytdl-sub-gui defaults..." mkdir -p /config/ytdl-sub-configs/examples && \ cp /defaults/examples/* /config/ytdl-sub-configs/examples +if [ "$CRON_ENABLE" = true ] ; then + + # set cron schedule if not set + if [ -z "${CRON_SCHEDULE}" ] ; then + CRON_SCHEDULE="0 */6 * * *" + fi + + # put it into the crontab file + echo "# min hour day month weekday command" > /config/crontabs/abc + echo " ${CRON_SCHEDULE} /config/ytdl-sub-configs/cron_script | tee -a /config/ytdl-sub-configs/cron_logs.txt" >> /config/crontabs/abc + + # clear the cron logs on start, always + echo > /config/ytdl-sub-configs/cron_logs.txt + + # restart cron + /etc/init.d/cron restart + + # check cron + crontab -u abc -l + ret=$? + + if [ $ret -eq 0 ]; then + echo "Cron schedule is successfully set to ${CRON_SCHEDULE}" + if [ "$CRON_RUN_ON_START" = true ] ; then + # Run cron script on start + /config/ytdl-sub-configs/cron_script | tee -a /config/ytdl-sub-configs/cron_logs.txt & + fi + else + echo "Cron schedule is invalid, disabling" + fi +fi + + + + # permissions chown -R ${PUID:-abc}:${PGID:-abc} \ /config diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml index 1a8797b9..c61ce947 100644 --- a/docker/testing/docker-compose.yml +++ b/docker/testing/docker-compose.yml @@ -6,6 +6,9 @@ services: - PUID=1000 - PGID=1000 - TZ=America/Los_Angeles + - CRON_ENABLE=True + - CRON_SCHEDULE=* * * * */1 + - CRON_RUN_ON_START=True volumes: - ./volumes/ytdl-sub-gui:/config ports: diff --git a/src/ytdl_sub/__init__.py b/src/ytdl_sub/__init__.py index a1ae89f9..d5b6ba3a 100644 --- a/src/ytdl_sub/__init__.py +++ b/src/ytdl_sub/__init__.py @@ -1,2 +1,2 @@ -__pypi_version__ = "2023.10.22.post3" -__local_version__ = "2023.10.22+bfba4f0" +__pypi_version__ = "2024.06.18" +__local_version__ = "2024.06.18+f7305ebf"