default cron script

This commit is contained in:
Jesse Bannon 2024-06-19 00:44:51 -07:00
parent 94db90f113
commit c2383614f3
5 changed files with 13 additions and 32 deletions

View file

@ -7,6 +7,9 @@ fi
echo "Checking ytdl-sub-gui defaults..."
# clear the cron logs on start, always
echo > /config/ytdl-sub-configs/cron_logs.txt
# copy config
[[ ! -e /config/ytdl-sub-configs/config.yaml ]] && \
mkdir -p /config/ytdl-sub-configs && \
@ -17,23 +20,17 @@ echo "Checking ytdl-sub-gui defaults..."
[[ ! -d /config/ytdl-sub-configs/examples ]] && \
mkdir -p /config/ytdl-sub-configs/examples && \
cp /defaults/examples/* /config/ytdl-sub-configs/examples
[[ ! -d /config/ytdl-sub-configs/cron_script ]] && \
mkdir -p /config/ytdl-sub-configs && \
cp /defaults/cron_script /config/ytdl-sub-configs/cron_script
if [ "$CRON_ENABLE" = true ] ; then
# set cron schedule if not set
if [ -z "${CRON_SCHEDULE}" ] ; then
CRON_SCHEDULE="0 */6 * * *"
fi
if [ -n "$CRON_SCHEDULE" ] ; then
# 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
/etc/init.d/cron reload
# check cron
crontab -u abc -l
@ -43,7 +40,7 @@ if [ "$CRON_ENABLE" = true ] ; 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 &
su - abc -c "/config/ytdl-sub-configs/cron_script | tee -a /config/ytdl-sub-configs/cron_logs.txt" &
fi
else
echo "Cron schedule is invalid, disabling"

View file

@ -1,19 +1,2 @@
# Bare-bones config. Here are some useful links to get started:
# Walk-through Guide: https://ytdl-sub.readthedocs.io/en/latest/guides/index.html
# Config Examples: https://github.com/jmbannon/ytdl-sub/tree/master/examples
# Prebuilt Presets: https://ytdl-sub.readthedocs.io/en/latest/presets.html
# Config Reference: https://ytdl-sub.readthedocs.io/en/latest/config_reference/index.html
#
# The subscriptions in `subscriptions.yaml` uses prebuilt presets which do not require
# any additions to this config. They can be downloaded using the command:
#
# ytdl-sub --config config.yaml sub subscriptions.yaml
#
# Or dry-ran with:
#
# ytdl-sub --dry-run --config config.yaml sub subscriptions.yaml
#
# See the documentation above on how to build your own custom presets.
#
configuration:
working_directory: ".ytdl-sub-working-directory"

View file

@ -0,0 +1,2 @@
echo "Running cron_script"
ytdl-sub --log-level info --config config.yaml sub subscriptions.yaml

View file

@ -6,7 +6,6 @@ services:
- PUID=1000
- PGID=1000
- TZ=America/Los_Angeles
- CRON_ENABLE=True
- CRON_SCHEDULE=* * * * */1
- CRON_RUN_ON_START=True
volumes:

View file

@ -1,2 +1,2 @@
__pypi_version__ = "2024.06.18"
__local_version__ = "2024.06.18+f7305ebf"
__pypi_version__ = "2024.06.19.post1"
__local_version__ = "2024.06.19+94db90f1"