From 40f8cdf5327b096eaa84d6b0db7554f6a5c2e593 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Mon, 19 May 2025 09:24:29 -0400 Subject: [PATCH 01/22] Fix Web Access Restrictions Regex Fix Web Access Restrictions Regex --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 201ae220..e3121c73 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4381,9 +4381,9 @@ _CheckWebGUILoginAccessOK_() mainLANIPaddrRegEx="$(echo "$mainLAN_IPaddr" | sed 's/\./\\./g')" # Router IP address MUST have access to WebGUI # - cidrIPaddrRegEx="${netwkIPv4AddrRegEx}/(2[4-9]|3[0-1])" + cidrIPaddrRegEx="${netwkIPv4AddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])" lanIPaddrRegEx1=">${mainLANIPaddrRegEx}>[13]" - lanIPaddrRegEx2=">${mainLANIPaddrRegEx}/(2[4-9]|3[0-2])>[13]" + lanIPaddrRegEx2=">${mainLANIPaddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])>[13]" lanIPaddrRegEx3=">${cidrIPaddrRegEx}>[13]" if echo "$restrictRuleList" | grep -qE "$lanIPaddrRegEx1|$lanIPaddrRegEx2" From f70169dcabdc45a0f789dfca929df769ea237cbd Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Mon, 19 May 2025 09:50:03 -0400 Subject: [PATCH 02/22] Add Missing Changelog Patch Add Missing Changelog Patch --- MerlinAU.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index e3121c73..307f9c4e 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -7304,7 +7304,7 @@ _high_risk_phrases_nointeractive_() } ##-------------------------------------==---## -## Modified by ExtremeFiretop [2024-Nov-24] ## +## Modified by ExtremeFiretop [2024-May-18] ## ##-------------------------------------==---## _ChangelogVerificationCheck_() { @@ -7336,6 +7336,11 @@ _ChangelogVerificationCheck_() fi changeLogFName="Changelog-${changeLogTag}.txt" changeLogFPath="$(/usr/bin/find -L "${FW_BIN_DIR}" -name "$changeLogFName" -print)" + + # force 3006 changelog if tag is NG but $release_version says 3006 + if [ "$changeLogTag" = "NG" ] && echo "$release_version" | grep -qE '^3006[.]' ; then + changeLogTag="3006" + fi fi if [ ! -f "$changeLogFPath" ] From 3c95762055f03157f06122828f5b0235ca5da794 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Mon, 19 May 2025 09:51:22 -0400 Subject: [PATCH 03/22] Missing Comment Updates Missing Comment Updates --- MerlinAU.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 307f9c4e..45ca92ce 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,7 +4,7 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2025-May-18 +# Last Modified: 2025-May-19 ################################################################### set -u @@ -4354,9 +4354,9 @@ _CIDR_IPaddrBlockContainsIPaddr_() fi } -##----------------------------------------## -## Modified by Martinski W. [2024-Aug-18] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-May-19] ## +##------------------------------------------## _CheckWebGUILoginAccessOK_() { local accessRestriction restrictRuleList From 45a31d14e112c62e18bccab5ffea2a16192bec03 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Mon, 19 May 2025 15:24:38 -0400 Subject: [PATCH 04/22] Actually Fix Web Access Restrictions Actually Fix Web Access Restrictions --- MerlinAU.sh | 56 ++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 45ca92ce..f2063534 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4316,42 +4316,22 @@ _GetPasswordInput_() return } -##-------------------------------------## -## Added by Martinski W. [2024-Aug-18] ## -##-------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-May-19] ## +##------------------------------------------## _CIDR_IPaddrBlockContainsIPaddr_() { - if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] - then return 1 ; fi - - local lastNETIPaddr4thOctet cidrIPRangeMax=0 - - local thisLANIPaddr="$2" - local cidrNETIPaddr="${1%/*}" - local cidrNETIPmask="${1#*/}" - local NETIPaddr4thOctet="${cidrNETIPaddr##*.}" - local LANIPaddr4thOctet="${thisLANIPaddr##*.}" - - # Assumes the host segment has a maximum of 8 bits # - # and the network segment has a minimum of 24 bits # - case "$cidrNETIPmask" in - 31) cidrIPRangeMax=1 ;; - 30) cidrIPRangeMax=3 ;; - 29) cidrIPRangeMax=7 ;; - 28) cidrIPRangeMax=15 ;; - 27) cidrIPRangeMax=31 ;; - 26) cidrIPRangeMax=63 ;; - 25) cidrIPRangeMax=127 ;; - 24) cidrIPRangeMax=255 ;; - esac - lastNETIPaddr4thOctet="$((NETIPaddr4thOctet + cidrIPRangeMax))" - [ "$lastNETIPaddr4thOctet" -gt 255 ] && lastNETIPaddr4thOctet=255 - - if [ "$LANIPaddr4thOctet" -ge "$NETIPaddr4thOctet" ] && \ - [ "$LANIPaddr4thOctet" -le "$lastNETIPaddr4thOctet" ] - then return 0 - else return 1 + if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then + return 1 fi + + awk -v cidr="$1" -v ip="$2" ' + function ip2int(s, a){split(s,a,".");return a[1]*16777216+a[2]*65536+a[3]*256+a[4]} + BEGIN{ + split(cidr,c,"/"); net=c[1]; bits=c[2]+0 + mask = bits==0 ? 0 : and(0xffffffff, lshift(0xffffffff,32-bits)) + exit and(ip2int(ip),mask)==and(ip2int(net),mask) ? 0 : 1 + }' } ##------------------------------------------## @@ -4380,11 +4360,13 @@ _CheckWebGUILoginAccessOK_() netwkIPv4AddrRegEx="$(echo "$netwkIPv4AddrX" | sed 's/\./\\./g')" mainLANIPaddrRegEx="$(echo "$mainLAN_IPaddr" | sed 's/\./\\./g')" - # Router IP address MUST have access to WebGUI # + local idxField='[<>][0-9]+[<>]' # <1> or >12< + local tailFlag='[<>][13]' # >1 or >3 (ALL / WebUI) cidrIPaddrRegEx="${netwkIPv4AddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])" - lanIPaddrRegEx1=">${mainLANIPaddrRegEx}>[13]" - lanIPaddrRegEx2=">${mainLANIPaddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])>[13]" - lanIPaddrRegEx3=">${cidrIPaddrRegEx}>[13]" + + lanIPaddrRegEx1="${idxField}${mainLANIPaddrRegEx}${tailFlag}" + lanIPaddrRegEx2="${idxField}${mainLANIPaddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])${tailFlag}" + lanIPaddrRegEx3="${idxField}${cidrIPaddrRegEx}${tailFlag}" if echo "$restrictRuleList" | grep -qE "$lanIPaddrRegEx1|$lanIPaddrRegEx2" then return 0 ; fi From fec2ac79892771d4448e7edbeef4afc0f80a8015 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 20 May 2025 11:20:56 -0400 Subject: [PATCH 05/22] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index f2063534..bb51ea99 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4362,7 +4362,7 @@ _CheckWebGUILoginAccessOK_() local idxField='[<>][0-9]+[<>]' # <1> or >12< local tailFlag='[<>][13]' # >1 or >3 (ALL / WebUI) - cidrIPaddrRegEx="${netwkIPv4AddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])" + cidrIPaddrRegEx="${IPv4addrs_RegEx}/([0-9]|[1-2][0-9]|3[0-2])" lanIPaddrRegEx1="${idxField}${mainLANIPaddrRegEx}${tailFlag}" lanIPaddrRegEx2="${idxField}${mainLANIPaddrRegEx}/([0-9]|[1-2][0-9]|3[0-2])${tailFlag}" From 7e9b05a0d0c2aa76ec2d78fb0ace0a4e07cbe340 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 20 May 2025 11:27:59 -0400 Subject: [PATCH 06/22] Update MerlinAU.sh --- MerlinAU.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index bb51ea99..f704d0b6 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -7320,7 +7320,8 @@ _ChangelogVerificationCheck_() changeLogFPath="$(/usr/bin/find -L "${FW_BIN_DIR}" -name "$changeLogFName" -print)" # force 3006 changelog if tag is NG but $release_version says 3006 - if [ "$changeLogTag" = "NG" ] && echo "$release_version" | grep -qE '^3006[.]' ; then + if [ "$changeLogTag" = "NG" ] && echo "$release_version" | grep -qE "^3006[.]" + then changeLogTag="3006" fi fi @@ -7452,7 +7453,8 @@ _ManageChangelogMerlin_() fi # force 3006 changelog if tag is NG but $2 says 3006 - if [ "$changeLogTag" = "NG" ] && [ $# -gt 1 ] && echo "$2" | grep -qE '^3006[.]' ; then + if [ "$changeLogTag" = "NG" ] && echo "$newUpdateVerStr" | grep -qE "^3006[.]" + then changeLogTag="3006" MerlinChangeLogURL="${CL_URL_3006}" fi From 4a1db6a60ce240e8b9a850d4d8f66eb777d7fe3a Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 20 May 2025 11:30:35 -0400 Subject: [PATCH 07/22] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index f704d0b6..295a47e6 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -7453,7 +7453,7 @@ _ManageChangelogMerlin_() fi # force 3006 changelog if tag is NG but $2 says 3006 - if [ "$changeLogTag" = "NG" ] && echo "$newUpdateVerStr" | grep -qE "^3006[.]" + if [ "$changeLogTag" = "NG" ] && echo "$2" | grep -qE "^3006[.]" then changeLogTag="3006" MerlinChangeLogURL="${CL_URL_3006}" From 7c52adbc3317e9782deff33f9e491baf43d0383e Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Tue, 20 May 2025 22:06:15 -0400 Subject: [PATCH 08/22] Update MerlinAU.sh --- MerlinAU.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 295a47e6..22b7c5eb 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -7452,8 +7452,9 @@ _ManageChangelogMerlin_() fi fi + release_version="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")" # force 3006 changelog if tag is NG but $2 says 3006 - if [ "$changeLogTag" = "NG" ] && echo "$2" | grep -qE "^3006[.]" + if [ "$changeLogTag" = "NG" ] && echo "$release_version" | grep -qE "^3006[.]" then changeLogTag="3006" MerlinChangeLogURL="${CL_URL_3006}" From 1cf1adddea524716e761ba597878206bf3daaae9 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Tue, 20 May 2025 22:07:35 -0400 Subject: [PATCH 09/22] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 22b7c5eb..561b6f0f 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -7453,7 +7453,7 @@ _ManageChangelogMerlin_() fi release_version="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")" - # force 3006 changelog if tag is NG but $2 says 3006 + # force 3006 changelog if tag is NG but $release_version says 3006 if [ "$changeLogTag" = "NG" ] && echo "$release_version" | grep -qE "^3006[.]" then changeLogTag="3006" From a867960ac533078be029430ca97fd9b757dbcbde Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 21 May 2025 17:25:04 -0400 Subject: [PATCH 10/22] Fix Changelog Verification Currently does not flatten the content so word wraps are missed such as: "any additionnal GN must be manually reconfigured." Also only checks between 2 matches firmware versions, which won't exist between firmware jumps in changelog 388.8 and 3006. This commit addresses these both by flattening the new lines and also checking for the date format instead of the firmware versions. --- MerlinAU.sh | 87 ++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 561b6f0f..943d69fb 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -7214,13 +7214,20 @@ _Toggle_ScriptAutoUpdate_Config_() } ##------------------------------------------## -## Modified by ExtremeFiretop [2025-Apr-11] ## +## Modified by ExtremeFiretop [2025-May-21] ## ##------------------------------------------## _high_risk_phrases_interactive_() { local changelog_contents="$1" + local changelog_flat + + changelog_flat="$( + printf '%s' "$changelog_contents" \ + | tr '\n' ' ' \ + | tr -s ' ' + )" - if echo "$changelog_contents" | grep -Eiq "$high_risk_terms" + if echo "$changelog_flat" | grep -Eiq "$high_risk_terms" then ChangelogApproval="$(Get_Custom_Setting "FW_New_Update_Changelog_Approval")" @@ -7260,13 +7267,20 @@ _high_risk_phrases_interactive_() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-May-26] ## +## Modified by ExtremeFiretop [2025-May-21] ## ##------------------------------------------## _high_risk_phrases_nointeractive_() { local changelog_contents="$1" + local changelog_flat + + changelog_flat="$( + printf '%s' "$changelog_contents" \ + | tr '\n' ' ' \ + | tr -s ' ' + )" - if echo "$changelog_contents" | grep -Eiq "$high_risk_terms" + if echo "$changelog_flat" | grep -Eiq "$high_risk_terms" then _SendEMailNotification_ STOP_FW_UPDATE_APPROVAL Update_Custom_Settings "FW_New_Update_Changelog_Approval" "BLOCKED" @@ -7332,60 +7346,31 @@ _ChangelogVerificationCheck_() _DoCleanUp_ return 1 else - # Use awk to format the version based on the number of initial digits # - formatted_current_version=$(echo "$current_version" | awk -F. '{ - if ($1 ~ /^[0-9]{4}$/) { # Check for a four-digit prefix - if (NF == 4) { - # Remove any non-digit characters from the fourth field - sub(/[^0-9].*/, "", $4) - if ($4 == "0") { - printf "%s.%s", $2, $3 # For version like 3004.388.5.0, remove the last .0 - } else { - printf "%s.%s.%s", $2, $3, $4 # For version like 3004.388.5.2, keep the last digit - } - } - } else if (NF == 3) { # For version without a four-digit prefix - if ($3 == "0") { - printf "%s.%s", $1, $2 # For version like 388.5.0, remove the last .0 - } else { - printf "%s.%s.%s", $1, $2, $3 # For version like 388.5.2, keep the last digit - } - } - }') - - formatted_release_version=$(echo "$release_version" | awk -F. '{ - if ($1 ~ /^[0-9]{4}$/) { # Check for a four-digit prefix - if (NF == 4 && $4 == "0") { - printf "%s.%s", $2, $3 # For version like 3004.388.5.0, remove the last .0 - } else if (NF == 4) { - printf "%s.%s.%s", $2, $3, $4 # For version like 3004.388.5.2, keep the last digit - } - } else if (NF == 3) { # For version without a four-digit prefix - if ($3 == "0") { - printf "%s.%s", $1, $2 # For version like 388.5.0, remove the last .0 - } else { - printf "%s.%s.%s", $1, $2, $3 # For version like 388.5.2, keep the last digit - } - } - }') - # Define regex patterns for both versions # - release_version_regex="${formatted_release_version//./[._]}\s*\([0-9]{1,2}-[A-Za-z]+-[0-9]{4}\)" - current_version_regex="${formatted_current_version//./[._]}\s*\([0-9]{1,2}-[A-Za-z]+-[0-9]{4}\)" + local date_pattern='[0-9]{1,2}-[A-Za-z]+-[0-9]{4}' if "$isGNUtonFW" then # For Gnuton, the whole file is relevant as it only contains the current version # changelog_contents="$(cat "$changeLogFPath")" else - if ! grep -Eq "$current_version_regex" "$changeLogFPath" - then - Say "Current version NOT found in changelog file. Bypassing changelog verification for this run." - return 0 - fi - # Extract log contents between two firmware versions from RMerlin # - changelog_contents="$(awk "/$release_version_regex/,/$current_version_regex/" "$changeLogFPath")" - fi + # find the first two matching line numbers + match1=$(grep -nE "$date_pattern" "$changeLogFPath" | head -1) + match2=$(grep -nE "$date_pattern" "$changeLogFPath" | head -2 | tail -1) + + # split on the first colon + line1=${match1%%:*} + line2=${match2%%:*} + + if [ -n "$line1" ] && [ -n "$line2" ] && [ "$line1" -le "$line2" ]; then + changelog_contents="$( + sed -n "${line1},${line2}p" "$changeLogFPath" + )" + else + Say "Could not find two date markers in changelog. Using entire file" + changelog_contents="$(cat "$changeLogFPath")" + fi + fi if [ "$mode" = "interactive" ] then From 5c141f5e23806f71ed4ee43eefdf891b575f4387 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 21 May 2025 19:08:05 -0400 Subject: [PATCH 11/22] Set Estimates to TBD when disabling Set Estimates to TBD when disabling --- MerlinAU.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 943d69fb..325aa04a 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2558,9 +2558,9 @@ _WebUI_SetEmailConfigFileFromAMTM_() _WriteVarDefToHelperJSFile_ "isEMailConfigEnabledInAMTM" "$isEMailConfigEnabledInAMTM" true } -##-------------------------------------## -## Added by Martinski W. [2025-Jan-15] ## -##-------------------------------------## +##---------------------------------------## +## Added by ExtremeFiretop [2025-May-20] ## +##---------------------------------------## _ActionsAfterNewConfigSettings_() { if [ ! -s "${CONFIG_FILE}.bak" ] || \ @@ -7840,9 +7840,9 @@ _Toggle_FW_UpdateEmailNotifications_() _WaitForEnterKey_ "$advnMenuReturnPromptStr" } -##----------------------------------------## -## Modified by Martinski W. [2025-Jan-05] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2025-May-21] ## +##------------------------------------------## _Toggle_FW_UpdateCheckSetting_() { local fwUpdateCheckEnabled fwUpdateCheckNewStateStr @@ -7866,6 +7866,7 @@ _Toggle_FW_UpdateCheckSetting_() FW_UpdateCheckState=0 fwUpdateCheckNewStateStr="${REDct}DISABLED${NOct}" Update_Custom_Settings "FW_Update_Check" "DISABLED" + Update_Custom_Settings FW_New_Update_Expected_Run_Date "TBD" _DelFWAutoUpdateHook_ _DelFWAutoUpdateCronJob_ else @@ -9791,14 +9792,15 @@ _SetDefaultBuildType_() fi } -##-------------------------------------## -## Added by Martinski W. [2025-Jan-05] ## -##-------------------------------------## +##---------------------------------------## +## Added by ExtremeFiretop [2025-May-21] ## +##---------------------------------------## _DisableFWAutoUpdateChecks_() { _DelFWAutoUpdateHook_ _DelFWAutoUpdateCronJob_ Update_Custom_Settings "FW_Update_Check" "DISABLED" + Update_Custom_Settings FW_New_Update_Expected_Run_Date "TBD" runfwUpdateCheck=false if [ "$FW_UpdateCheckState" -ne 0 ] From 1706ad268ca28f3351fb3ec5f97d89ededfa7c53 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 21 May 2025 21:09:59 -0400 Subject: [PATCH 12/22] Fix WebUI Estimations (Recalculations and TBD) Previously changing the postpone period in the WebUi did not correctly recalculate the new estimate flash time. Now we force it too. As well previously the estimate did not reset to (TBD) when disabling update checks. --- MerlinAU.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 325aa04a..ca6fa688 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,7 +4,7 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2025-May-19 +# Last Modified: 2025-May-21 ################################################################### set -u @@ -2559,7 +2559,7 @@ _WebUI_SetEmailConfigFileFromAMTM_() } ##---------------------------------------## -## Added by ExtremeFiretop [2025-May-20] ## +## Added by ExtremeFiretop [2025-May-21] ## ##---------------------------------------## _ActionsAfterNewConfigSettings_() { @@ -2584,7 +2584,7 @@ _ActionsAfterNewConfigSettings_() fi if _ConfigOptionChanged_ "FW_New_Update_Postponement_Days=" then - _Calculate_NextRunTime_ + _Calculate_NextRunTime_ recal fi if _ConfigOptionChanged_ "Allow_Script_Auto_Update" then @@ -5945,13 +5945,18 @@ _Calculate_DST_() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jun-10] ## +## Modified by ExtremeFiretop [2025-May-21] ## ##------------------------------------------## _Calculate_NextRunTime_() { + local force_recalc=false local fwNewUpdateVersion fwNewUpdateNotificationDate local upfwDateTimeSecs nextCronTimeSecs + if [ "$1" = "recal" ] + then force_recalc=true + fi + # Check for available firmware update if ! fwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)"; then fwNewUpdateVersion="NONE FOUND" @@ -5966,7 +5971,7 @@ _Calculate_NextRunTime_() elif [ "$fwNewUpdateVersion" = "NONE FOUND" ] then ExpectedFWUpdateRuntime="${REDct}NONE FOUND${NOct}" - elif [ "$ExpectedFWUpdateRuntime" = "TBD" ] || [ -z "$ExpectedFWUpdateRuntime" ] + elif [ "$force_recalc" = "true" ] || [ "$ExpectedFWUpdateRuntime" = "TBD" ] || [ -z "$ExpectedFWUpdateRuntime" ] then # If conditions are met (cron job enabled and update available), calculate the next runtime fwNewUpdateNotificationDate="$(Get_Custom_Setting FW_New_Update_Notification_Date)" @@ -6196,7 +6201,7 @@ _Set_FW_UpdatePostponementDays_() then Update_Custom_Settings FW_New_Update_Postponement_Days "$newPostponementDays" echo "The number of days to postpone F/W Update was updated successfully." - _Calculate_NextRunTime_ + _Calculate_NextRunTime_ recal _WaitForEnterKey_ "$mainMenuReturnPromptStr" fi return 0 @@ -6668,7 +6673,7 @@ _Set_FW_UpdateCronScheduleCustom_() printf "Cron job '${GRNct}${CRON_JOB_TAG}${NOct}' was updated successfully.\n" current_schedule_english="$(translate_schedule "$nextCronSchedule")" printf "Job Schedule: ${GRNct}${current_schedule_english}${NOct}\n" - _Calculate_NextRunTime_ + _Calculate_NextRunTime_ recal else retCode=1 printf "${REDct}**ERROR**${NOct}: Failed to add/update the cron job [${CRON_JOB_TAG}].\n" @@ -7073,7 +7078,7 @@ _Set_FW_UpdateCronScheduleGuided_() printf "Cron job '${GRNct}${CRON_JOB_TAG}${NOct}' was updated successfully.\n" cronSchedStrHR="$(_TranslateCronSchedHR_ "$nextCronSched")" printf "Job Schedule: ${GRNct}${cronSchedStrHR}${NOct}\n" - _Calculate_NextRunTime_ + _Calculate_NextRunTime_ recal else retCode=1 printf "${REDct}**ERROR**${NOct}: Failed to add/update the cron job [${CRON_JOB_TAG}].\n" @@ -9811,9 +9816,9 @@ _DisableFWAutoUpdateChecks_() fi } -##-------------------------------------## -## Added by Martinski W. [2025-Jan-05] ## -##-------------------------------------## +##---------------------------------------## +## Added by ExtremeFiretop [2025-May-21] ## +##---------------------------------------## _EnableFWAutoUpdateChecks_() { _AddFWAutoUpdateHook_ @@ -9826,6 +9831,7 @@ _EnableFWAutoUpdateChecks_() nvram set firmware_check_enable="$FW_UpdateCheckState" nvram commit fi + _Calculate_NextRunTime_ } ##----------------------------------------## From e0e9fcee1f297df44c88f90b32b3f92162c9febb Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 21 May 2025 21:20:19 -0400 Subject: [PATCH 13/22] Bug Fix/Code Cleanup Making it an optional parameter instead --- MerlinAU.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index ca6fa688..da2c4ff1 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -5953,8 +5953,9 @@ _Calculate_NextRunTime_() local fwNewUpdateVersion fwNewUpdateNotificationDate local upfwDateTimeSecs nextCronTimeSecs - if [ "$1" = "recal" ] - then force_recalc=true + if [ $# -eq 1 ] && [ "$1" = "recal" ] + then + force_recalc=true fi # Check for available firmware update From 38a3721dee906745b7a3dc6ab2633929bbf91c8c Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 21 May 2025 21:55:54 -0400 Subject: [PATCH 14/22] Code cleanup --- MerlinAU.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index da2c4ff1..b2d4efe5 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -9709,12 +9709,12 @@ _ProcessMeshNodes_() if [ $# -eq 0 ] || [ -z "$1" ] then echo "**ERROR** **NO_PARAMS**" ; return 1 ; fi - uid=1 - if ! node_list="$(_GetNodeIPv4List_)" - then node_list="" ; fi - if "$aiMeshNodes_OK" then + uid=1 + if ! node_list="$(_GetNodeIPv4List_)" + then node_list="" ; fi + if [ -n "$node_list" ] then # Iterate over the list of nodes and print information for each node From cf1681f2df4c25e21bc6ac49253531ee5fe203c8 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 22 May 2025 23:01:50 -0400 Subject: [PATCH 15/22] Fix the Password Focus on Edge/Chrome Minor Fixes to Fix the Invalid Password Focus on Edge/Chrome Currently on Edge/Chrome; even when the password is validated; the user is unable to click elsewhere like to change the postpone period. This fixes that issue. --- MerlinAU.asp | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/MerlinAU.asp b/MerlinAU.asp index 11579a99..685c0bbc 100644 --- a/MerlinAU.asp +++ b/MerlinAU.asp @@ -1119,9 +1119,9 @@ const loginPassword = } this.pswdStr = pswdStr; this.pswdLen = pswdStr.length; - if (this.pswdInvalid || this.pswdVerified || this.pswdUnverified || - this.pswdLen < this.minLen || this.pswdLen > this.maxLen || - this.pswdStr.match (`${this.allBlankCharsRegExp}`) !== null) + if ( this.pswdInvalid || + this.pswdLen < this.minLen || this.pswdLen > this.maxLen || + this.pswdStr.match(this.allBlankCharsRegExp) !== null ) { return false; } else { return true; } @@ -1133,6 +1133,20 @@ const loginPassword = /**----------------------------------------**/ function ValidatePasswordString (formField, eventID) { + // clear old server invalid flag as soon as they type + if (eventID === 'onKEYUP') { loginPassword.pswdInvalid = false; } + + // if the server has already said “invalid,” keep it red + if (loginPassword.pswdInvalid) + { + formField.focus(); + $(formField).addClass('Invalid'); + $(formField).off('mouseover'); + $(formField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);}); + $(formField)[0].onmouseout = nd; + return false; + } + if (loginPassword.ValidateString(formField, eventID)) { $(formField).removeClass('Invalid'); @@ -1141,18 +1155,12 @@ function ValidatePasswordString (formField, eventID) } else { - let retStatus; - if (loginPassword.pswdVerified || loginPassword.pswdUnverified) - { retStatus = true; } - else - { - retStatus = false; - $(formField).addClass('Invalid'); - } + $(formField).addClass('Invalid'); formField.focus(); + $(formField).off('mouseover'); $(formField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);}); $(formField)[0].onmouseout = nd; - return retStatus; + return false; } } @@ -1506,11 +1514,12 @@ function GetLoginPswdCheckStatus() loginPassword.pswdUnverified = true; break; case 5: //Failure// + // mark invalid and only steal focus on real failure + loginPassword.pswdInvalid = true; passwordFailed = true; pswdStatusText = 'Status:\n' + loginPswdCheckMsgStr; pswdStatusHint0 = loginPswdInvalidHint; pswdStatusHint1 = loginPswdInvalidHint; - loginPassword.pswdInvalid = true; break; case 6: //Unknown// pswdStatusText = 'Status:\n' + loginPswdCheckMsgStr; @@ -1526,15 +1535,14 @@ function GetLoginPswdCheckStatus() loginPswdHint = loginPswdHint.replace (/PswdSTATUS/, pswdStatusHint1); pswdField = document.getElementById('routerPassword'); - if (passwordFailed || pswdVerified || pswdUnverified) + + // only refocus when passwordFailed is true + if (passwordFailed) { - if (passwordFailed) - { - alert(`**ERROR**\n${loginPswdInvalidMsge}`); - $(pswdField).addClass('Invalid'); - } + alert(`**ERROR**\n${loginPswdInvalidMsge}`); + $(pswdField).addClass('Invalid'); pswdField.focus(); - $(pswdField).on('mouseover',function(){return overlib(pswdStatusHint0,0,0);}); + $(pswdField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);}); $(pswdField)[0].onmouseout = nd; } else From 34a76afc11e6227e49b553df10d43fadebbf458f Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 22 May 2025 23:04:31 -0400 Subject: [PATCH 16/22] Commit missing comments --- MerlinAU.asp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/MerlinAU.asp b/MerlinAU.asp index 685c0bbc..2864b634 100644 --- a/MerlinAU.asp +++ b/MerlinAU.asp @@ -1062,9 +1062,9 @@ function GetExternalCheckResults() }); } -/**----------------------------------------**/ -/** Modified by Martinski W. [2025-Mar-07] **/ -/**----------------------------------------**/ +/**------------------------------------------**/ +/** Modified by ExtremeFiretop [2025-May-22] **/ +/**------------------------------------------**/ // To support 'routerPassword' element // const loginPassword = { @@ -1128,9 +1128,9 @@ const loginPassword = } }; -/**----------------------------------------**/ -/** Modified by Martinski W. [2025-Mar-07] **/ -/**----------------------------------------**/ +/**------------------------------------------**/ +/** Modified by ExtremeFiretop [2025-May-22] **/ +/**------------------------------------------**/ function ValidatePasswordString (formField, eventID) { // clear old server invalid flag as soon as they type @@ -1469,9 +1469,9 @@ function ShowHintMsg (formField) } } -/**-------------------------------------**/ -/** Added by Martinski W. [2025-Mar-07] **/ -/**-------------------------------------**/ +/**------------------------------------------**/ +/** Modified by ExtremeFiretop [2025-May-22] **/ +/**------------------------------------------**/ function GetLoginPswdCheckStatus() { $.ajax({ From a094ed7dd6e01d89d59c7153f9651935001dd884 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 28 May 2025 19:37:14 -0400 Subject: [PATCH 17/22] Fix Memory Clearing for Low Memory Models Fix Memory Clearing for Low Memory Models --- MerlinAU.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b2d4efe5..ab10bef3 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -3665,12 +3665,12 @@ _GetRequiredRAM_KB_() echo "$total_required_kb" } -##----------------------------------------## -## Modified by Martinski W. [2023-Mar-24] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2025-May-28] ## +##------------------------------------------## _ShutDownNonCriticalServices_() { - for procName in nt_center nt_monitor nt_actMail + for procName in nt_center nt_monitor nt_actMail usbmuxd netool do procNum="$(ps w | grep -w "$procName" | grep -cv "grep -w")" if [ "$procNum" -gt 0 ] @@ -3680,7 +3680,7 @@ _ShutDownNonCriticalServices_() fi done - for service_name in conn_diag samba nasapps + for service_name in samba nasapps do procNum="$(ps w | grep -w "$service_name" | grep -cv "grep -w")" if [ "$procNum" -gt 0 ] From 8195634d4945c48b57ca19c50645b4cd3d2d4af3 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 28 May 2025 20:51:38 -0400 Subject: [PATCH 18/22] Adding Back conn_diag Adding Back conn_diag --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index ab10bef3..a548a6ed 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -3680,7 +3680,7 @@ _ShutDownNonCriticalServices_() fi done - for service_name in samba nasapps + for service_name in conn_diag samba nasapps do procNum="$(ps w | grep -w "$service_name" | grep -cv "grep -w")" if [ "$procNum" -gt 0 ] From 96f29c63ca9c61dfad2ce3b048327245a5bd9b3d Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 29 May 2025 01:11:33 -0400 Subject: [PATCH 19/22] Re-Implementing Memory Diff Solution Re-Implementing Memory Diff Solution from https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/commit/0993ac545f0d451398da2813323a2755958e9532 --- MerlinAU.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/MerlinAU.sh b/MerlinAU.sh index a548a6ed..384207d4 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8817,6 +8817,51 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or return 1 fi + ##---------------------------------------## + ## Added by ExtremeFiretop [2025-May-29] ## + ##---------------------------------------## + # Step 1: Find files + foundFiles=$( { /usr/bin/find -L "$FW_BIN_DIR" -name "*.w" -print; /usr/bin/find -L "$FW_BIN_DIR" -name "*.pkgtb" -print; } ) + + # Initialize the total size counter + total_size_bytes=0 + + IFS=$'\n' # Set IFS to newline to correctly iterate over files in case they contain spaces + for file in $foundFiles; do + if [ -f "$file" ]; then # Ensure the file exists and is a regular file + # Use wc -c to count the file size in bytes and add it to the total + size=$(wc -c <"$file") + total_size_bytes=$((total_size_bytes + size)) # Accumulate total size + fi + done + unset IFS # Reset IFS to default + + # Display the total size in bytes + Say "Total size of files: $total_size_bytes bytes" + + # Convert total size from bytes to KB and adjust the required space + total_size_kb="$((total_size_bytes / 1024))" + + # Set the minimum required RAM cushion to 50MB (50 * 1024 = 51200) + minimum_cushion_kb=51200 + + # Subtract the calculated size from requiredRAM_kb + if [ "$total_size_kb" -gt 0 ]; then + requiredRAM_kb=$((requiredRAM_kb - total_size_kb)) + Say "Adjusted required RAM by subtracting sizes of .w or .pkgtb files: $total_size_kb KB. New required RAM: ${requiredRAM_kb} KB" + + # Check if the adjusted required space is less than the minimum cushion + if [ "$requiredRAM_kb" -lt "$minimum_cushion_kb" ]; then + # Add the difference to fulfill the minimum cushion + cushion_diff=$((minimum_cushion_kb - requiredRAM_kb)) + requiredRAM_kb=$((requiredRAM_kb + cushion_diff)) + Say "Added cushion of $cushion_diff KB to meet the minimum required RAM of 50MB." + fi + else + Say "No .w or .pkgtb file found for adjustment." + return 1 + fi + freeRAM_kb="$(_GetFreeRAM_KB_)" availableRAM_kb="$(_GetAvailableRAM_KB_)" Say "Required RAM: ${requiredRAM_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" From 11e41bb889bd9e75f402074ba6371b87533d26e8 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 29 May 2025 01:19:50 -0400 Subject: [PATCH 20/22] Lowing Overhead - Removing Memory Subtraction Solution Removing Memory Subtraction Solution Lowering overhead by half from 50% to 25% --- MerlinAU.sh | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 384207d4..8c143531 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -3651,7 +3651,7 @@ _GetRequiredRAM_KB_() { local theURL="$1" local zip_file_size_bytes zip_file_size_kb overhead_kb - local total_required_kb overhead_percentage=50 + local total_required_kb overhead_percentage=25 # Size of the ZIP file in bytes # zip_file_size_bytes="$(curl -LsI --retry 4 --retry-delay 5 "$theURL" | grep -i Content-Length | tail -1 | awk '{print $2}')" @@ -8817,51 +8817,6 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or return 1 fi - ##---------------------------------------## - ## Added by ExtremeFiretop [2025-May-29] ## - ##---------------------------------------## - # Step 1: Find files - foundFiles=$( { /usr/bin/find -L "$FW_BIN_DIR" -name "*.w" -print; /usr/bin/find -L "$FW_BIN_DIR" -name "*.pkgtb" -print; } ) - - # Initialize the total size counter - total_size_bytes=0 - - IFS=$'\n' # Set IFS to newline to correctly iterate over files in case they contain spaces - for file in $foundFiles; do - if [ -f "$file" ]; then # Ensure the file exists and is a regular file - # Use wc -c to count the file size in bytes and add it to the total - size=$(wc -c <"$file") - total_size_bytes=$((total_size_bytes + size)) # Accumulate total size - fi - done - unset IFS # Reset IFS to default - - # Display the total size in bytes - Say "Total size of files: $total_size_bytes bytes" - - # Convert total size from bytes to KB and adjust the required space - total_size_kb="$((total_size_bytes / 1024))" - - # Set the minimum required RAM cushion to 50MB (50 * 1024 = 51200) - minimum_cushion_kb=51200 - - # Subtract the calculated size from requiredRAM_kb - if [ "$total_size_kb" -gt 0 ]; then - requiredRAM_kb=$((requiredRAM_kb - total_size_kb)) - Say "Adjusted required RAM by subtracting sizes of .w or .pkgtb files: $total_size_kb KB. New required RAM: ${requiredRAM_kb} KB" - - # Check if the adjusted required space is less than the minimum cushion - if [ "$requiredRAM_kb" -lt "$minimum_cushion_kb" ]; then - # Add the difference to fulfill the minimum cushion - cushion_diff=$((minimum_cushion_kb - requiredRAM_kb)) - requiredRAM_kb=$((requiredRAM_kb + cushion_diff)) - Say "Added cushion of $cushion_diff KB to meet the minimum required RAM of 50MB." - fi - else - Say "No .w or .pkgtb file found for adjustment." - return 1 - fi - freeRAM_kb="$(_GetFreeRAM_KB_)" availableRAM_kb="$(_GetAvailableRAM_KB_)" Say "Required RAM: ${requiredRAM_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" From 0629f9350af0d742a4ba3b0aaa637cbff2bfb0c9 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Sat, 31 May 2025 14:50:41 -0400 Subject: [PATCH 21/22] Undoing Memory Based Changes Undoing Memory Based Changes --- MerlinAU.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 8c143531..b2d4efe5 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -3651,7 +3651,7 @@ _GetRequiredRAM_KB_() { local theURL="$1" local zip_file_size_bytes zip_file_size_kb overhead_kb - local total_required_kb overhead_percentage=25 + local total_required_kb overhead_percentage=50 # Size of the ZIP file in bytes # zip_file_size_bytes="$(curl -LsI --retry 4 --retry-delay 5 "$theURL" | grep -i Content-Length | tail -1 | awk '{print $2}')" @@ -3665,12 +3665,12 @@ _GetRequiredRAM_KB_() echo "$total_required_kb" } -##------------------------------------------## -## Modified by ExtremeFiretop [2025-May-28] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2023-Mar-24] ## +##----------------------------------------## _ShutDownNonCriticalServices_() { - for procName in nt_center nt_monitor nt_actMail usbmuxd netool + for procName in nt_center nt_monitor nt_actMail do procNum="$(ps w | grep -w "$procName" | grep -cv "grep -w")" if [ "$procNum" -gt 0 ] From d6075e18d82f0453b8f755ffe3ba8f917c9ba074 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 31 May 2025 21:37:53 -0400 Subject: [PATCH 22/22] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 651fccbb..42720665 100644 --- a/README.md +++ b/README.md @@ -163,3 +163,12 @@ The script can be run using the below options: - Feel free to contribute to this script by submitting issues or pull requests on GitHub. Your feedback and contributions are greatly appreciated! ## Use this Automatic F/W Update script at your own discretion. By using this script you assume all risks associated with updating a router to a new firmware version. + +## Star History + + + + + Star History Chart + +