From 58f810f21de0813497071d2dfe58bc7e54553186 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Wed, 19 Jul 2023 14:44:28 +0000 Subject: [PATCH] 1.6 - logging fixes --- radarr/AutoConfig.service | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/radarr/AutoConfig.service b/radarr/AutoConfig.service index d13662a..463568b 100644 --- a/radarr/AutoConfig.service +++ b/radarr/AutoConfig.service @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.5" +scriptVersion="1.6" scriptName="AutoConfig" #### Import Settings @@ -10,6 +10,22 @@ log () { echo $m_time" :: $scriptName :: $scriptVersion :: "$1 } +logfileSetup () { + # auto-clean up log file to reduce space usage + if [ -f "/config/logs/$scriptName.txt" ]; then + find /config/logs -type f -name "$scriptName.txt" -size +1024k -delete + fi + + if [ ! -f "/config/logs/$scriptName.txt" ]; then + touch "/config/logs/$scriptName.txt" + chmod 666 "/config/logs/$scriptName.txt" + fi +} + +# Create Log, start writing... +logfileSetup +exec &> >(tee -a "/config/logs/$scriptName.txt") + if [ "$enableAutoConfig" != "true" ]; then log "Script is not enabled, enable by setting enableAutoConfig to \"true\" by modifying the \"/config/extended.conf\" config file..." log "Sleeping (infinity)" @@ -55,17 +71,6 @@ verifyApiAccess () { getArrAppInfo verifyApiAccess -# auto-clean up log file to reduce space usage -if [ -f "/config/logs/AutoConfig.txt" ]; then - find /config/logs -type f -name "AutoConfig.txt" -size +1024k -delete -fi - -if [ ! -f "/config/logs/AutoConfig.txt" ]; then - touch "/config/logs/AutoConfig.txt" - chmod 777 "/config/logs/AutoConfig.txt" -fi -exec &> >(tee -a "/config/logs/AutoConfig.txt") - if [ -f /config/extended/naming.json ]; then log "Using custom Naming (/config/extended/naming.json)..." namingJson=$(cat /config/extended/naming.json)