From 62d4b3f518dab9c35520edabcf1b8dce76dd1688 Mon Sep 17 00:00:00 2001 From: billsbdb3 <64713235+billsbdb3@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:41:10 -0400 Subject: [PATCH] Update Recyclarr --- universal/services/Recyclarr | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/universal/services/Recyclarr b/universal/services/Recyclarr index 8c7458e..0d361af 100644 --- a/universal/services/Recyclarr +++ b/universal/services/Recyclarr @@ -9,12 +9,12 @@ source /config/extended/functions #### Create Log File logfileSetup -# Redirect all output to a temporary log file to avoid duplicate logs -exec &> >(tee -a /tmp/recyclarr_temp.log) +logfile="/config/logs/$logFileName" -#### Check Arr App -getArrAppInfo -verifyApiAccess +log() { + m_time=$(date "+%F %T") + echo "$m_time :: $scriptName :: $scriptVersion :: $1" | tee -a "$logfile" +} verifyConfig () { if [ "$enableRecyclarr" != "true" ]; then @@ -28,13 +28,13 @@ verifyConfig () { fi } -RecyclarrProcess () { +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" + sed -i "s%arrApi%$arrApiKey%g" "/config/extended/recyclarr.yaml" - # Update arr app log "Updating Arr via Recyclarr" + if [ ! -d /config/extended/recyclarr-data ]; then mkdir -p /config/extended/recyclarr-data chmod 777 /config/extended/recyclarr-data @@ -42,23 +42,14 @@ RecyclarrProcess () { # Run Recyclarr and capture the output /recyclarr/recyclarr sync -c $recyclarrConfig --app-data /config/extended/recyclarr-data 2>&1 | while IFS= read -r line; do - log "$line" + echo "$(date "+%F %T") :: $scriptName :: $scriptVersion :: $line" | tee -a "$logfile" done - + log "Complete" } -# Move the temporary log file to the final log file -move_logs() { - while IFS= read -r line; do - echo "$(date "+%F %T") :: $scriptName :: $scriptVersion :: $line" >> "/config/logs/$logFileName" - done < /tmp/recyclarr_temp.log - rm /tmp/recyclarr_temp.log -} - -# Loop Script +# Main Loop for (( ; ; )); do - let i++ logfileSetup verifyConfig getArrAppInfo @@ -66,7 +57,6 @@ for (( ; ; )); do RecyclarrProcess log "Script sleeping for $recyclarrScriptInterval..." sleep $recyclarrScriptInterval - move_logs done exit