Skip to content

Commit 9c4b68b

Browse files
Saved Most Recent Log File
Added code to save the most recent F/W update log file. This way at least the most recent remains available to review when deleting all log files older than 30 days.
1 parent 5b9c890 commit 9c4b68b

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

MerlinAU.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#
55
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7-
# Last Modified: 2026-Feb-06
7+
# Last Modified: 2026-Feb-07
88
###################################################################
99
set -u
1010

1111
## Set version for each Production Release ##
1212
readonly SCRIPT_VERSION=1.5.9
13-
readonly SCRIPT_VERSTAG="26020622"
13+
readonly SCRIPT_VERSTAG="26020700"
1414
readonly SCRIPT_NAME="MerlinAU"
1515
## Set to "master" for Production Releases ##
1616
SCRIPT_BRANCH="dev"
@@ -2111,11 +2111,30 @@ readonly POST_REBOOT_SCRIPT_HOOK="[ -x $ScriptFilePath ] && $POST_REBOOT_SCRIPT_
21112111
readonly POST_UPDATE_EMAIL_SCRIPT_JOB="$ScriptFilePath postUpdateEmail &"
21122112
readonly POST_UPDATE_EMAIL_SCRIPT_HOOK="[ -x $ScriptFilePath ] && $POST_UPDATE_EMAIL_SCRIPT_JOB $hookScriptTagStr"
21132113

2114-
if [ -d "$FW_LOG_DIR" ]
2115-
then
2116-
# Log rotation - delete logs older than 30 days #
2114+
##-------------------------------------##
2115+
## Added by Martinski W. [2026-Feb-07] ##
2116+
##-------------------------------------##
2117+
_CleanUpOldLogFiles_()
2118+
{
2119+
[ ! -d "$FW_LOG_DIR" ] && return 1
2120+
local numLogFiles topLogFile
2121+
2122+
numLogFiles="$(ls -1lt "$FW_LOG_DIR"/*.log 2>/dev/null | wc -l)"
2123+
# Leave one log file (if any available) #
2124+
[ "$numLogFiles" -lt 2 ] && return 0
2125+
2126+
# Save the most recent log file #
2127+
topFile="$(ls -1t "$FW_LOG_DIR"/*.log 2>/dev/null | head -n1)"
2128+
[ -n "$topFile" ] && mv -f "$topFile" "${topFile}.SAVED.TEMP.LOG"
2129+
2130+
# Delete logs older than 30 days #
21172131
/usr/bin/find -L "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \;
2118-
fi
2132+
2133+
# Restore the most recent log file #
2134+
[ -n "$topFile" ] && mv -f "${topFile}.SAVED.TEMP.LOG" "$topFile"
2135+
}
2136+
2137+
_CleanUpOldLogFiles_
21192138

21202139
##----------------------------------------##
21212140
## Modified by Martinski W. [2024-Jan-27] ##

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater
22

33
## v1.5.9
4-
## 2026-Jan-24
4+
## 2026-Feb-07
55

66
## WebUI:
77
![image](https://github.com/user-attachments/assets/9c1dff99-9c13-491b-a7fa-aff924d5f02e)

0 commit comments

Comments
 (0)