Skip to content

Commit e14eecc

Browse files
authored
Update Recyclarr
1 parent 512286d commit e14eecc

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

universal/services/Recyclarr

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ source /config/extended/functions
99
#### Create Log File
1010
logfileSetup
1111

12-
logfile="/config/logs/$logFileName"
13-
14-
# Redirect all output to the log file
15-
exec &> >(tee -a "$logfile")
12+
# Redirect all output to a temporary log file to avoid duplicate logs
13+
exec &> >(tee -a /tmp/recyclarr_temp.log)
1614

1715
#### Check Arr App
1816
getArrAppInfo
@@ -35,21 +33,29 @@ RecyclarrProcess () {
3533
sed -i "s%arrUrl%$arrUrl%g" "/config/extended/recyclarr.yaml"
3634
sed -i "s%arrApi%$arrApiKey%g" "/config/extended/recyclarr.yaml"
3735

38-
# update arr app
36+
# Update arr app
3937
log "Updating Arr via Recyclarr"
4038
if [ ! -d /config/extended/recyclarr-data ]; then
4139
mkdir -p /config/extended/recyclarr-data
4240
chmod 777 /config/extended/recyclarr-data
4341
fi
4442

4543
# Run Recyclarr and capture the output
46-
/recyclarr/recyclarr sync -c $recyclarrConfig --app-data /config/extended/recyclarr-data 2>&1 | tee -a "$logfile" | while IFS= read -r line; do
47-
echo "$(date "+%F %T") :: $scriptName :: $scriptVersion :: $line"
48-
done >> "$logfile"
44+
/recyclarr/recyclarr sync -c $recyclarrConfig --app-data /config/extended/recyclarr-data 2>&1 | while IFS= read -r line; do
45+
log "$line"
46+
done
4947

5048
log "Complete"
5149
}
5250

51+
# Move the temporary log file to the final log file
52+
move_logs() {
53+
while IFS= read -r line; do
54+
echo "$(date "+%F %T") :: $scriptName :: $scriptVersion :: $line" >> "/config/logs/$logFileName"
55+
done < /tmp/recyclarr_temp.log
56+
rm /tmp/recyclarr_temp.log
57+
}
58+
5359
# Loop Script
5460
for (( ; ; )); do
5561
let i++
@@ -60,6 +66,7 @@ for (( ; ; )); do
6066
RecyclarrProcess
6167
log "Script sleeping for $recyclarrScriptInterval..."
6268
sleep $recyclarrScriptInterval
69+
move_logs
6370
done
6471

6572
exit

0 commit comments

Comments
 (0)