From f8d91684076f2406fd7d5677bcf6408c832c628d Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Fri, 18 Jul 2025 08:15:02 -0400 Subject: [PATCH 01/16] Cleaning Up Temporary Unused Code Cleaning Up Temporary Unused Code --- MerlinAU.sh | 140 ++++------------------------------------------------ README.md | 4 +- version.txt | 2 +- 3 files changed, 12 insertions(+), 134 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index fd3bc317..80d064d7 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,12 +4,12 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2025-Jul-03 +# Last Modified: 2025-Jul-18 ################################################################### set -u ## Set version for each Production Release ## -readonly SCRIPT_VERSION=1.5.0 +readonly SCRIPT_VERSION=1.5.1 readonly SCRIPT_NAME="MerlinAU" ## Set to "master" for Production Releases ## SCRIPT_BRANCH="dev" @@ -195,7 +195,7 @@ readonly fwInstalledBranchVer="${fwInstalledBaseVers}.$(echo "$fwInstalledBuildV # For minimum supported firmware version check # MinFirmwareVerCheckFailed=false readonly MinSupportedFW_3004_386_Ver="3004.386.13.2" -readonly MinSupportedFW_3004_388_Ver="3004.388.8.0" +readonly MinSupportedFW_3004_388_Ver="3004.388.8.4" readonly MinSupportedFW_3006_102_Ver="3004.388.8.2" ##----------------------------------------## @@ -1188,9 +1188,6 @@ _InitCustomDefaultsConfig_() fi local retCode=0 preferredPath - # TEMPORARY Migration Function # - _Migrate_Settings_ - if ! grep -q "^FW_New_Update_Notification_Date " "$CONFIG_FILE" then if [ "$(wc -l < "$CONFIG_FILE")" -lt 1 ] @@ -1969,94 +1966,6 @@ _Set_FW_UpdateZIP_DirectoryPath_() return 0 } -##----------------------------------------## -## Modified by Martinski W. [2025-Feb-15] ## -##----------------------------------------## -## Function to migrate specific settings from old values to new standardized values. -## This function is meant to be only TEMPORARY. -## We should be safe to remove it after 3 months, or 5 version releases, -## whichever comes first. Similar to the migration function removed in v1.0.9 -##-----------------------------------------------------------------------------------## -_Migrate_Settings_() -{ - [ ! -s "$CONFIG_FILE" ] && return 1 - - ## Migrate Setting from [y|Y|n|N] to [ENABLED|DISABLED] ## - ROGBuild_Value="$(Get_Custom_Setting ROGBuild)" - if [ "$ROGBuild_Value" != "TBD" ] - then - case "$ROGBuild_Value" in - y|Y) New_ROGBuild_Value="ENABLED" ;; - n|N) New_ROGBuild_Value="DISABLED" ;; - *) - New_ROGBuild_Value="" - ! echo "$ROGBuild_Value" | grep -qE "^(ENABLED|DISABLED)$" && \ - Say "ROGBuild has a unknown value: '$ROGBuild_Value'. Skipping migration for this setting." - ;; - esac - if [ -n "$New_ROGBuild_Value" ] - then - if Update_Custom_Settings ROGBuild "$New_ROGBuild_Value" - then - Say "ROGBuild setting was successfully migrated to '$New_ROGBuild_Value'." - else - Say "Error occurred while migrating ROGBuild setting to '$New_ROGBuild_Value'." - fi - fi - fi - - ## Migrate Setting from [y|Y|n|N] to [ENABLED|DISABLED] ## - TUFBuild_Value="$(Get_Custom_Setting TUFBuild)" - if [ "$TUFBuild_Value" != "TBD" ] - then - case "$TUFBuild_Value" in - y|Y) New_TUFBuild_Value="ENABLED" ;; - n|N) New_TUFBuild_Value="DISABLED" ;; - *) - New_TUFBuild_Value="" - ! echo "$TUFBuild_Value" | grep -qE "^(ENABLED|DISABLED)$" && \ - Say "TUFBuild has a unknown value: '$TUFBuild_Value'. Skipping migration for this setting." - ;; - esac - if [ -n "$New_TUFBuild_Value" ] - then - if Update_Custom_Settings TUFBuild "$New_TUFBuild_Value" - then - Say "TUFBuild setting was successfully migrated to '$New_TUFBuild_Value'." - else - Say "Error occurred while migrating TUFBuild setting to '$New_TUFBuild_Value'." - fi - fi - fi - - ## Migrate Setting from [true|false] to [ENABLED|DISABLED] ## - EMailNotif_Value="$(grep '^FW_New_Update_EMail_Notification=' "$CONFIG_FILE" | cut -d'=' -f2 | tr -d '"')" - if [ -n "$EMailNotif_Value" ] && [ "$EMailNotif_Value" != "TBD" ] - then - case "$EMailNotif_Value" in - true|TRUE|True) New_EMailNotif_Value="ENABLED" ;; - false|FALSE|False) New_EMailNotif_Value="DISABLED" ;; - *) - New_EMailNotif_Value="" - ! echo "$EMailNotif_Value" | grep -qE "^(ENABLED|DISABLED)$" && \ - Say "FW_New_Update_EMail_Notification has a unknown value: '$EMailNotif_Value'. Skipping migration for this setting." - ;; - esac - if [ -n "$New_EMailNotif_Value" ] - then - sed -i '/^FW_New_Update_EMail_Notification .*/d' "$CONFIG_FILE" - sed -i "s/^FW_New_Update_EMail_Notification=.*/FW_New_Update_EMail_Notification $New_EMailNotif_Value/" "$CONFIG_FILE" - if [ $? -eq 0 ] - then - sendEMailNotificationsFlag="$New_EMailNotif_Value" - Say "EMail_Notification setting was successfully migrated to $New_EMailNotif_Value." - else - Say "Error occurred while migrating EMail_Notification setting to $New_EMailNotif_Value." - fi - fi - fi -} - ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-27] ## ##------------------------------------------## @@ -2705,30 +2614,6 @@ _UpdateConfigFromWebUISettings_() return 0 } -##-------------------------------------## -## Added by Martinski W. [2024-Dec-31] ## -##-------------------------------------## -newGUIversionNum="$(_ScriptVersionStrToNum_ '1.4.0')" -# Temporary code used to migrate to future new script version # -_CheckForNewGUIVersionUpdate_() -{ - local retCode theScriptVerNum urlScriptVerNum - if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] - then - theScriptVerNum="$ScriptVersionNum" - urlScriptVerNum="$DLRepoVersionNum" - else - theScriptVerNum="$(_ScriptVersionStrToNum_ "$1")" - urlScriptVerNum="$(_ScriptVersionStrToNum_ "$2")" - fi - if [ "$theScriptVerNum" -lt "$newGUIversionNum" ] && \ - [ "$urlScriptVerNum" -ge "$newGUIversionNum" ] - then retCode=0 - else retCode=1 - fi - return "$retCode" -} - ##-------------------------------------## ## Added by Martinski W. [2025-Mar-24] ## ##-------------------------------------## @@ -2830,20 +2715,15 @@ _DownloadScriptFiles_() return "$retCode" } -##----------------------------------------## -## Modified by Martinski W. [2025-May-05] ## -##----------------------------------------## +##-------------------------------------------## +## Modified by ExtremeFiretop [2025-July-18] ## +##-------------------------------------------## _SCRIPT_UPDATE_() { - local extraParam="" - if [ $# -gt 0 ] && [ "$1" = "force" ] then printf "\n${CYANct}Force downloading latest script version...${NOct}\n" _CheckForNewScriptUpdates_ -quietcheck - if _CheckForNewGUIVersionUpdate_ "$SCRIPT_VERSION" "$DLRepoVersion" - then extraParam="install" - fi printf "${CYANct}Downloading latest version [$DLRepoVersion] of ${SCRIPT_NAME}${NOct}\n" if _DownloadScriptFiles_ update @@ -2860,7 +2740,7 @@ _SCRIPT_UPDATE_() fi sleep 1 _ReleaseLock_ - exec "$ScriptFilePath" $extraParam + exec "$ScriptFilePath" exit 0 else if ! "$isInteractive" @@ -2901,9 +2781,8 @@ _SCRIPT_UPDATE_() printf "$(date) - Successfully updated $SCRIPT_NAME v${DLRepoVersion}\n" printf "${CYANct}Restarting script...${NOct}\n" sleep 1 - _CheckForNewGUIVersionUpdate_ && extraParam="install" _ReleaseLock_ - exec "$ScriptFilePath" $extraParam + exec "$ScriptFilePath" exit 0 fi else @@ -2930,9 +2809,8 @@ _SCRIPT_UPDATE_() printf "\n$(date) - Successfully updated $SCRIPT_NAME v${DLRepoVersion}\n" printf "${CYANct}Restarting script...${NOct}\n" sleep 1 - _CheckForNewGUIVersionUpdate_ && extraParam="install" _ReleaseLock_ - exec "$ScriptFilePath" $extraParam + exec "$ScriptFilePath" exit 0 else _WaitForEnterKey_ diff --git a/README.md b/README.md index 6993eefb..6af322c1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater -## v1.5.0 -## 2025-Jul-06 +## v1.5.1 +## 2025-Jul-18 ## WebUI: ![image](https://github.com/user-attachments/assets/9c1dff99-9c13-491b-a7fa-aff924d5f02e) diff --git a/version.txt b/version.txt index bc80560f..26ca5946 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.5.0 +1.5.1 From 0c3198cbb4ef6d5935d2beb5b70749efb57d273f Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 23 Jul 2025 23:21:30 -0400 Subject: [PATCH 02/16] Fixing More Comparison Errors Fixing More Comparison Errors --- MerlinAU.sh | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 80d064d7..00383131 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-Jul-18 +# Last Modified: 2025-Jul-23 ################################################################### set -u @@ -786,9 +786,9 @@ _GetFirmwareVariantFromRouter_() echo "$hasGNUtonFW" ; return 0 } -##----------------------------------------## -## Modified by Martinski W. [2024-May-31] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2025-July-23] ## +##------------------------------------------## _FWVersionStrToNum_() { if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] @@ -797,7 +797,7 @@ _FWVersionStrToNum_() USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" local verNum verStr="$1" nonProductionVersionWeight=0 - local fwBasecodeVers="" numOfFields + local fwBasecodeVers="" numOfFields buildDigits #-------------------------------------------------------------- # Handle any 'alpha/beta' in the version string to be sure @@ -829,7 +829,17 @@ _FWVersionStrToNum_() fwBasecodeVers="$(echo "$verStr" | cut -d'.' -f1)" verStr="$(echo "$verStr" | cut -d'.' -f2-)" fi - verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')" + #----------------------------------------------------------- + # NEW: capture any trailing build‑suffix digits (e.g. "gnuton2" → 2) + #----------------------------------------------------------- + buildDigits="$(echo "$verStr" | sed -n 's/.*[^0-9]\([0-9]\+\)$/\1/p')" + buildDigits=$(printf "%02d" "${buildDigits:-0}") + + # Strip the non‑numeric tail so we feed only dotted numbers to awk + verStr="$(echo "$verStr" | sed 's/[^0-9.]*$//')" + + # Core numeric conversion (Major Minor Patch) + two‑digit build suffix + verNum="$(echo "$verStr" | awk -F'.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')${buildDigits}" # Subtract non-production weight from the version number # verNum="$((verNum + nonProductionVersionWeight))" @@ -2935,13 +2945,13 @@ _CreateEMailContent_() fwInstalledVersion="$(_GetCurrentFWInstalledLongVersion_)" if ! "$offlineUpdateTrigger" then - fwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_)" + fwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" else fwNewUpdateVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")" fi - # Remove "_rog" or "_tuf" or -gHASHVALUES or -Gnuton* suffix to avoid version comparison failure, can't remove all for proper beta and alpha comparison # - fwInstalledVersion="$(echo "$fwInstalledVersion" | sed -E 's/(_(rog|tuf)|-g[0-9a-f]{10}|-gnuton[0-9]+)$//')" + # Remove "_rog" or "_tuf" or -gHASHVALUES suffix to avoid version comparison failure, can't remove all for proper beta and alpha comparison # + fwInstalledVersion="$(echo "$fwInstalledVersion" | sed -E 's/(_(rog|tuf)|-g[0-9a-f]{10})$//')" case "$1" in FW_UPDATE_TEST_EMAIL) @@ -4843,7 +4853,7 @@ _GetLatestFWUpdateVersionFromGitHub_() if ! "$offlineUpdateTrigger" then - routerVersion="$(_GetLatestFWUpdateVersionFromRouter_)" + routerVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" else routerVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")" fi @@ -4874,7 +4884,7 @@ _GetLatestFWUpdateVersionFromGitHub_() # Extract the version portion from the URL # urlVersion="$(echo "$theURL" \ | grep -oE "${PRODUCT_ID}_[^ ]*\.(w|pkgtb)" \ - | sed "s/${PRODUCT_ID}_//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g;s/-gnuton[0-9][0-9]*\$//" | head -n1)" + | sed "s/${PRODUCT_ID}_//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g" | head -n1)" if [ "$urlVersion" = "$routerVersion" ] then @@ -4905,7 +4915,7 @@ GetLatestFirmwareMD5URL() if ! "$offlineUpdateTrigger" then - routerVersion="$(_GetLatestFWUpdateVersionFromRouter_)" + routerVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" else routerVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")" fi @@ -4937,7 +4947,7 @@ GetLatestFirmwareMD5URL() # Extract the version portion from the URL # md5Version="$(echo "$theURL" \ | grep -oE "${PRODUCT_ID}_[^ ]*\.(md5)" \ - | sed "s/${PRODUCT_ID}_//;s/.md5$//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g;s/-gnuton[0-9][0-9]*\$//" | head -n1)" + | sed "s/${PRODUCT_ID}_//;s/.md5$//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g" | head -n1)" if [ "$md5Version" = "$routerVersion" ] then @@ -8750,7 +8760,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or # "New F/W Release Version" from the router itself. # If no new F/W version update is available return. #------------------------------------------------------ - if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ + if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_ 1)" || \ ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" then Say "No new firmware version update is found for [$MODEL_ID] router model." @@ -8792,7 +8802,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or if ! "$offlineUpdateTrigger" then - NewUpdate_VersionVerify="$(_GetLatestFWUpdateVersionFromRouter_)" + NewUpdate_VersionVerify="$(_GetLatestFWUpdateVersionFromRouter_ 1)" if [ "$NewUpdate_VersionVerify" != "$release_version" ] then Say "WARNING: The release version found by MerlinAU [$release_version] does not match the F/W update version from the router [$NewUpdate_VersionVerify]." From 2b3a5317e68871e9cb3aa4aaa3d1e8a0e73b6b52 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Wed, 23 Jul 2025 23:46:46 -0400 Subject: [PATCH 03/16] Missed one Missed one --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 00383131..007a1dd1 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -10402,7 +10402,7 @@ _ShowMainMenuOptions_() # Check if router reports a new F/W update is available. # If yes, modify the notification settings accordingly. #-----------------------------------------------------------# - if FW_NewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_)" && \ + if FW_NewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" && \ [ -n "$FW_NewUpdateVersion" ] && [ -n "$FW_InstalledVersion" ] && \ [ "$FW_NewUpdateVersion" != "$FW_NewUpdateVerInit" ] then From 9e4a6fa42ac5d68c0d1c31e37108bc18676c1d9d Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 24 Jul 2025 00:34:26 -0400 Subject: [PATCH 04/16] Committing Additional Logic Fixes Committing Additional Logic Fixes --- MerlinAU.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 007a1dd1..6ecd5615 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -786,9 +786,9 @@ _GetFirmwareVariantFromRouter_() echo "$hasGNUtonFW" ; return 0 } -##------------------------------------------## +##-------------------------------------------## ## Modified by ExtremeFiretop [2025-July-23] ## -##------------------------------------------## +##-------------------------------------------## _FWVersionStrToNum_() { if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] @@ -796,8 +796,8 @@ _FWVersionStrToNum_() USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - local verNum verStr="$1" nonProductionVersionWeight=0 - local fwBasecodeVers="" numOfFields buildDigits + local verNum verStr="$1" + local fwBasecodeVers="" numOfFields buildDigits isBeta=0 prodFlag #-------------------------------------------------------------- # Handle any 'alpha/beta' in the version string to be sure @@ -805,8 +805,9 @@ _FWVersionStrToNum_() #-------------------------------------------------------------- if echo "$verStr" | grep -qiE '(alpha|beta)' then + isBeta=1 # Adjust weight value if "Beta-to-Production" update is enabled # - [ "$USE_BETA_WEIGHT" = "ENABLED" ] && nonProductionVersionWeight=-100 + [ "$USE_BETA_WEIGHT" = "ENABLED" ] # Replace '.alpha|.beta' and anything following it with ".0" # verStr="$(echo "$verStr" | sed 's/[.][Aa]lpha.*/.0/ ; s/[.][Bb]eta.*/.0/')" @@ -830,19 +831,19 @@ _FWVersionStrToNum_() verStr="$(echo "$verStr" | cut -d'.' -f2-)" fi #----------------------------------------------------------- - # NEW: capture any trailing build‑suffix digits (e.g. "gnuton2" → 2) + # NEW: capture any trailing build-suffix digits (e.g. "gnuton2" → 2) #----------------------------------------------------------- buildDigits="$(echo "$verStr" | sed -n 's/.*[^0-9]\([0-9]\+\)$/\1/p')" buildDigits=$(printf "%02d" "${buildDigits:-0}") - # Strip the non‑numeric tail so we feed only dotted numbers to awk - verStr="$(echo "$verStr" | sed 's/[^0-9.]*$//')" + # Production flag: 1 = prod, 0 = beta/alpha + prodFlag="$((1 - isBeta))" - # Core numeric conversion (Major Minor Patch) + two‑digit build suffix - verNum="$(echo "$verStr" | awk -F'.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')${buildDigits}" + # Strip the non-numeric tail so we feed only dotted numbers to awk + verStr="$(echo "$verStr" | sed 's/[^0-9.]*$//')" - # Subtract non-production weight from the version number # - verNum="$((verNum + nonProductionVersionWeight))" + # Core numeric conversion (Major Minor Patch) + build suffix + prod flag + verNum="$(echo "$verStr" | awk -F'.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')${buildDigits}${prodFlag}" # Now prepend the F/W Basecode version # [ -n "$fwBasecodeVers" ] && verNum="${fwBasecodeVers}$verNum" From 1a57147ec5f26f63ad5a36bc3224cf341f5bc406 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 24 Jul 2025 11:21:32 -0400 Subject: [PATCH 05/16] Additional Patches to Webs_Updates Additional Patches to Webs_Updates Reimplement the use of the $USE_BETA_WEIGHT --- MerlinAU.sh | 26 +++++++++++++++++--------- gnuton_webs_update.sh | 16 +++++++++++++--- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 6ecd5615..b75d217b 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-Jul-23 +# Last Modified: 2025-Jul-24 ################################################################### set -u @@ -787,7 +787,7 @@ _GetFirmwareVariantFromRouter_() } ##-------------------------------------------## -## Modified by ExtremeFiretop [2025-July-23] ## +## Modified by ExtremeFiretop [2025-July-24] ## ##-------------------------------------------## _FWVersionStrToNum_() { @@ -797,7 +797,15 @@ _FWVersionStrToNum_() USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" local verNum verStr="$1" - local fwBasecodeVers="" numOfFields buildDigits isBeta=0 prodFlag + local fwBasecodeVers="" numOfFields buildDigits isBeta=0 prodFlag tagRank=2 + local stableRank=2 betaRank=1 alphaRank=0 + + # If beta weight is NOT enabled, all tags get the same rank (0) + if [ "$USE_BETA_WEIGHT" != "ENABLED" ] + then + stableRank=0 ; betaRank=0 ; alphaRank=0 + fi + tagRank="$stableRank" #-------------------------------------------------------------- # Handle any 'alpha/beta' in the version string to be sure @@ -805,9 +813,9 @@ _FWVersionStrToNum_() #-------------------------------------------------------------- if echo "$verStr" | grep -qiE '(alpha|beta)' then - isBeta=1 - # Adjust weight value if "Beta-to-Production" update is enabled # - [ "$USE_BETA_WEIGHT" = "ENABLED" ] + if echo "$verStr" | grep -qi 'alpha'; then tagRank="$alphaRank" ; isBeta=1 + elif echo "$verStr" | grep -qi 'beta' ; then tagRank="$betaRank" ; isBeta=1 + fi # Replace '.alpha|.beta' and anything following it with ".0" # verStr="$(echo "$verStr" | sed 's/[.][Aa]lpha.*/.0/ ; s/[.][Bb]eta.*/.0/')" @@ -836,13 +844,13 @@ _FWVersionStrToNum_() buildDigits="$(echo "$verStr" | sed -n 's/.*[^0-9]\([0-9]\+\)$/\1/p')" buildDigits=$(printf "%02d" "${buildDigits:-0}") - # Production flag: 1 = prod, 0 = beta/alpha - prodFlag="$((1 - isBeta))" + # Production/Beta/Alpha weight digit + prodFlag="$tagRank" # Strip the non-numeric tail so we feed only dotted numbers to awk verStr="$(echo "$verStr" | sed 's/[^0-9.]*$//')" - # Core numeric conversion (Major Minor Patch) + build suffix + prod flag + # Core numeric conversion (Major Minor Patch) + build suffix + tag weight verNum="$(echo "$verStr" | awk -F'.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')${buildDigits}${prodFlag}" # Now prepend the F/W Basecode version # diff --git a/gnuton_webs_update.sh b/gnuton_webs_update.sh index 1e1fcc6a..966cf414 100644 --- a/gnuton_webs_update.sh +++ b/gnuton_webs_update.sh @@ -1,6 +1,6 @@ #!/bin/sh -readonly SCRIPT_VERSTAG="25070312" +readonly SCRIPT_VERSTAG="25072411" wget_options="-q -t 2 -T 30" @@ -20,8 +20,10 @@ fi current_base=$(nvram get firmver | sed "s/\.//g") current_firm=$(nvram get buildno | cut -d. -f1) current_buildno=$(nvram get buildno | cut -d. -f2) -#Extract extendno, subtract value by 1 if it contains "alpha/beta", remove all other values such as "_rog" or "-g*" -current_extendno="$(nvram get extendno | awk -F'[_-]' '{n=$1} /[aA]lpha|[bB]eta/{n--} END{print n}')" +current_extendno="$(nvram get extendno | awk -F'[_-]' '{print $1}')" +current_gnuton="$(nvram get extendno | sed -n 's/.*gnuton\([0-9]\+\).*/\1/p')" +[ -z "$current_gnuton" ] && current_gnuton=0 +echo "$(nvram get extendno)" | grep -qiE 'beta|alpha' && current_is_beta=1 || current_is_beta=0 # get firmware information model=$(nvram get productid) @@ -50,6 +52,10 @@ else extendno=$(echo $extendno | sed s/#.*//;) lextendno=$(echo $extendno | sed s/-g.*//;) + new_gnuton="$(echo $extendno | sed -n 's/.*gnuton\([0-9]\+\).*/\1/p')" + [ -z "$new_gnuton" ] && new_gnuton=0 + echo "$extendno" | grep -qiE 'beta|alpha' && new_is_beta=1 || new_is_beta=0 + nvram set webs_state_info=${firmbase}_${firmver}_${buildno}_${extendno} rm -f /tmp/wlan_update.* @@ -72,6 +78,10 @@ else newfirm=1 elif [ "$current_base" -eq "$firmbase" ] && [ "$current_firm" -eq "$firmver" ] && [ "$current_buildno" -eq "$buildno" ] && [ "$current_extendno" -lt "$lextendno" ]; then newfirm=1 + elif [ "$current_base" -eq "$firmbase" ] && [ "$current_firm" -eq "$firmver" ] && [ "$current_buildno" -eq "$buildno" ] && [ "$current_extendno" -eq "$lextendno" ] && [ "$current_gnuton" -lt "$new_gnuton" ]; then + newfirm=1 + elif [ "$current_base" -eq "$firmbase" ] && [ "$current_firm" -eq "$firmver" ] && [ "$current_buildno" -eq "$buildno" ] && [ "$current_extendno" -eq "$lextendno" ] && [ "$current_gnuton" -eq "$new_gnuton" ] && [ "$current_is_beta" -eq 1 ] && [ "$new_is_beta" -eq 0 ]; then + newfirm=1 else newfirm=0 fi From 8cc7335211085f3f71a6701e7072c7cc69a343bd Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 24 Jul 2025 11:40:10 -0400 Subject: [PATCH 06/16] Allow Updates to Webs_Update Script Allow Updates to Webs_Update Script --- MerlinAU.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b75d217b..b9d18cc5 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2651,6 +2651,18 @@ _GetDLScriptVersion_() return 0 } +##---------------------------------------## +## Added by ExtremeFiretop [2025-Jul-24] ## +##---------------------------------------## +_GetScriptVerstag_() +{ + if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ] + then echo 0 ; return 1 ; fi + sed -n 's/.*SCRIPT_VERSTAG="\([0-9]\+\)".*/\1/p' "$1" | tail -n1 + [ $? -ne 0 ] && echo 0 +} + + ##----------------------------------------## ## Modified by Martinski W. [2025-Feb-15] ## ##----------------------------------------## @@ -11065,9 +11077,9 @@ _DoInitializationStartup_() _SetDefaultBuildType_ } -##-------------------------------------## -## Added by Martinski W. [2025-Jul-03] ## -##-------------------------------------## +##-------------------------------------------## +## Modified by ExtremeFiretop [2025-July-24] ## +##-------------------------------------------## ####################################################################### # TEMPORARY hack to check if the Gnuton F/W built-in 'webs_update.sh' # script is the most recent version that includes required fixes. @@ -11079,8 +11091,7 @@ _DoInitializationStartup_() _Gnuton_Check_Webs_Update_Script_() { if ! "$isGNUtonFW" || \ - ! "$checkWebsUpdateScriptForGnuton" || \ - grep -qE 'SCRIPT_VERSTAG="[0-9]+"' "$FW_UpdateCheckScript" + ! "$checkWebsUpdateScriptForGnuton" then checkWebsUpdateScriptForGnuton=false return 0 @@ -11088,16 +11099,25 @@ _Gnuton_Check_Webs_Update_Script_() local theWebsUpdateFile="webs_update.sh" local fixedWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile" + local localVerstag=0 remoteVerstag=0 + + #Get local VERSTAG (if any) # + localVerstag="$(_GetScriptVerstag_ "$FW_UpdateCheckScript")" + [ -z "$localVerstag" ] && localVerstag=0 - ## Get the fixed version of the script targeted for Gnuton F/W ## + # Get the fixed version of the script targeted for Gnuton F/W # if _CurlFileDownload_ "gnuton_webs_update.sh" "$fixedWebsUpdateFilePath" then chmod 755 "$fixedWebsUpdateFilePath" + remoteVerstag="$(_GetScriptVerstag_ "$fixedWebsUpdateFilePath")" + [ -z "$remoteVerstag" ] && remoteVerstag=0 else return 1 #NOT available so do nothing# fi - if ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 + # Only (re)bind if remote is newer OR files differ # + if [ "$remoteVerstag" -gt "$localVerstag" ] || \ + ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 then umount "$FW_UpdateCheckScript" 2>/dev/null mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript" From 8670488630a6ebd877556bb42f5cd44a041dd00e Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 24 Jul 2025 11:47:04 -0400 Subject: [PATCH 07/16] Navigate around the binded file Navigate around the binded file for comparison --- MerlinAU.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b9d18cc5..b9a2e1db 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -11099,17 +11099,18 @@ _Gnuton_Check_Webs_Update_Script_() local theWebsUpdateFile="webs_update.sh" local fixedWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile" + local tmpFixedWebsUpdateFilePath="${fixedWebsUpdateFilePath}.DL.TMP" local localVerstag=0 remoteVerstag=0 - #Get local VERSTAG (if any) # + #Get local VERSTAG (if any) # localVerstag="$(_GetScriptVerstag_ "$FW_UpdateCheckScript")" [ -z "$localVerstag" ] && localVerstag=0 # Get the fixed version of the script targeted for Gnuton F/W # - if _CurlFileDownload_ "gnuton_webs_update.sh" "$fixedWebsUpdateFilePath" + if _CurlFileDownload_ "gnuton_webs_update.sh" "$tmpFixedWebsUpdateFilePath" then - chmod 755 "$fixedWebsUpdateFilePath" - remoteVerstag="$(_GetScriptVerstag_ "$fixedWebsUpdateFilePath")" + chmod 755 "$tmpFixedWebsUpdateFilePath" + remoteVerstag="$(_GetScriptVerstag_ "$tmpFixedWebsUpdateFilePath")" [ -z "$remoteVerstag" ] && remoteVerstag=0 else return 1 #NOT available so do nothing# @@ -11117,11 +11118,14 @@ _Gnuton_Check_Webs_Update_Script_() # Only (re)bind if remote is newer OR files differ # if [ "$remoteVerstag" -gt "$localVerstag" ] || \ - ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 + ! diff "$FW_UpdateCheckScript" "$tmpFixedWebsUpdateFilePath" >/dev/null 2>&1 then umount "$FW_UpdateCheckScript" 2>/dev/null + mv -f "$tmpFixedWebsUpdateFilePath" "$fixedWebsUpdateFilePath" mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript" Say "${YLWct}Set up a fixed version of the \"${theWebsUpdateFile}\" script file.${NOct}" + else + rm -f "$tmpFixedWebsUpdateFilePath" fi } From f26ba292bdd43ea24471bc65977b34cc96058532 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 24 Jul 2025 12:34:09 -0400 Subject: [PATCH 08/16] Workaround for Bound File Workaround for Bound File --- MerlinAU.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b9a2e1db..035a9827 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2688,7 +2688,13 @@ _CurlFileDownload_() then updatedWebUIPage=true else updatedWebUIPage=false fi - mv -f "$tempFilePathDL" "$2" + if grep -q " $2 " /proc/mounts 2>/dev/null + then + cat "$tempFilePathDL" > "$2" + rm -f "$tempFilePathDL" + else + mv -f "$tempFilePathDL" "$2" + fi retCode=0 fi @@ -11099,18 +11105,18 @@ _Gnuton_Check_Webs_Update_Script_() local theWebsUpdateFile="webs_update.sh" local fixedWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile" - local tmpFixedWebsUpdateFilePath="${fixedWebsUpdateFilePath}.DL.TMP" local localVerstag=0 remoteVerstag=0 #Get local VERSTAG (if any) # localVerstag="$(_GetScriptVerstag_ "$FW_UpdateCheckScript")" [ -z "$localVerstag" ] && localVerstag=0 + umount "$FW_UpdateCheckScript" 2>/dev/null # Get the fixed version of the script targeted for Gnuton F/W # - if _CurlFileDownload_ "gnuton_webs_update.sh" "$tmpFixedWebsUpdateFilePath" + if _CurlFileDownload_ "gnuton_webs_update.sh" "$fixedWebsUpdateFilePath" then - chmod 755 "$tmpFixedWebsUpdateFilePath" - remoteVerstag="$(_GetScriptVerstag_ "$tmpFixedWebsUpdateFilePath")" + chmod 755 "$fixedWebsUpdateFilePath" + remoteVerstag="$(_GetScriptVerstag_ "$fixedWebsUpdateFilePath")" [ -z "$remoteVerstag" ] && remoteVerstag=0 else return 1 #NOT available so do nothing# @@ -11118,14 +11124,13 @@ _Gnuton_Check_Webs_Update_Script_() # Only (re)bind if remote is newer OR files differ # if [ "$remoteVerstag" -gt "$localVerstag" ] || \ - ! diff "$FW_UpdateCheckScript" "$tmpFixedWebsUpdateFilePath" >/dev/null 2>&1 + ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 then umount "$FW_UpdateCheckScript" 2>/dev/null - mv -f "$tmpFixedWebsUpdateFilePath" "$fixedWebsUpdateFilePath" mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript" Say "${YLWct}Set up a fixed version of the \"${theWebsUpdateFile}\" script file.${NOct}" else - rm -f "$tmpFixedWebsUpdateFilePath" + rm -f "$fixedWebsUpdateFilePath" fi } From 87e259fc63f54e2eec914cad9646b77c6c20012d Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Thu, 24 Jul 2025 12:42:56 -0400 Subject: [PATCH 09/16] Cleanup Cleanup --- MerlinAU.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 035a9827..fcc30b17 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -11122,9 +11122,8 @@ _Gnuton_Check_Webs_Update_Script_() return 1 #NOT available so do nothing# fi - # Only (re)bind if remote is newer OR files differ # - if [ "$remoteVerstag" -gt "$localVerstag" ] || \ - ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 + # Only (re)bind if remote is newer OR the currently bound file is missing the version tag # + if [ "$remoteVerstag" -gt "$localVerstag" ] || [ "$localVerstag" -eq 0 ] then umount "$FW_UpdateCheckScript" 2>/dev/null mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript" From e9865f44a60f86e08436156d55c09c2b01b96484 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Thu, 24 Jul 2025 12:56:39 -0400 Subject: [PATCH 10/16] Update gnuton_webs_update.sh --- gnuton_webs_update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gnuton_webs_update.sh b/gnuton_webs_update.sh index 966cf414..605232e5 100644 --- a/gnuton_webs_update.sh +++ b/gnuton_webs_update.sh @@ -52,9 +52,9 @@ else extendno=$(echo $extendno | sed s/#.*//;) lextendno=$(echo $extendno | sed s/-g.*//;) - new_gnuton="$(echo $extendno | sed -n 's/.*gnuton\([0-9]\+\).*/\1/p')" - [ -z "$new_gnuton" ] && new_gnuton=0 - echo "$extendno" | grep -qiE 'beta|alpha' && new_is_beta=1 || new_is_beta=0 + new_gnuton="$(echo $extendno | sed -n 's/.*gnuton\([0-9]\+\).*/\1/p')" + [ -z "$new_gnuton" ] && new_gnuton=0 + echo "$extendno" | grep -qiE 'beta|alpha' && new_is_beta=1 || new_is_beta=0 nvram set webs_state_info=${firmbase}_${firmver}_${buildno}_${extendno} From 2ca47df3c9c397e559d94945a9a921de5bcada0f Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Fri, 25 Jul 2025 09:19:34 -0400 Subject: [PATCH 11/16] Fine-Tuning Fine-Tuning --- MerlinAU.sh | 5 +++-- gnuton_webs_update.sh | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index fcc30b17..035a9827 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -11122,8 +11122,9 @@ _Gnuton_Check_Webs_Update_Script_() return 1 #NOT available so do nothing# fi - # Only (re)bind if remote is newer OR the currently bound file is missing the version tag # - if [ "$remoteVerstag" -gt "$localVerstag" ] || [ "$localVerstag" -eq 0 ] + # Only (re)bind if remote is newer OR files differ # + if [ "$remoteVerstag" -gt "$localVerstag" ] || \ + ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 then umount "$FW_UpdateCheckScript" 2>/dev/null mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript" diff --git a/gnuton_webs_update.sh b/gnuton_webs_update.sh index 966cf414..605232e5 100644 --- a/gnuton_webs_update.sh +++ b/gnuton_webs_update.sh @@ -52,9 +52,9 @@ else extendno=$(echo $extendno | sed s/#.*//;) lextendno=$(echo $extendno | sed s/-g.*//;) - new_gnuton="$(echo $extendno | sed -n 's/.*gnuton\([0-9]\+\).*/\1/p')" - [ -z "$new_gnuton" ] && new_gnuton=0 - echo "$extendno" | grep -qiE 'beta|alpha' && new_is_beta=1 || new_is_beta=0 + new_gnuton="$(echo $extendno | sed -n 's/.*gnuton\([0-9]\+\).*/\1/p')" + [ -z "$new_gnuton" ] && new_gnuton=0 + echo "$extendno" | grep -qiE 'beta|alpha' && new_is_beta=1 || new_is_beta=0 nvram set webs_state_info=${firmbase}_${firmver}_${buildno}_${extendno} From c02bef148ce8bc0c0c349585f2531f376baadd61 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Mon, 28 Jul 2025 17:59:42 -0400 Subject: [PATCH 12/16] Removing unnecessary unmount Removing unnecessary unmount Was causing the webs_update file to always need to be remounted. --- MerlinAU.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 035a9827..371c982f 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -11111,7 +11111,6 @@ _Gnuton_Check_Webs_Update_Script_() localVerstag="$(_GetScriptVerstag_ "$FW_UpdateCheckScript")" [ -z "$localVerstag" ] && localVerstag=0 - umount "$FW_UpdateCheckScript" 2>/dev/null # Get the fixed version of the script targeted for Gnuton F/W # if _CurlFileDownload_ "gnuton_webs_update.sh" "$fixedWebsUpdateFilePath" then From aa37b4e55fa0cb5c23964bd4667e21899d863822 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Tue, 29 Jul 2025 02:12:13 -0700 Subject: [PATCH 13/16] Code Improvements Improved code for Gnuton 'webs_update.sh' script detection. --- MerlinAU.sh | 54 +++++++++++++++++++++++++---------------------------- README.md | 2 +- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 371c982f..ffbc535a 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-Jul-24 +# Last Modified: 2025-Jul-29 ################################################################### set -u @@ -2654,14 +2654,13 @@ _GetDLScriptVersion_() ##---------------------------------------## ## Added by ExtremeFiretop [2025-Jul-24] ## ##---------------------------------------## -_GetScriptVerstag_() +_Get_GnutonWebUpdate_ScriptVersTag_() { if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ] then echo 0 ; return 1 ; fi sed -n 's/.*SCRIPT_VERSTAG="\([0-9]\+\)".*/\1/p' "$1" | tail -n1 [ $? -ne 0 ] && echo 0 -} - +} ##----------------------------------------## ## Modified by Martinski W. [2025-Feb-15] ## @@ -2669,7 +2668,8 @@ _GetScriptVerstag_() _CurlFileDownload_() { if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] - then return 1 ; fi + then return 1 + fi local retCode=1 local tempFilePathDL="${2}.DL.TMP" local srceFilePathDL="${SCRIPT_URL_REPO}/$1" @@ -2688,13 +2688,7 @@ _CurlFileDownload_() then updatedWebUIPage=true else updatedWebUIPage=false fi - if grep -q " $2 " /proc/mounts 2>/dev/null - then - cat "$tempFilePathDL" > "$2" - rm -f "$tempFilePathDL" - else - mv -f "$tempFilePathDL" "$2" - fi + mv -f "$tempFilePathDL" "$2" retCode=0 fi @@ -11083,9 +11077,9 @@ _DoInitializationStartup_() _SetDefaultBuildType_ } -##-------------------------------------------## -## Modified by ExtremeFiretop [2025-July-24] ## -##-------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2025-Jul-29] ## +##----------------------------------------## ####################################################################### # TEMPORARY hack to check if the Gnuton F/W built-in 'webs_update.sh' # script is the most recent version that includes required fixes. @@ -11104,32 +11098,34 @@ _Gnuton_Check_Webs_Update_Script_() fi local theWebsUpdateFile="webs_update.sh" - local fixedWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile" - local localVerstag=0 remoteVerstag=0 + local fixedGnutonWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile" + local dwnldGnutonWebsUpdateFilePath="${SETTINGS_DIR}/${theWebsUpdateFile}.GNUTON" + local localVersTag remoteVersTag - #Get local VERSTAG (if any) # - localVerstag="$(_GetScriptVerstag_ "$FW_UpdateCheckScript")" - [ -z "$localVerstag" ] && localVerstag=0 + # Get local VERSTAG (if any) # + localVersTag="$(_Get_GnutonWebUpdate_ScriptVersTag_ "$FW_UpdateCheckScript")" + [ -z "$localVersTag" ] && localVersTag=0 # Get the fixed version of the script targeted for Gnuton F/W # - if _CurlFileDownload_ "gnuton_webs_update.sh" "$fixedWebsUpdateFilePath" + if _CurlFileDownload_ "gnuton_webs_update.sh" "$dwnldGnutonWebsUpdateFilePath" then - chmod 755 "$fixedWebsUpdateFilePath" - remoteVerstag="$(_GetScriptVerstag_ "$fixedWebsUpdateFilePath")" - [ -z "$remoteVerstag" ] && remoteVerstag=0 + chmod 755 "$dwnldGnutonWebsUpdateFilePath" + remoteVersTag="$(_Get_GnutonWebUpdate_ScriptVersTag_ "$dwnldGnutonWebsUpdateFilePath")" + [ -z "$remoteVersTag" ] && remoteVersTag=0 else return 1 #NOT available so do nothing# fi - # Only (re)bind if remote is newer OR files differ # - if [ "$remoteVerstag" -gt "$localVerstag" ] || \ - ! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1 + # (Re)bind/mount only if remote is newer version OR files differ # + if [ "$remoteVersTag" -gt "$localVersTag" ] || \ + ! diff "$FW_UpdateCheckScript" "$dwnldGnutonWebsUpdateFilePath" >/dev/null 2>&1 then umount "$FW_UpdateCheckScript" 2>/dev/null - mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript" + mv -f "$dwnldGnutonWebsUpdateFilePath" "$fixedGnutonWebsUpdateFilePath" + mount -o bind "$fixedGnutonWebsUpdateFilePath" "$FW_UpdateCheckScript" Say "${YLWct}Set up a fixed version of the \"${theWebsUpdateFile}\" script file.${NOct}" else - rm -f "$fixedWebsUpdateFilePath" + rm -f "$dwnldGnutonWebsUpdateFilePath" fi } diff --git a/README.md b/README.md index 6af322c1..37b99145 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater ## v1.5.1 -## 2025-Jul-18 +## 2025-Jul-29 ## WebUI: ![image](https://github.com/user-attachments/assets/9c1dff99-9c13-491b-a7fa-aff924d5f02e) From 0a81b4f35abf8c7c950d3c8b6cbe78904e741e3c Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 1 Aug 2025 10:38:54 -0400 Subject: [PATCH 14/16] Suggested Fix by @cdavis5e Suggested Fix by @cdavis5e --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index ffbc535a..55b08c02 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4905,7 +4905,7 @@ _GetLatestFWUpdateVersionFromGitHub_() # Extract the version portion from the URL # urlVersion="$(echo "$theURL" \ | grep -oE "${PRODUCT_ID}_[^ ]*\.(w|pkgtb)" \ - | sed "s/${PRODUCT_ID}_//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g" | head -n1)" + | sed "s/${PRODUCT_ID}_//;s/\\.w$//;s/\\.pkgtb$//;s/_\\(ubi\\|puresqubi\\|nand_squashfs\\)$//;s/_/./g" | head -n1)" if [ "$urlVersion" = "$routerVersion" ] then @@ -4968,7 +4968,7 @@ GetLatestFirmwareMD5URL() # Extract the version portion from the URL # md5Version="$(echo "$theURL" \ | grep -oE "${PRODUCT_ID}_[^ ]*\.(md5)" \ - | sed "s/${PRODUCT_ID}_//;s/.md5$//;s/.w$//;s/.pkgtb$//;s/.ubi$//;s/_/./g" | head -n1)" + | sed "s/${PRODUCT_ID}_//;s/\\.md5$//;s/\\.w$//;s/\\.pkgtb$//;s/_\\(ubi\\|puresqubi\\|nand_squashfs\\)$//;s/_/./g" | head -n1)" if [ "$md5Version" = "$routerVersion" ] then From 6d16cd42421f4be2c5a131dc688f253a99dbdc94 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:57:11 -0700 Subject: [PATCH 15/16] Code Improvements Some code improvements and fine-tuning. --- MerlinAU.sh | 96 ++++++++++++++++++++++++++++------------------------- README.md | 2 +- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 55b08c02..23f8150d 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-Jul-29 +# Last Modified: 2025-Aug-02 ################################################################### set -u @@ -4854,22 +4854,26 @@ _GetLatestFWUpdateVersionFromWebsite_() return 0 } -##------------------------------------------## -## Modified by ExtremeFiretop [2024-May-05] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2025-Aug-02] ## +##----------------------------------------## _GetLatestFWUpdateVersionFromGitHub_() { - local routerVersion search_type release_data - local gitURL="$1" # GitHub URL for the latest release # + local routerVersion searchType releaseData + local theGitURL="$1" # GitHub URL for the latest F/W release # local firmware_type="$2" # "tuf", "rog" or "pure" # - local grep_pattern downloadURLs theURL urlVersion + local grepPattern theFW_URLs fw_URL urlVersion + local FW_FileExtRegExp FW_BinTypeRegExp + + FW_FileExtRegExp="(w|pkgtb)" + FW_BinTypeRegExp="(nand_squashfs|puresqubi|pureubi|ubi|squashfs|pure)" - search_type="$firmware_type" # Default to the input firmware_type # + searchType="$firmware_type" # Default to the input firmware_type # - # If firmware_type is "pure", set search_type to include "squashfs" as well # + # If firmware_type is "pure", include all F/W image types # if [ "$firmware_type" = "pure" ] then - search_type="pure\|squashfs\|ubi" + searchType="$FW_BinTypeRegExp" fi if ! "$offlineUpdateTrigger" @@ -4885,53 +4889,56 @@ _GetLatestFWUpdateVersionFromGitHub_() fi # Fetch the latest release data from GitHub # - release_data="$(curl -s "$gitURL")" + releaseData="$(curl -s "$theGitURL")" - # Construct the grep pattern based on search_type # - grep_pattern="\"browser_download_url\": \".*${PRODUCT_ID}.*\(${search_type}\).*\.\(w\|pkgtb\)\"" + # grep search pattern # + grepPattern="\"browser_download_url\": \".*${PRODUCT_ID}.*${searchType}.*\.${FW_FileExtRegExp}\"" # Extract all matched download URLs # - downloadURLs="$(echo "$release_data" | \ - grep -o "$grep_pattern" | \ - grep -o "https://[^ ]*\.\(w\|pkgtb\)")" + theFW_URLs="$(echo "$releaseData" | grep -oE "$grepPattern" | \ + grep -oE "https://[^ ]*\.${FW_FileExtRegExp}")" - if [ -z "$downloadURLs" ] + if [ -z "$theFW_URLs" ] then echo "**ERROR** **NO_GITHUB_URL**" return 1 else - for theURL in $downloadURLs + for fw_URL in $theFW_URLs do # Extract the version portion from the URL # - urlVersion="$(echo "$theURL" \ - | grep -oE "${PRODUCT_ID}_[^ ]*\.(w|pkgtb)" \ - | sed "s/${PRODUCT_ID}_//;s/\\.w$//;s/\\.pkgtb$//;s/_\\(ubi\\|puresqubi\\|nand_squashfs\\)$//;s/_/./g" | head -n1)" + urlVersion="$(echo "$fw_URL" | grep -oE "${PRODUCT_ID}_[^ ]*\.${FW_FileExtRegExp}" | \ + sed -E "s/${PRODUCT_ID}_//;s/\.${FW_FileExtRegExp}$//;s/_${FW_BinTypeRegExp}$//;s/_/./g" | head -n1)" if [ "$urlVersion" = "$routerVersion" ] then echo "$urlVersion" - echo "$theURL" + echo "$fw_URL" return 0 fi done fi } -##------------------------------------------## -## Modified by ExtremeFiretop [2024-May-05] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2025-Aug-02] ## +##----------------------------------------## GetLatestFirmwareMD5URL() { - local routerVersion - local gitURL="$1" # GitHub URL for the latest release # + local routerVersion searchType releaseData + local theGitURL="$1" # GitHub URL for the latest F/W release # local firmware_type="$2" # "tuf", "rog" or "pure" # + local grepPattern theMD5_URLs md5_URL md5Version + local FW_FileExtRegExp FW_BinTypeRegExp + + FW_FileExtRegExp="(w|pkgtb)" + FW_BinTypeRegExp="(nand_squashfs|puresqubi|pureubi|ubi|squashfs|pure)" - local search_type="$firmware_type" # Default to the input firmware_type # + searchType="$firmware_type" # Default to the input firmware_type # - # If firmware_type is "pure", set search_type to include "squashfs" as well + # If firmware_type is "pure", include all F/W image types # if [ "$firmware_type" = "pure" ] then - search_type="pure\|squashfs\|ubi" + searchType="$FW_BinTypeRegExp" fi if ! "$offlineUpdateTrigger" @@ -4947,32 +4954,29 @@ GetLatestFirmwareMD5URL() fi # Fetch the latest release data from GitHub # - local release_data="$(curl -s "$gitURL")" + releaseData="$(curl -s "$theGitURL")" - # Construct the grep pattern based on search_type # - local grep_pattern="\"browser_download_url\": \".*${PRODUCT_ID}.*\(${search_type}\).*\.md5\"" + # grep search pattern # + grepPattern="\"browser_download_url\": \".*${PRODUCT_ID}.*${searchType}.*\.${FW_FileExtRegExp}\.md5\"" # Extract all matched download URLs # - local md5_URLs="$(echo "$release_data" | - grep -o "$grep_pattern" | - sed -E 's/.*"browser_download_url": "([^"]+)".*/\1/')" + theMD5_URLs="$(echo "$releaseData" | grep -oE "$grepPattern" | \ + grep -oE "https://[^ ]*\.${FW_FileExtRegExp}\.md5")" - if [ -z "$md5_URLs" ] + if [ -z "$theMD5_URLs" ] then echo "**ERROR** **NO_MD5_FILE_URL_FOUND**" return 1 else - local theURL md5Version - for theURL in $md5_URLs + for md5_URL in $theMD5_URLs do # Extract the version portion from the URL # - md5Version="$(echo "$theURL" \ - | grep -oE "${PRODUCT_ID}_[^ ]*\.(md5)" \ - | sed "s/${PRODUCT_ID}_//;s/\\.md5$//;s/\\.w$//;s/\\.pkgtb$//;s/_\\(ubi\\|puresqubi\\|nand_squashfs\\)$//;s/_/./g" | head -n1)" + md5Version="$(echo "$md5_URL" | grep -oE "${PRODUCT_ID}_[^ ]*\.${FW_FileExtRegExp}\.md5" | \ + sed -E "s/${PRODUCT_ID}_//;s/\.${FW_FileExtRegExp}\.md5$//;s/_${FW_BinTypeRegExp}$//;s/_/./g" | head -n1)" if [ "$md5Version" = "$routerVersion" ] then - echo "$theURL" + echo "$md5_URL" return 0 fi done @@ -4984,15 +4988,15 @@ GetLatestFirmwareMD5URL() ##----------------------------------------## GetLatestChangelogURL() { - local gitURL="$1" # GitHub URL for the latest release # + local theGitURL="$1" # GitHub URL for the latest F/W release # local changelogURL # Fetch the latest release data from GitHub # - local release_data="$(curl -s "$gitURL")" + local releaseData="$(curl -s "$theGitURL")" # Parse the release data to find the download URL of the CHANGELOG file # Directly find the URL without matching a specific model number - changelogURL="$(echo "$release_data" | grep -o "\"browser_download_url\": \".*CHANGELOG.*\"" | grep -o "https://[^ ]*\"" | tr -d '"' | head -n1)" + changelogURL="$(echo "$releaseData" | grep -o "\"browser_download_url\": \".*CHANGELOG.*\"" | grep -o "https://[^ ]*\"" | tr -d '"' | head -n1)" if [ -z "$changelogURL" ] then diff --git a/README.md b/README.md index 37b99145..e5b3cd85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater ## v1.5.1 -## 2025-Jul-29 +## 2025-Aug-02 ## WebUI: ![image](https://github.com/user-attachments/assets/9c1dff99-9c13-491b-a7fa-aff924d5f02e) From 56cef8a184ba61eca4a7194cae4a5d48e99fcc99 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 4 Aug 2025 08:35:41 -0400 Subject: [PATCH 16/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e5b3cd85..866889d2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater ## v1.5.1 -## 2025-Aug-02 +## 2025-Aug-04 ## WebUI: ![image](https://github.com/user-attachments/assets/9c1dff99-9c13-491b-a7fa-aff924d5f02e)