Skip to content

Commit 11c9a65

Browse files
Initial Bug Fix for 558
1. After updating the firmware, the script runs: sh /jffs/scripts/MerlinAU.sh **postUpdateEmail** - However, that function does not currently handle resetting the setting value of **FW_New_Update_Notification_Vers** back to "TBD" and instead would only reset the value of **"FW_New_Update_Changelog_Approval" back to "TBD" for some reason. Due to this, it retrained a stale firmware-update notification version in the settings for: **FW_New_Update_Notification_Vers** 2. The WebUI was consistently setting a static weight value of -100 for Beta/Alpha releases, regardless of the setting for **Beta-to-Release F/W Updates** -The WebUI should only set the weight penalty of beta/alpha releases if the setting is enabled for: **Beta-to-Release F/W Updates** Additionally, when enabled, it should compare the numeric segments first and only use beta/alpha status as a tie-breaker within the SAME numeric version.
1 parent 0a8f9da commit 11c9a65

4 files changed

Lines changed: 79 additions & 39 deletions

File tree

MerlinAU.asp

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<script language="JavaScript" type="text/javascript">
2828
2929
/**----------------------------**/
30-
/** Last Modified: 2026-Jan-24 **/
30+
/** Last Modified: 2026-Apr-05 **/
3131
/**----------------------------**/
3232
3333
// Separate variables for shared and AJAX settings //
@@ -301,8 +301,8 @@ function RunScriptUpdateFirmwareGateCheck()
301301
return;
302302
}
303303
304-
let installedNum = FWVersionStrToNum(installedStr);
305-
let requiredNum = FWVersionStrToNum(requiredStr);
304+
let installedNum = FWVersionStrToNum(installedStr, false);
305+
let requiredNum = FWVersionStrToNum(requiredStr, false);
306306
307307
pendingScriptUpdateGateCheck = false;
308308
isFormSubmitting = false;
@@ -1287,45 +1287,76 @@ function ConfirmLoginTest(formInput)
12871287
}
12881288
12891289
/**----------------------------------------**/
1290-
/** Modified by Martinski W. [2025-Jan-26] **/
1290+
/** Modified by ExtremeFiretop [2026-Apr-05] **/
12911291
/**----------------------------------------**/
12921292
// Converts F/W version string with the format: "3006.102.5.2" //
12931293
// to a number of the format: '30061020502' //
1294-
function FWVersionStrToNum (verStr)
1295-
{
1296-
if (verStr === null ||
1297-
verStr.length === 0 ||
1298-
verStr === 'TBD')
1294+
//
1295+
// If usePrereleaseRank is true:
1296+
// release > rc > beta > alpha for the SAME numeric version.
1297+
//
1298+
// If usePrereleaseRank is false:
1299+
// only the numeric version parts are compared.
1300+
//
1301+
function FWVersionStrToNum(verStr, usePrereleaseRank)
1302+
{
1303+
if (verStr == null)
12991304
{ return 0; }
13001305
1301-
let nonProductionVersionWeight = 0;
1302-
let foundAlphaBetaVersion = verStr.match (/([Aa]lpha|[Bb]eta)/);
1303-
if (foundAlphaBetaVersion == null)
1304-
{ nonProductionVersionWeight = 0; }
1305-
else
1306+
let versionText = String(verStr).trim();
1307+
if (versionText === '' || versionText === 'TBD')
1308+
{ return 0; }
1309+
1310+
let numericMatch = versionText.match(/^\d+(?:\.\d+)*/);
1311+
if (numericMatch == null)
1312+
{ return 0; }
1313+
1314+
let versionCore = numericMatch[0];
1315+
let segments = versionCore.split('.');
1316+
let versionNumStr = '';
1317+
1318+
for (let index = 0; index < segments.length; index++)
13061319
{
1307-
nonProductionVersionWeight = 100;
1308-
verStr = verStr.replace (/([Aa]lpha|[Bb]eta)[0-9]*/,'0');
1320+
let segmentText = segments[index];
1321+
1322+
if (segmentText.length > 2)
1323+
{ versionNumStr += segmentText; }
1324+
else
1325+
{ versionNumStr += segmentText.padStart(2, '0'); }
13091326
}
13101327
1311-
// Remove everything after the first non-numeric-and-dot character //
1312-
// e.g. "3006.102.1.alpha1" => "3006.102.1" //
1313-
verStr = verStr.split(/[^\d.]/, 1)[0];
1328+
let baseVersionNum = parseInt(versionNumStr, 10);
1329+
if (isNaN(baseVersionNum))
1330+
{ return 0; }
13141331
1315-
let segments = verStr.split('.');
1316-
let partNum=0, partStr='', verNumStr='';
1332+
// Default: numeric-only comparison //
1333+
if (usePrereleaseRank !== true)
1334+
{ return (baseVersionNum * 100); }
13171335
1318-
for (var index=0 ; index < segments.length ; index++)
1336+
let lowerVersionText = versionText.toLowerCase();
1337+
let prereleaseRank = 99; // release //
1338+
1339+
let rcMatch = lowerVersionText.match(/rc(\d*)/);
1340+
let betaMatch = lowerVersionText.match(/beta(\d*)/);
1341+
let alphaMatch = lowerVersionText.match(/alpha(\d*)/);
1342+
1343+
if (alphaMatch != null)
13191344
{
1320-
if (segments[index].length > 2)
1321-
{ partStr = segments[index]; }
1322-
else
1323-
{ partStr = segments[index].padStart(2, '0'); }
1324-
verNumStr = (verNumStr + partStr);
1345+
let alphaNum = parseInt(alphaMatch[1] || '0', 10);
1346+
prereleaseRank = 20 + Math.min(alphaNum, 19);
1347+
}
1348+
else if (betaMatch != null)
1349+
{
1350+
let betaNum = parseInt(betaMatch[1] || '0', 10);
1351+
prereleaseRank = 50 + Math.min(betaNum, 19);
1352+
}
1353+
else if (rcMatch != null)
1354+
{
1355+
let rcNum = parseInt(rcMatch[1] || '0', 10);
1356+
prereleaseRank = 80 + Math.min(rcNum, 19);
13251357
}
1326-
let verNum = (parseInt(verNumStr, 10) - nonProductionVersionWeight);
13271358
1328-
return (verNum);
1359+
return ((baseVersionNum * 100) + prereleaseRank);
13291360
}
13301361
13311362
/**----------------------------------------**/
@@ -1826,9 +1857,13 @@ function InitializeFields()
18261857
var fwUpdateAvailable = FW_NewUpdateVersAvailable;
18271858
var fwVersionInstalled = fwVersionInstalledElement.textContent.trim();
18281859
1860+
// Only apply beta/alpha/release weighting if Beta-to-Release Updates is enabled //
1861+
var usePrereleaseRank =
1862+
(custom_settings.FW_Allow_Beta_Production_Up === 'ENABLED');
1863+
18291864
// Convert both to numeric forms //
1830-
var verNumAvailable = FWVersionStrToNum(fwUpdateAvailable);
1831-
var verNumInstalled = FWVersionStrToNum(fwVersionInstalled);
1865+
var verNumAvailable = FWVersionStrToNum(fwUpdateAvailable, usePrereleaseRank);
1866+
var verNumInstalled = FWVersionStrToNum(fwVersionInstalled, usePrereleaseRank);
18321867
18331868
// If verNumAvailable is 0, maybe treat as "NONE FOUND" //
18341869
if (verNumAvailable === 0)
@@ -1840,7 +1875,7 @@ function InitializeFields()
18401875
{ // Update available //
18411876
fwUpdateAvailableElement.innerHTML = InvYLWct + fwUpdateAvailable + InvCLEAR;
18421877
isFwUpdateAvailable = true;
1843-
}
1878+
}
18441879
else // No update //
18451880
{
18461881
fwUpdateAvailableElement.innerHTML = InvYLWct + "NONE FOUND" + InvCLEAR;

MerlinAU.sh

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

1111
## Set version for each Production Release ##
12-
readonly SCRIPT_VERSION=1.6.0
13-
readonly SCRIPT_VERSTAG="26031823"
12+
readonly SCRIPT_VERSION=1.6.1
13+
readonly SCRIPT_VERSTAG="26040512"
1414
readonly SCRIPT_NAME="MerlinAU"
1515
## Set to "master" for Production Releases ##
1616
SCRIPT_BRANCH="master"
@@ -9943,7 +9943,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or
99439943
}
99449944

99459945
##----------------------------------------##
9946-
## Modified by Martinski W. [2024-Nov-17] ##
9946+
## Modified by ExtremeFiretop [2026-Apr-05] ##
99479947
##----------------------------------------##
99489948
_PostUpdateEmailNotification_()
99499949
{
@@ -9954,6 +9954,11 @@ _PostUpdateEmailNotification_()
99549954
Update_Custom_Settings "FW_New_Update_Changelog_Approval" "TBD"
99559955
fi
99569956

9957+
current_version="$(_GetCurrentFWInstalledLongVersion_)"
9958+
release_version="$(_GetLatestFWUpdateVersionFromRouter_ 1)"
9959+
9960+
_CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version"
9961+
99579962
local theWaitDelaySecs=10
99589963
local maxWaitDelaySecs=600 #10 minutes#
99599964
local curWaitDelaySecs=0

README.md

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

3-
## v1.6.0
4-
## 2026-Mar-19
3+
## v1.6.1
4+
## 2026-Apr-05
55

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

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.0
1+
1.6.1

0 commit comments

Comments
 (0)