@@ -9,12 +9,12 @@ source /config/extended/functions
99# ### Create Log File
1010logfileSetup
1111
12- # Redirect all output to a temporary log file to avoid duplicate logs
13- exec & > >( tee -a /tmp/recyclarr_temp.log)
12+ logfile=" /config/logs/$logFileName "
1413
15- # ### Check Arr App
16- getArrAppInfo
17- verifyApiAccess
14+ log () {
15+ m_time=$( date " +%F %T" )
16+ echo " $m_time :: $scriptName :: $scriptVersion :: $1 " | tee -a " $logfile "
17+ }
1818
1919verifyConfig () {
2020 if [ " $enableRecyclarr " != " true" ]; then
@@ -28,45 +28,35 @@ verifyConfig () {
2828 fi
2929}
3030
31- RecyclarrProcess () {
31+ RecyclarrProcess () {
3232 # Configure Yaml with URL and API Key
3333 sed -i " s%arrUrl%$arrUrl %g" " /config/extended/recyclarr.yaml"
34- sed -i " s%arrApi%$arrApiKey %g" " /config/extended/recyclarr.yaml"
34+ sed -i " s%arrApi%$arrApiKey %g" " /config/extended/recyclarr.yaml"
3535
36- # Update arr app
3736 log " Updating Arr via Recyclarr"
37+
3838 if [ ! -d /config/extended/recyclarr-data ]; then
3939 mkdir -p /config/extended/recyclarr-data
4040 chmod 777 /config/extended/recyclarr-data
4141 fi
4242
4343 # Run Recyclarr and capture the output
4444 /recyclarr/recyclarr sync -c $recyclarrConfig --app-data /config/extended/recyclarr-data 2>&1 | while IFS= read -r line; do
45- log " $line "
45+ echo " $( date " +%F %T " ) :: $scriptName :: $scriptVersion :: $ line" | tee -a " $logfile "
4646 done
47-
47+
4848 log " Complete"
4949}
5050
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-
59- # Loop Script
51+ # Main Loop
6052for (( ; ; )) ; do
61- let i++
6253 logfileSetup
6354 verifyConfig
6455 getArrAppInfo
6556 verifyApiAccess
6657 RecyclarrProcess
6758 log " Script sleeping for $recyclarrScriptInterval ..."
6859 sleep $recyclarrScriptInterval
69- move_logs
7060done
7161
7262exit
0 commit comments