44#
55# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7- # Last Modified: 2025-Jun-30
7+ # Last Modified: 2025-Jul-03
88# ##################################################################
99set -u
1010
@@ -775,7 +775,7 @@ _GetFirmwareVariantFromRouter_()
775775
776776 # #FOR TESTING/DEBUG ONLY##
777777 if false # Change to true for forcing GNUton flag #
778- then hasGNUtonFW= true ; return 0 ; fi
778+ then echo " true" ; return 0 ; fi
779779 # #FOR TESTING/DEBUG ONLY##
780780
781781 # Check if installed F/W NVRAM vars contain "gnuton" #
@@ -4950,13 +4950,14 @@ _GetLatestFWUpdateVersionFromWebsite_()
49504950# #------------------------------------------##
49514951_GetLatestFWUpdateVersionFromGitHub_ ()
49524952{
4953- local routerVersion
4953+ local routerVersion search_type release_data
49544954 local gitURL=" $1 " # GitHub URL for the latest release #
49554955 local firmware_type=" $2 " # "tuf", "rog" or "pure" #
4956+ local grep_pattern downloadURLs theURL urlVersion
49564957
4957- local search_type=" $firmware_type " # Default to the input firmware_type #
4958+ search_type=" $firmware_type " # Default to the input firmware_type #
49584959
4959- # If firmware_type is "pure", set search_type to include "squashfs" as well
4960+ # If firmware_type is "pure", set search_type to include "squashfs" as well #
49604961 if [ " $firmware_type " = " pure" ]
49614962 then
49624963 search_type=" pure\|squashfs\|ubi"
@@ -4975,13 +4976,13 @@ _GetLatestFWUpdateVersionFromGitHub_()
49754976 fi
49764977
49774978 # Fetch the latest release data from GitHub #
4978- local release_data=" $( curl -s " $gitURL " ) "
4979+ release_data=" $( curl -s " $gitURL " ) "
49794980
49804981 # Construct the grep pattern based on search_type #
4981- local grep_pattern=" \" browser_download_url\" : \" .*${PRODUCT_ID} .*\(${search_type} \).*\.\(w\|pkgtb\)\" "
4982+ grep_pattern=" \" browser_download_url\" : \" .*${PRODUCT_ID} .*\(${search_type} \).*\.\(w\|pkgtb\)\" "
49824983
49834984 # Extract all matched download URLs #
4984- local downloadURLs=" $( echo " $release_data " | \
4985+ downloadURLs=" $( echo " $release_data " | \
49854986 grep -o " $grep_pattern " | \
49864987 grep -o " https://[^ ]*\.\(w\|pkgtb\)" ) "
49874988
@@ -4990,7 +4991,6 @@ _GetLatestFWUpdateVersionFromGitHub_()
49904991 echo " **ERROR** **NO_GITHUB_URL**"
49914992 return 1
49924993 else
4993- local theURL urlVersion
49944994 for theURL in $downloadURLs
49954995 do
49964996 # Extract the version portion from the URL #
@@ -11168,6 +11168,50 @@ _DoInitializationStartup_()
1116811168 _SetDefaultBuildType_
1116911169}
1117011170
11171+ # #-------------------------------------##
11172+ # # Added by Martinski W. [2025-Jul-03] ##
11173+ # #-------------------------------------##
11174+ # ######################################################################
11175+ # TEMPORARY hack to check if the Gnuton F/W built-in 'webs_update.sh'
11176+ # script is the most recent version that includes required fixes.
11177+ # If not, we temporarily set up a local version so that MerlinAU
11178+ # can continue to work by detecting available F/W version updates.
11179+ # NOTE:
11180+ # The 'webs_update.sh' MUST have "SCRIPT_VERSTAG" variable defined.
11181+ # ######################################################################
11182+ _Gnuton_Check_Webs_Update_Script_ ()
11183+ {
11184+ if ! " $isGNUtonFW " || \
11185+ ! " $checkWebsUpdateScriptForGnuton " || \
11186+ grep -qE ' SCRIPT_VERSTAG="[0-9]+"' " $FW_UpdateCheckScript "
11187+ then
11188+ checkWebsUpdateScriptForGnuton=false
11189+ return 0
11190+ fi
11191+
11192+ local theWebsUpdateFile=" webs_update.sh"
11193+ local fixedWebsUpdateFilePath=" ${SETTINGS_DIR} /$theWebsUpdateFile "
11194+
11195+ # # Get the fixed version of the script targeted for Gnuton F/W ##
11196+ if _CurlFileDownload_ " gnuton_webs_update.sh" " $fixedWebsUpdateFilePath "
11197+ then
11198+ chmod 755 " $fixedWebsUpdateFilePath "
11199+ else
11200+ return 1 # NOT available so do nothing#
11201+ fi
11202+
11203+ if ! diff " $FW_UpdateCheckScript " " $fixedWebsUpdateFilePath " > /dev/null 2>&1
11204+ then
11205+ umount " $FW_UpdateCheckScript " 2> /dev/null
11206+ mount -o bind " $fixedWebsUpdateFilePath " " $FW_UpdateCheckScript "
11207+ Say " ${YLWct} Set up a fixed version of the \" ${theWebsUpdateFile} \" script file.${NOct} "
11208+ fi
11209+ }
11210+
11211+ # # Set variable to 'false' to stop the check ##
11212+ checkWebsUpdateScriptForGnuton=" $isGNUtonFW "
11213+ _Gnuton_Check_Webs_Update_Script_
11214+
1117111215FW_InstalledVersion=" $( _GetCurrentFWInstalledLongVersion_) "
1117211216FW_InstalledVerStr=" ${GRNct}${FW_InstalledVersion}${NOct} "
1117311217FW_NewUpdateVerInit=TBD
0 commit comments