manga-dlp/docker/rootfs/etc/cont-init.d/52-set-schedule.sh

54 lines
1.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
2022-12-30 01:46:53 +01:00
custom_args=(
--path "${MDLP_PATH}"
--read "${MDLP_READ}"
--language "${MDLP_LANGUAGE}"
--chapters "${MDLP_CHAPTERS}"
--format "${MDLP_FILE_FORMAT}"
--wait "${MDLP_WAIT}"
)
function prepare_vars() {
# set log level
case "${MDLP_LOG_LEVEL}" in
"warn")
2022-12-30 01:46:53 +01:00
custom_args+=("--warn")
;;
"debug")
2022-12-30 01:46:53 +01:00
custom_args+=("--debug")
;;
*)
2022-12-30 01:46:53 +01:00
if [[ -n "${MDLP_LOG_LEVEL}" ]]; then
custom_args+=("--loglevel" "${MDLP_LOG_LEVEL}")
fi
;;
esac
# check if forcevol should be used
if [[ "${MDLP_FORCEVOL,,}" == "true" ]]; then
2022-12-30 01:46:53 +01:00
custom_args+=("--forcevol")
fi
}
# set schedule with env variables
function set_vars() {
2022-12-30 01:46:53 +01:00
cat << EOF > "/app/schedules/daily.sh"
#!/bin/bash
python3 /app/manga-dlp.py ${custom_args[@]}
EOF
}
# check if schedule should be generated
if [[ "${MDLP_GENERATE_SCHEDULE,,}" == "true" ]]; then
echo "Generating schedule"
prepare_vars
set_vars
fi