diff --git a/universal/services/Recycalarr b/universal/services/Recycalarr index dbdfa9c..b7f7647 100644 --- a/universal/services/Recycalarr +++ b/universal/services/Recycalarr @@ -1,20 +1,37 @@ #!/usr/bin/env bash -scriptVersion="1.3" +scriptVersion="1.4" scriptName="Recyclarr" -#### Import Settings -source /config/extended.conf - log () { m_time=`date "+%F %T"` echo $m_time" :: $scriptName :: $scriptVersion :: "$1 } -if [ "$enableRecyclarr" != "true" ]; then - log "Script is not enabled, enable by setting enableRecyclarr 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/Recyclarr.txt" ]; then + find /config/logs -type f -name "Recyclarr.txt" -size +1024k -delete + fi + + if [ ! -f "/config/logs/Recyclarr.txt" ]; then + touch "/config/logs/Recyclarr.txt" + chmod 666 "/config/logs/Recyclarr.txt" + fi + exec &> >(tee -a "/config/logs/Recyclarr.txt") +} + +verifyConfig () { + #### Import Settings + source /config/extended.conf + + if [ "$enableRecyclarr" != "true" ]; then + log "Script is not enabled, enable by setting enableRecyclarr to \"true\" by modifying the \"/config/extended.conf\" config file..." + log "Sleeping (infinity)" + sleep infinity + fi +} + + getArrAppInfo () { # Get Arr App information @@ -57,18 +74,7 @@ verifyApiAccess () { fi done } -RecyclarrProcess () { - # auto-clean up log file to reduce space usage - if [ -f "/config/logs/Recyclarr.txt" ]; then - find /config/logs -type f -name "Recyclarr.txt" -size +1024k -delete - fi - - if [ ! -f "/config/logs/Recyclarr.txt" ]; then - touch "/config/logs/Recyclarr.txt" - chmod 666 "/config/logs/Recyclarr.txt" - fi - exec &> >(tee -a "/config/logs/Recyclarr.txt") - +RecyclarrProcess () { # Configure Yaml with URL and API Key sed -i "s%arrUrl%$arrUrl%g" "/config/extended/recyclarr.yaml" sed -i "s%arrApi%$arrApiKey%g" "/config/extended/recyclarr.yaml" @@ -83,9 +89,11 @@ RecyclarrProcess () { log "Complete" } -log "Starting Script...." +# Loop Script for (( ; ; )); do let i++ + logfileSetup + verifyConfig getArrAppInfo verifyApiAccess RecyclarrProcess