manga-dlp/docker/rootfs/etc/cont-init.d/51-fix-schedule.sh

31 lines
1 KiB
Bash
Raw Normal View History

#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# source env variables
source /etc/cont-init.d/20-setenv.sh
# check schedule
2022-07-19 22:45:00 +02:00
[[ -f "/app/schedules/daily.sh" ]] && DAILY_SH_FOUND=true
[[ -f "/app/schedules/daily" ]] && DAILY_FOUND=true
# check crontab
if grep -q -e "/app/schedules/daily.sh\s" /etc/cron.d/mangadlp; then
2022-07-19 22:45:00 +02:00
CRON_SH_FOUND=true
elif grep -q -e "/app/schedules/daily\s" /etc/cron.d/mangadlp; then
2022-07-19 22:45:00 +02:00
CRON_FOUND=true
fi
# fix new .sh schedule if its not synced with the crontab
2022-07-19 22:45:00 +02:00
if [[ "${CRON_SH_FOUND}" == "true" ]] && [[ "${DAILY_SH_FOUND}" != "true" ]]; then
echo "Fixing new .sh schedule"
2022-07-19 22:45:00 +02:00
echo "Adding symlink to daily.sh"
if ! ln -s /app/schedule/daily /app/schedule/daily.sh; then
echo "Cant fix schedule. Maybe the file is missing."
fi
2022-07-19 22:45:00 +02:00
elif [[ "${CRON_FOUND}" == "true" ]] && [[ "${DAILY_FOUND}" != "true" ]]; then
echo "Fixing new .sh schedule"
2022-07-19 22:45:00 +02:00
echo "Adding symlink to daily"
if ! ln -s /app/schedule/daily.sh /app/schedule/daily; then
echo "Cant fix schedule. Maybe the file is missing."
fi
fi