From 7a081f6ddf9594ac1aaca0a604016ac92e69f9f9 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Fri, 14 Jul 2023 19:30:36 +0000 Subject: [PATCH] v1.1 improved logging --- universal/services/QueueCleaner | 41 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/universal/services/QueueCleaner b/universal/services/QueueCleaner index 74c0a72..276c468 100644 --- a/universal/services/QueueCleaner +++ b/universal/services/QueueCleaner @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bash -scriptVersion="1.0.6" +scriptVersion="1.1" scriptName="QueueCleaner" #### Import Settings @@ -10,22 +10,26 @@ log () { echo $m_time" :: $scriptName :: $scriptVersion :: "$1 } -if [ "$enableQueueCleaner" != "true" ]; then - log "Script is not enabled, enable by setting enableQueueCleaner to \"true\" by modifying the \"/config/extended.conf\" config file..." - log "Sleeping (infinity)" - sleep infinity -fi +verifyConfig () { + if [ "$enableQueueCleaner" != "true" ]; then + log "Script is not enabled, enable by setting enableQueueCleaner to \"true\" by modifying the \"/config/extended.conf\" config file..." + log "Sleeping (infinity)" + sleep infinity + fi +} -# auto-clean up log file to reduce space usage -if [ -f "/config/logs/QueueCleaner.txt" ]; then - find /config/logs -type f -name "QueueCleaner.txt" -size +1024k -delete -fi - -if [ ! -f "/config/logs/QueueCleaner.txt" ]; then - touch "/config/logs/QueueCleaner.txt" - chmod 666 "/config/logs/QueueCleaner.txt" -fi -exec &> >(tee -a "/config/logs/QueueCleaner.txt") +logfileSetup () { + # auto-clean up log file to reduce space usage + if [ -f "/config/logs/QueueCleaner.txt" ]; then + find /config/logs -type f -name "QueueCleaner.txt" -size +1024k -delete + fi + + if [ ! -f "/config/logs/QueueCleaner.txt" ]; then + touch "/config/logs/QueueCleaner.txt" + chmod 666 "/config/logs/QueueCleaner.txt" + fi + exec &> >(tee -a "/config/logs/QueueCleaner.txt") +} QueueCleanerProcess () { # Get Arr App information @@ -114,13 +118,12 @@ verifyApiAccess () { done } -# Install packages -PackageInstallation - arrName="$(cat /config/config.xml | xq | jq -r .Config.InstanceName)" if [ "$arrName" == "Sonarr" ] || [ "$arrName" == "Radarr" ] || [ "$arrName" == "Lidarr" ] || [ "$arrName" == "Readarr" ]; then for (( ; ; )); do let i++ + logfileSetup + verifyConfig log "Starting..." QueueCleanerProcess log "Sleeping 15m..."