2022-07-18 18:41:41 +02:00
|
|
|
#!/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
|
2022-07-18 18:41:41 +02:00
|
|
|
# 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
|
2022-07-18 18:41:41 +02:00
|
|
|
elif grep -q -e "/app/schedules/daily\s" /etc/cron.d/mangadlp; then
|
2022-07-19 22:45:00 +02:00
|
|
|
CRON_FOUND=true
|
2022-07-18 18:41:41 +02:00
|
|
|
fi
|
|
|
|
|
2022-12-29 18:46:42 +01:00
|
|
|
# fix new .sh schedule if it's not synced with the crontab
|
2022-07-19 22:45:00 +02:00
|
|
|
if [[ "${CRON_SH_FOUND}" == "true" ]] && [[ "${DAILY_SH_FOUND}" != "true" ]]; then
|
2022-07-18 18:41:41 +02:00
|
|
|
echo "Fixing new .sh schedule"
|
2022-07-19 22:45:00 +02:00
|
|
|
echo "Adding symlink to daily.sh"
|
2022-07-18 18:41:41 +02:00
|
|
|
if ! ln -s /app/schedule/daily /app/schedule/daily.sh; then
|
2022-12-29 18:46:42 +01:00
|
|
|
echo "Can't fix schedule. Maybe the file is missing."
|
2022-07-18 18:41:41 +02:00
|
|
|
fi
|
2022-07-19 22:45:00 +02:00
|
|
|
elif [[ "${CRON_FOUND}" == "true" ]] && [[ "${DAILY_FOUND}" != "true" ]]; then
|
2022-07-18 18:41:41 +02:00
|
|
|
echo "Fixing new .sh schedule"
|
2022-07-19 22:45:00 +02:00
|
|
|
echo "Adding symlink to daily"
|
2022-07-18 18:41:41 +02:00
|
|
|
if ! ln -s /app/schedule/daily.sh /app/schedule/daily; then
|
2022-12-29 18:46:42 +01:00
|
|
|
echo "Can't fix schedule. Maybe the file is missing."
|
2022-07-18 18:41:41 +02:00
|
|
|
fi
|
|
|
|
fi
|