Skip to content

Commit aa37b4e

Browse files
Code Improvements
Improved code for Gnuton 'webs_update.sh' script detection.
1 parent 25051fa commit aa37b4e

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

MerlinAU.sh

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

@@ -2654,22 +2654,22 @@ _GetDLScriptVersion_()
26542654
##---------------------------------------##
26552655
## Added by ExtremeFiretop [2025-Jul-24] ##
26562656
##---------------------------------------##
2657-
_GetScriptVerstag_()
2657+
_Get_GnutonWebUpdate_ScriptVersTag_()
26582658
{
26592659
if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ]
26602660
then echo 0 ; return 1 ; fi
26612661
sed -n 's/.*SCRIPT_VERSTAG="\([0-9]\+\)".*/\1/p' "$1" | tail -n1
26622662
[ $? -ne 0 ] && echo 0
2663-
}
2664-
2663+
}
26652664

26662665
##----------------------------------------##
26672666
## Modified by Martinski W. [2025-Feb-15] ##
26682667
##----------------------------------------##
26692668
_CurlFileDownload_()
26702669
{
26712670
if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ]
2672-
then return 1 ; fi
2671+
then return 1
2672+
fi
26732673
local retCode=1
26742674
local tempFilePathDL="${2}.DL.TMP"
26752675
local srceFilePathDL="${SCRIPT_URL_REPO}/$1"
@@ -2688,13 +2688,7 @@ _CurlFileDownload_()
26882688
then updatedWebUIPage=true
26892689
else updatedWebUIPage=false
26902690
fi
2691-
if grep -q " $2 " /proc/mounts 2>/dev/null
2692-
then
2693-
cat "$tempFilePathDL" > "$2"
2694-
rm -f "$tempFilePathDL"
2695-
else
2696-
mv -f "$tempFilePathDL" "$2"
2697-
fi
2691+
mv -f "$tempFilePathDL" "$2"
26982692
retCode=0
26992693
fi
27002694

@@ -11083,9 +11077,9 @@ _DoInitializationStartup_()
1108311077
_SetDefaultBuildType_
1108411078
}
1108511079

11086-
##-------------------------------------------##
11087-
## Modified by ExtremeFiretop [2025-July-24] ##
11088-
##-------------------------------------------##
11080+
##----------------------------------------##
11081+
## Modified by Martinski W. [2025-Jul-29] ##
11082+
##----------------------------------------##
1108911083
#######################################################################
1109011084
# TEMPORARY hack to check if the Gnuton F/W built-in 'webs_update.sh'
1109111085
# script is the most recent version that includes required fixes.
@@ -11104,32 +11098,34 @@ _Gnuton_Check_Webs_Update_Script_()
1110411098
fi
1110511099

1110611100
local theWebsUpdateFile="webs_update.sh"
11107-
local fixedWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile"
11108-
local localVerstag=0 remoteVerstag=0
11101+
local fixedGnutonWebsUpdateFilePath="${SETTINGS_DIR}/$theWebsUpdateFile"
11102+
local dwnldGnutonWebsUpdateFilePath="${SETTINGS_DIR}/${theWebsUpdateFile}.GNUTON"
11103+
local localVersTag remoteVersTag
1110911104

11110-
#Get local VERSTAG (if any) #
11111-
localVerstag="$(_GetScriptVerstag_ "$FW_UpdateCheckScript")"
11112-
[ -z "$localVerstag" ] && localVerstag=0
11105+
# Get local VERSTAG (if any) #
11106+
localVersTag="$(_Get_GnutonWebUpdate_ScriptVersTag_ "$FW_UpdateCheckScript")"
11107+
[ -z "$localVersTag" ] && localVersTag=0
1111311108

1111411109
# Get the fixed version of the script targeted for Gnuton F/W #
11115-
if _CurlFileDownload_ "gnuton_webs_update.sh" "$fixedWebsUpdateFilePath"
11110+
if _CurlFileDownload_ "gnuton_webs_update.sh" "$dwnldGnutonWebsUpdateFilePath"
1111611111
then
11117-
chmod 755 "$fixedWebsUpdateFilePath"
11118-
remoteVerstag="$(_GetScriptVerstag_ "$fixedWebsUpdateFilePath")"
11119-
[ -z "$remoteVerstag" ] && remoteVerstag=0
11112+
chmod 755 "$dwnldGnutonWebsUpdateFilePath"
11113+
remoteVersTag="$(_Get_GnutonWebUpdate_ScriptVersTag_ "$dwnldGnutonWebsUpdateFilePath")"
11114+
[ -z "$remoteVersTag" ] && remoteVersTag=0
1112011115
else
1112111116
return 1 #NOT available so do nothing#
1112211117
fi
1112311118

11124-
# Only (re)bind if remote is newer OR files differ #
11125-
if [ "$remoteVerstag" -gt "$localVerstag" ] || \
11126-
! diff "$FW_UpdateCheckScript" "$fixedWebsUpdateFilePath" >/dev/null 2>&1
11119+
# (Re)bind/mount only if remote is newer version OR files differ #
11120+
if [ "$remoteVersTag" -gt "$localVersTag" ] || \
11121+
! diff "$FW_UpdateCheckScript" "$dwnldGnutonWebsUpdateFilePath" >/dev/null 2>&1
1112711122
then
1112811123
umount "$FW_UpdateCheckScript" 2>/dev/null
11129-
mount -o bind "$fixedWebsUpdateFilePath" "$FW_UpdateCheckScript"
11124+
mv -f "$dwnldGnutonWebsUpdateFilePath" "$fixedGnutonWebsUpdateFilePath"
11125+
mount -o bind "$fixedGnutonWebsUpdateFilePath" "$FW_UpdateCheckScript"
1113011126
Say "${YLWct}Set up a fixed version of the \"${theWebsUpdateFile}\" script file.${NOct}"
1113111127
else
11132-
rm -f "$fixedWebsUpdateFilePath"
11128+
rm -f "$dwnldGnutonWebsUpdateFilePath"
1113311129
fi
1113411130
}
1113511131

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater
22
## v1.5.1
3-
## 2025-Jul-18
3+
## 2025-Jul-29
44

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

0 commit comments

Comments
 (0)