From 0a7844347b1851a5281cd8cfa2339d4fde7d6dc0 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Wed, 19 Jul 2023 18:08:51 +0000 Subject: [PATCH] v1.5 - logging fixes --- sonarr/AutoConfig.service | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/sonarr/AutoConfig.service b/sonarr/AutoConfig.service index 45eb93f..dc35386 100644 --- a/sonarr/AutoConfig.service +++ b/sonarr/AutoConfig.service @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.4" +scriptVersion="1.5" 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,19 +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 666 "/config/logs/AutoConfig.txt" -fi -exec &> >(tee -a "/config/logs/AutoConfig.txt") - - - if [ -f /config/extended/naming.json ]; then log "Using custom Sonarr Naming (/config/extended/naming.json)..." namingJson=$(cat /config/extended/naming.json)