From 09a4e60efe5b6d5e9355be804a0d768cbbb4a451 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 22 Jun 2026 09:48:16 -0400 Subject: [PATCH 1/3] Fix log cleanup function to create directory and restore logs Ensure log directory exists before cleanup and enhance log deletion with restoration attempt. --- MerlinAU.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 9bc9d03b..3876e7df 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2250,7 +2250,7 @@ readonly POST_UPDATE_EMAIL_SCRIPT_HOOK="[ -x $ScriptFilePath ] && $POST_UPDATE_E ##------------------------------------------## _CleanUpOldLogFiles_() { - [ ! -d "$FW_LOG_DIR" ] && return 1 + [ ! -d "$FW_LOG_DIR" ] && mkdir -p -m 755 "$FW_LOG_DIR" local numLogFiles topLogFile savedTopLogFile="" numLogFiles="$(ls -1lt "$FW_LOG_DIR"/*.log 2>/dev/null | wc -l)" @@ -2270,7 +2270,18 @@ _CleanUpOldLogFiles_() fi # Delete logs older than 30 days # - /usr/bin/find -L "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; + if ! /usr/bin/find -L "$FW_LOG_DIR" \ + -name '*.log' \ + -mtime +30 \ + -exec rm -f {} \; + then + # Attempt restoration before returning failure. + [ -n "$savedTopLogFile" ] && + [ -e "$savedTopLogFile" ] && + mv -f "$savedTopLogFile" "$topLogFile" 2>/dev/null + + return 1 + fi # Restore the most recent log file # if [ -n "$topLogFile" ] && \ From 28bce8703924bd60129f6e924b15a281d925ff71 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 22 Jun 2026 09:51:45 -0400 Subject: [PATCH 2/3] Update script version and branch for development --- MerlinAU.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 3876e7df..e4b93bbd 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -9,11 +9,11 @@ set -u ## Set version for each Production Release ## -readonly SCRIPT_VERSION=1.6.4 -readonly SCRIPT_VERSTAG="26061118" +readonly SCRIPT_VERSION=1.6.5 +readonly SCRIPT_VERSTAG="26062210" readonly SCRIPT_NAME="MerlinAU" ## Set to "master" for Production Releases ## -SCRIPT_BRANCH="master" +SCRIPT_BRANCH="dev" ##----------------------------------------## ## Modified by Martinski W. [2024-Jul-03] ## From 7a3be17623633388d3b49f69219f9d85fcff8b52 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 22 Jun 2026 10:09:21 -0400 Subject: [PATCH 3/3] Update MerlinAU.sh --- MerlinAU.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index e4b93bbd..7af4855e 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2250,7 +2250,11 @@ readonly POST_UPDATE_EMAIL_SCRIPT_HOOK="[ -x $ScriptFilePath ] && $POST_UPDATE_E ##------------------------------------------## _CleanUpOldLogFiles_() { - [ ! -d "$FW_LOG_DIR" ] && mkdir -p -m 755 "$FW_LOG_DIR" + # Create the log directory on a fresh installation. + if [ ! -d "$FW_LOG_DIR" ] + then + mkdir -p -m 755 "$FW_LOG_DIR" 2>/dev/null || return 1 + fi local numLogFiles topLogFile savedTopLogFile="" numLogFiles="$(ls -1lt "$FW_LOG_DIR"/*.log 2>/dev/null | wc -l)"