ubuntu working, headless next
This commit is contained in:
parent
c2383614f3
commit
c69c18f623
6 changed files with 42 additions and 27 deletions
|
|
@ -5,51 +5,56 @@ if [ "$YTDL_SUB_TYPE" != "gui" ] ; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking ytdl-sub-gui defaults..."
|
# always create the config dir with empty cron logs
|
||||||
|
mkdir -p /config/ytdl-sub-configs
|
||||||
|
echo "" > /config/ytdl-sub-configs/cron_logs.txt
|
||||||
|
|
||||||
# clear the cron logs on start, always
|
echo "[ytdl-sub-init] Checking defaults..."
|
||||||
echo > /config/ytdl-sub-configs/cron_logs.txt
|
|
||||||
|
|
||||||
# copy config
|
# copy config
|
||||||
[[ ! -e /config/ytdl-sub-configs/config.yaml ]] && \
|
[[ ! -e /config/ytdl-sub-configs/config.yaml ]] && \
|
||||||
mkdir -p /config/ytdl-sub-configs && \
|
|
||||||
cp /defaults/config.yaml /config/ytdl-sub-configs/config.yaml
|
cp /defaults/config.yaml /config/ytdl-sub-configs/config.yaml
|
||||||
[[ ! -e /config/ytdl-sub-configs/subscriptions.yaml ]] && \
|
[[ ! -e /config/ytdl-sub-configs/subscriptions.yaml ]] && \
|
||||||
mkdir -p /config/ytdl-sub-configs && \
|
|
||||||
cp /defaults/subscriptions.yaml /config/ytdl-sub-configs/subscriptions.yaml
|
cp /defaults/subscriptions.yaml /config/ytdl-sub-configs/subscriptions.yaml
|
||||||
[[ ! -d /config/ytdl-sub-configs/examples ]] && \
|
[[ ! -d /config/ytdl-sub-configs/examples ]] && \
|
||||||
mkdir -p /config/ytdl-sub-configs/examples && \
|
mkdir -p /config/ytdl-sub-configs/examples && \
|
||||||
cp /defaults/examples/* /config/ytdl-sub-configs/examples
|
cp -r /defaults/examples/* /config/ytdl-sub-configs/examples
|
||||||
[[ ! -d /config/ytdl-sub-configs/cron_script ]] && \
|
[[ ! -d /config/ytdl-sub-configs/cron_script ]] && \
|
||||||
mkdir -p /config/ytdl-sub-configs && \
|
|
||||||
cp /defaults/cron_script /config/ytdl-sub-configs/cron_script
|
cp /defaults/cron_script /config/ytdl-sub-configs/cron_script
|
||||||
|
chmod +x /config/ytdl-sub-configs/cron_script
|
||||||
|
|
||||||
|
# permissions
|
||||||
|
chown -R ${PUID:-abc}:${PGID:-abc} \
|
||||||
|
/config
|
||||||
|
|
||||||
if [ -n "$CRON_SCHEDULE" ] ; then
|
if [ -n "$CRON_SCHEDULE" ] ; then
|
||||||
# put it into the crontab file
|
# copy cron wrapper over
|
||||||
echo "# min hour day month weekday command" > /config/crontabs/abc
|
cp /defaults/cron_wrapper.gui /opt/cron_wrapper
|
||||||
echo " ${CRON_SCHEDULE} /config/ytdl-sub-configs/cron_script | tee -a /config/ytdl-sub-configs/cron_logs.txt" >> /config/crontabs/abc
|
chmod +x /opt/cron_wrapper
|
||||||
|
chown abc:abc /opt/cron_wrapper
|
||||||
|
|
||||||
|
# execute cron wrapper in the crontab file
|
||||||
|
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > /config/crontabs/abc
|
||||||
|
echo "" >> /config/crontabs/abc
|
||||||
|
echo "# min hour day month weekday command" >> /config/crontabs/abc
|
||||||
|
echo " ${CRON_SCHEDULE} /opt/cron_wrapper" >> /config/crontabs/abc
|
||||||
|
|
||||||
# restart cron
|
# restart cron
|
||||||
/etc/init.d/cron reload
|
/etc/init.d/cron reload
|
||||||
|
|
||||||
# check cron
|
# check cron
|
||||||
crontab -u abc -l
|
crontab -u abc /config/crontabs/abc
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
if [ $ret -eq 0 ]; then
|
if [ $ret -eq 0 ]; then
|
||||||
echo "Cron schedule is successfully set to ${CRON_SCHEDULE}"
|
echo "[ytdl-sub-init] Cron schedule is successfully set to ${CRON_SCHEDULE}"
|
||||||
if [ "$CRON_RUN_ON_START" = true ] ; then
|
if [ -n "$CRON_RUN_ON_START" ] ; then
|
||||||
# Run cron script on start
|
# Run cron script on start, logs get emitted to docker so do not write to cron logs
|
||||||
su - abc -c "/config/ytdl-sub-configs/cron_script | tee -a /config/ytdl-sub-configs/cron_logs.txt" &
|
echo "[ytdl-sub-init] Cron on start enabled, starting"
|
||||||
|
sudo -b -u abc bash -c "cd /config/ytdl-sub-configs && ./cron_script"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Cron schedule is invalid, disabling"
|
echo "[ytdl-sub-init] Cron schedule is invalid, disabling"
|
||||||
|
sleep 10
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# permissions
|
|
||||||
chown -R ${PUID:-abc}:${PGID:-abc} \
|
|
||||||
/config
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,11 @@ if [ "$YTDL_SUB_TYPE" == "gui" ] ; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking ytdl-sub defaults..."
|
# always create the config dir with empty cron logs
|
||||||
|
mkdir -p /config
|
||||||
|
echo "" > /config/cron_logs.txt
|
||||||
|
|
||||||
|
echo "[ytdl-sub-init] Checking defaults..."
|
||||||
|
|
||||||
# copy config
|
# copy config
|
||||||
[[ ! -e /config/config.yaml ]] && \
|
[[ ! -e /config/config.yaml ]] && \
|
||||||
|
|
|
||||||
3
docker/root/defaults/cron_wrapper.gui
Normal file
3
docker/root/defaults/cron_wrapper.gui
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cd /config/ytdl-sub-configs
|
||||||
|
bash ./cron_script | tee -a ./cron_logs.txt
|
||||||
3
docker/root/defaults/cron_wrapper.headless
Normal file
3
docker/root/defaults/cron_wrapper.headless
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cd /config
|
||||||
|
bash ./cron_script | tee -a ./cron_logs.txt
|
||||||
|
|
@ -6,7 +6,7 @@ services:
|
||||||
- PUID=1000
|
- PUID=1000
|
||||||
- PGID=1000
|
- PGID=1000
|
||||||
- TZ=America/Los_Angeles
|
- TZ=America/Los_Angeles
|
||||||
- CRON_SCHEDULE=* * * * */1
|
- CRON_SCHEDULE=* * * * * */1
|
||||||
- CRON_RUN_ON_START=True
|
- CRON_RUN_ON_START=True
|
||||||
volumes:
|
volumes:
|
||||||
- ./volumes/ytdl-sub-gui:/config
|
- ./volumes/ytdl-sub-gui:/config
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
__pypi_version__ = "2024.06.19.post1"
|
__pypi_version__ = "2024.06.19.post2"
|
||||||
__local_version__ = "2024.06.19+94db90f1"
|
__local_version__ = "2024.06.19+c2383614"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue