Skip to content

Commit 8606f62

Browse files
Improvements to support APs
Improvements to support APs Made changes so that we can handle specific functionality or features based on whether the router is in "Router Mode" (i.e. Primary router) or in "AP Mode." This allows us to determine whether the WebGUI should be mounted or whether the AiMesh nodes should be handled only by the Primary router.
1 parent cbf9feb commit 8606f62

File tree

2 files changed

+60
-37
lines changed

2 files changed

+60
-37
lines changed

MerlinAU.sh

Lines changed: 59 additions & 36 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-Mar-18
7+
# Last Modified: 2025-Mar-19
88
###################################################################
99
set -u
1010

@@ -208,13 +208,24 @@ case "$fwInstalledBranchVer" in
208208
esac
209209

210210
##----------------------------------------##
211-
## Modified by Martinski W. [2025-Mar-18] ##
211+
## Modified by Martinski W. [2025-Mar-19] ##
212212
##----------------------------------------##
213-
nvramSWmode="$(nvram get sw_mode)"
214-
## FOR TESTING WebGUI support when AP Mode ##
215-
if [ "$nvramSWmode" -eq 1 ] || [ "$nvramSWmode" -eq 3 ]
216-
then inRouterSWmode=true
217-
else inRouterSWmode=false
213+
aiMeshNodes_OK=false
214+
mountWebGUI_OK=false
215+
inMainRouterMode=false
216+
inAccessPointMode=false
217+
218+
readonly nvramSWmode="$(nvram get sw_mode)"
219+
if [ "$nvramSWmode" = "1" ]
220+
then
221+
mountWebGUI_OK=true
222+
aiMeshNodes_OK=true
223+
inMainRouterMode=true
224+
elif [ "$nvramSWmode" = "3" ]
225+
then
226+
mountWebGUI_OK=true
227+
aiMeshNodes_OK=true
228+
inAccessPointMode=true
218229
fi
219230

220231
readonly mainMenuReturnPromptStr="Press <Enter> to return to the Main Menu..."
@@ -505,10 +516,19 @@ _ShowLogo_()
505516
}
506517

507518
##----------------------------------------##
508-
## Modified by Martinski W. [2025-Feb-22] ##
519+
## Modified by Martinski W. [2025-Mar-19] ##
509520
##----------------------------------------##
510521
_ShowAbout_()
511522
{
523+
local webUI_Page webUI_URL="[Not Available]"
524+
if "$mountWebGUI_OK"
525+
then
526+
webUI_Page="$(_Check_WebGUI_Page_Exists_)"
527+
if [ "$webUI_Page" != "NONE" ]
528+
then webUI_URL="$(_GetRouterURL_)/$webUI_Page"
529+
fi
530+
fi
531+
512532
clear
513533
_ShowLogo_
514534
cat <<EOF
@@ -520,6 +540,9 @@ About
520540
firmware version update that is currently available.
521541
[Developed by ExtremeFiretop and Martinski W.]
522542
543+
WebUI Tab URL
544+
$webUI_URL
545+
523546
License
524547
$SCRIPT_NAME is free to use under the GNU General Public License
525548
version 3 (GPL-3.0) https://opensource.org/licenses/GPL-3.0
@@ -813,13 +836,13 @@ _FWVersionStrToNum_()
813836
}
814837

815838
##----------------------------------------##
816-
## Modified by Martinski W. [2024-Nov-27] ##
839+
## Modified by Martinski W. [2025-Mar-19] ##
817840
##----------------------------------------##
818-
if "$inRouterSWmode"
841+
if "$inMainRouterMode"
819842
then
820843
readonly FW_Update_CRON_DefaultSchedule="0 0 * * *"
821844
else
822-
## Recommended 20 minutes AFTER for AiMesh Nodes ##
845+
## Set 20 minutes AFTER for APs and AiMesh Nodes ##
823846
readonly FW_Update_CRON_DefaultSchedule="20 0 * * *"
824847
fi
825848

@@ -1489,7 +1512,7 @@ _WebUI_FW_UpdateZIPDirPathDefault_()
14891512
##----------------------------------------##
14901513
_InitHelperJSFile_()
14911514
{
1492-
! "$inRouterSWmode" && return 0
1515+
! "$mountWebGUI_OK" && return 0
14931516

14941517
[ ! -s "$HELPER_JSFILE" ] && \
14951518
{
@@ -1511,7 +1534,7 @@ _UpdateHelperJSFile_()
15111534
{
15121535
if [ $# -lt 2 ] || \
15131536
[ -z "$1" ] || [ -z "$2" ] || \
1514-
! "$inRouterSWmode"
1537+
! "$mountWebGUI_OK"
15151538
then return 1; fi
15161539

15171540
local extCheckMsg=""
@@ -2128,7 +2151,7 @@ _Mount_WebUI_()
21282151
##-------------------------------------##
21292152
_CheckFor_WebGUI_Page_()
21302153
{
2131-
if "$inRouterSWmode" && \
2154+
if "$mountWebGUI_OK" && \
21322155
[ "$(_Check_WebGUI_Page_Exists_)" = "NONE" ]
21332156
then _Mount_WebUI_ ; fi
21342157
}
@@ -2324,7 +2347,7 @@ _CreateDirPaths_()
23242347
mkdir -p "$SETTINGS_DIR"
23252348
chmod 755 "$SETTINGS_DIR"
23262349
fi
2327-
! "$inRouterSWmode" && return 0
2350+
! "$mountWebGUI_OK" && return 0
23282351

23292352
if [ ! -d "$SCRIPT_WEB_DIR" ]
23302353
then
@@ -2342,7 +2365,7 @@ _CreateSymLinks_()
23422365
then
23432366
rm -rf "${SCRIPT_WEB_DIR:?}/"* 2>/dev/null
23442367
fi
2345-
! "$inRouterSWmode" && return 0
2368+
! "$mountWebGUI_OK" && return 0
23462369

23472370
ln -sf "$CONFIG_FILE" "${SCRIPT_WEB_DIR}/config.htm" 2>/dev/null
23482371
ln -sf "$HELPER_JSFILE" "${SCRIPT_WEB_DIR}/checkHelper.js" 2>/dev/null
@@ -2382,7 +2405,7 @@ _WriteVarDefToHelperJSFile_()
23822405
##-------------------------------------##
23832406
_WebUI_AutoFWUpdateCheckCronSchedule_()
23842407
{
2385-
! "$inRouterSWmode" && return 0
2408+
! "$mountWebGUI_OK" && return 0
23862409
local fwUpdtCronScheduleRaw fwUpdtCronScheduleStr
23872410
fwUpdtCronScheduleRaw="$(Get_Custom_Setting FW_New_Update_Cron_Job_Schedule)"
23882411
fwUpdtCronScheduleStr="$(_TranslateCronSchedHR_ "$fwUpdtCronScheduleRaw")"
@@ -2394,7 +2417,7 @@ _WebUI_AutoFWUpdateCheckCronSchedule_()
23942417
##-------------------------------------##
23952418
_WebUI_AutoScriptUpdateCronSchedule_()
23962419
{
2397-
! "$inRouterSWmode" && return 0
2420+
! "$mountWebGUI_OK" && return 0
23982421
local scriptUpdtCronSchedRaw scriptUpdtCronSchedStr
23992422
scriptUpdtCronSchedRaw="$(_GetScriptAutoUpdateCronSchedule_)"
24002423
scriptUpdtCronSchedStr="$(_TranslateCronSchedHR_ "$scriptUpdtCronSchedRaw")"
@@ -2406,7 +2429,7 @@ _WebUI_AutoScriptUpdateCronSchedule_()
24062429
##-------------------------------------##
24072430
_WebUI_SetEmailConfigFileFromAMTM_()
24082431
{
2409-
! "$inRouterSWmode" && return 0
2432+
! "$mountWebGUI_OK" && return 0
24102433
_CheckEMailConfigFileFromAMTM_ 0
24112434
_WriteVarDefToHelperJSFile_ "isEMailConfigEnabledInAMTM" "$isEMailConfigEnabledInAMTM" true
24122435
}
@@ -2634,7 +2657,7 @@ _DownloadScriptFiles_()
26342657
retCode=1
26352658
Say "${REDct}**ERROR**${NOct}: Unable to download latest version file for $SCRIPT_NAME."
26362659
fi
2637-
if "$inRouterSWmode" && \
2660+
if "$mountWebGUI_OK" && \
26382661
_CurlFileDownload_ "$SCRIPT_WEB_ASP_FILE" "$SCRIPT_WEB_ASP_PATH"
26392662
then
26402663
chmod 664 "$SCRIPT_WEB_ASP_PATH"
@@ -2650,7 +2673,7 @@ _DownloadScriptFiles_()
26502673
"$isUpdateAction" && _Mount_WebUI_
26512674
fi
26522675
retCode=0
2653-
elif "$inRouterSWmode"
2676+
elif "$mountWebGUI_OK"
26542677
then
26552678
retCode=1
26562679
Say "${REDct}**ERROR**${NOct}: Unable to download latest WebUI ASP file for $SCRIPT_NAME."
@@ -2687,7 +2710,7 @@ _SCRIPT_UPDATE_()
26872710
if _DownloadScriptFiles_ update
26882711
then
26892712
printf "${CYANct}$SCRIPT_NAME files were successfully updated.${NOct}\n\n"
2690-
if "$inRouterSWmode"
2713+
if "$mountWebGUI_OK"
26912714
then
26922715
_SetVersionSharedSettings_ local "$DLRepoVersion"
26932716
_SetVersionSharedSettings_ server "$DLRepoVersion"
@@ -2709,7 +2732,7 @@ _SCRIPT_UPDATE_()
27092732
printf "${CYANct}Version Currently Installed: ${YLWct}${SCRIPT_VERSION}${NOct}\n"
27102733
printf "${CYANct}Update Version Available Now: ${YLWct}${DLRepoVersion}${NOct}\n\n"
27112734

2712-
if "$inRouterSWmode"
2735+
if "$mountWebGUI_OK"
27132736
then _SetVersionSharedSettings_ server "$DLRepoVersion" ; fi
27142737

27152738
if [ "$SCRIPT_VERSION" = "$DLRepoVersion" ]
@@ -2722,7 +2745,7 @@ _SCRIPT_UPDATE_()
27222745

27232746
if _DownloadScriptFiles_ update
27242747
then
2725-
if "$inRouterSWmode"
2748+
if "$mountWebGUI_OK"
27262749
then _SetVersionSharedSettings_ local "$DLRepoVersion" ; fi
27272750
printf "\n${CYANct}Download successful!${NOct}\n"
27282751
printf "$(date) - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n"
@@ -2743,7 +2766,7 @@ _SCRIPT_UPDATE_()
27432766

27442767
if _DownloadScriptFiles_ update
27452768
then
2746-
if "$inRouterSWmode"
2769+
if "$mountWebGUI_OK"
27472770
then _SetVersionSharedSettings_ local "$DLRepoVersion" ; fi
27482771
printf "\n$(date) - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n"
27492772
printf "${CYANct}Update successful! Restarting script...${NOct}\n"
@@ -2885,7 +2908,7 @@ _CreateEMailContent_()
28852908
} > "$tempEMailBodyMsg"
28862909
;;
28872910
AGGREGATED_UPDATE_NOTIFICATION)
2888-
if "$inRouterSWmode" && [ -n "$node_list" ]; then
2911+
if "$aiMeshNodes_OK" && [ -n "$node_list" ]; then
28892912
nodefwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromNode_ 1)"
28902913
fi
28912914
if [ -z "$nodefwNewUpdateVersion" ]
@@ -7349,7 +7372,7 @@ _CheckNewUpdateFirmwareNotification_()
73497372
fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")"
73507373
Update_Custom_Settings FW_New_Update_Notification_Vers "$fwNewUpdateNotificationVers"
73517374
Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate"
7352-
"$inRouterSWmode" && sendNewUpdateStatusEmail=true
7375+
"$mountWebGUI_OK" && sendNewUpdateStatusEmail=true
73537376
if ! "$FlashStarted"
73547377
then
73557378
if "$isGNUtonFW"
@@ -7367,7 +7390,7 @@ _CheckNewUpdateFirmwareNotification_()
73677390
then
73687391
fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")"
73697392
Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate"
7370-
"$inRouterSWmode" && sendNewUpdateStatusEmail=true
7393+
"$mountWebGUI_OK" && sendNewUpdateStatusEmail=true
73717394
if ! "$FlashStarted"
73727395
then
73737396
if "$isGNUtonFW"
@@ -9126,7 +9149,7 @@ _DoStartupInit_()
91269149
_InitHelperJSFile_
91279150
_SetVersionSharedSettings_ local "$SCRIPT_VERSION"
91289151

9129-
if "$inRouterSWmode"
9152+
if "$mountWebGUI_OK"
91309153
then
91319154
_Mount_WebUI_
91329155
_AutoStartupHook_ create 2>/dev/null
@@ -9151,7 +9174,7 @@ _DoInstallation_()
91519174
_SetVersionSharedSettings_ server "$SCRIPT_VERSION"
91529175
_DownloadScriptFiles_ install
91539176

9154-
if "$inRouterSWmode"
9177+
if "$mountWebGUI_OK"
91559178
then
91569179
! _Mount_WebUI_ && webguiOK=false
91579180
_AutoStartupHook_ create 2>/dev/null
@@ -9196,7 +9219,7 @@ _DoUnInstallation_()
91969219
_DelPostUpdateEmailNotifyScriptHook_
91979220
_SetVersionSharedSettings_ delete
91989221

9199-
if "$inRouterSWmode"
9222+
if "$mountWebGUI_OK"
92009223
then
92019224
_Unmount_WebUI_
92029225
_AutoStartupHook_ delete 2>/dev/null
@@ -9447,7 +9470,7 @@ _ProcessMeshNodes_()
94479470
if ! node_list="$(_GetNodeIPv4List_)"
94489471
then node_list="" ; fi
94499472

9450-
if "$inRouterSWmode"
9473+
if "$aiMeshNodes_OK"
94519474
then
94529475
if [ -n "$node_list" ]
94539476
then
@@ -10115,7 +10138,7 @@ _ShowMainMenuOptions_()
1011510138
printf "\n ${GRNct}ad${NOct}. Advanced Options\n"
1011610139

1011710140
# Check for AiMesh Nodes #
10118-
if "$inRouterSWmode" && [ -n "$node_list" ]; then
10141+
if "$aiMeshNodes_OK" && [ -n "$node_list" ]; then
1011910142
printf "\n ${GRNct}mn${NOct}. AiMesh Node(s) Info\n"
1012010143
fi
1012110144

@@ -10266,7 +10289,7 @@ _ShowAdvancedOptionsMenu_()
1026610289
if _CheckEMailConfigFileFromAMTM_ 0
1026710290
then
1026810291
# F/W Update Email Notifications #
10269-
if "$inRouterSWmode"
10292+
if "$mountWebGUI_OK"
1027010293
then
1027110294
printf "\n ${GRNct}em${NOct}. Toggle F/W Update Email Notifications"
1027210295
else
@@ -10565,7 +10588,7 @@ _MainMenu_()
1056510588
;;
1056610589
ad) _AdvancedOptionsMenu_
1056710590
;;
10568-
mn) if "$inRouterSWmode" && [ -n "$node_list" ]
10591+
mn) if "$aiMeshNodes_OK" && [ -n "$node_list" ]
1056910592
then _ShowNodesMenuOptions_
1057010593
else _InvalidMenuSelection_
1057110594
fi
@@ -10610,7 +10633,7 @@ _DoInitializationStartup_()
1061010633
_InitHelperJSFile_
1061110634
_SetVersionSharedSettings_ local "$SCRIPT_VERSION"
1061210635

10613-
if "$inRouterSWmode"
10636+
if "$mountWebGUI_OK"
1061410637
then
1061510638
_AutoStartupHook_ create 2>/dev/null
1061610639
_AutoServiceEvent_ create 2>/dev/null

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.4.0
3-
## 2025-Mar-18
3+
## 2025-Mar-19
44

55
## WebUI:
66
![image](https://github.com/user-attachments/assets/10d0971c-b3c6-477a-8904-d4bf013f72df)

0 commit comments

Comments
 (0)