[FEATURE] Orchestrate cron using Docker Env variables"

This commit is contained in:
Jesse Bannon 2024-06-19 00:00:04 -07:00
parent f7305ebf8a
commit 94db90f113
6 changed files with 48 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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"