58 lines
1.6 KiB
Text
58 lines
1.6 KiB
Text
#!/usr/bin/with-contenv bash
|
|
|
|
# Exit if not gui
|
|
if [ "$YTDL_SUB_TYPE" != "gui" ] ; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "Checking ytdl-sub-gui defaults..."
|
|
|
|
# copy config
|
|
[[ ! -e /config/ytdl-sub-configs/config.yaml ]] && \
|
|
mkdir -p /config/ytdl-sub-configs && \
|
|
cp /defaults/config.yaml /config/ytdl-sub-configs/config.yaml
|
|
[[ ! -e /config/ytdl-sub-configs/subscriptions.yaml ]] && \
|
|
mkdir -p /config/ytdl-sub-configs && \
|
|
cp /defaults/subscriptions.yaml /config/ytdl-sub-configs/subscriptions.yaml
|
|
[[ ! -d /config/ytdl-sub-configs/examples ]] && \
|
|
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
|