diff --git a/radarr/AutoExtras.service b/radarr/AutoExtras.service index 56687d7..988750c 100644 --- a/radarr/AutoExtras.service +++ b/radarr/AutoExtras.service @@ -1,20 +1,40 @@ #!/usr/bin/env bash -scriptVersion="1.2" +scriptVersion="1.3" scriptName="AutoExtras" -#### Import Settings -source /config/extended.conf - log () { m_time=`date "+%F %T"` echo $m_time" :: $scriptName :: $scriptVersion :: "$1 } -if [ "$enableExtras" != "true" ]; then - log "Script is not enabled, enable by setting enableExtras to \"true\" by modifying the \"/config/extended.conf\" config file..." - log "Sleeping (infinity)" - sleep infinity -fi +logfileSetup () { + # auto-clean up log file to reduce space usage + if [ -f "/config/logs/AutoExtras.txt" ]; then + find /config/logs -type f -name "QueueCleaner.txt" -size +1024k -delete + fi + + if [ ! -f "/config/logs/AutoExtras.txt" ]; then + touch "/config/logs/AutoExtras.txt" + chmod 666 "/config/logs/AutoExtras.txt" + fi + exec &> >(tee -a "/config/logs/AutoExtras.txt") +} + +verifyConfig () { + #### Import Settings + source /config/extended.conf + + if [ "$enableExtras" != "true" ]; then + log "Script is not enabled, enable by setting enableExtras to \"true\" by modifying the \"/config/extended.conf\" config file..." + log "Sleeping (infinity)" + sleep infinity + fi + + if [ -z "$autoExtrasScriptInterval" ]; then + autoExtrasScriptInterval="24h" + fi +} + getArrAppInfo () { # Get Arr App information @@ -53,17 +73,6 @@ verifyApiAccess () { } AutoExtrasProcess () { - - # auto-clean up log file to reduce space usage - if [ -f "/config/logs/AutoExtras.txt" ]; then - find /config/logs -type f -name "AutoExtras.txt" -size +1024k -delete - fi - - if [ ! -f "/config/logs/AutoExtras.txt" ]; then - touch "/config/logs/AutoExtras.txt" - chmod 777 "/config/logs/AutoExtras.txt" - fi - exec &> >(tee -a "/config/logs/AutoExtras.txt") radarrMovieList=$(curl -s --header "X-Api-Key:"${arrApiKey} --request GET "$arrUrl/api/v3/movie") radarrMovieTotal=$(echo "${radarrMovieList}" | jq -r '.[] | select(.hasFile==true) | .id' | wc -l) @@ -78,14 +87,15 @@ AutoExtrasProcess () { } -log "Starting Script...." for (( ; ; )); do let i++ + logfileSetup + verifyConfig getArrAppInfo verifyApiAccess AutoExtrasProcess - log "Script sleeping for 24 hours..." - sleep 24h + log "Script sleeping for $autoExtrasScriptInterval..." + sleep $autoExtrasScriptInterval done exit