From 8606f62264da72e8d29b98974635b66477ed77ab Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 19 Mar 2025 02:00:51 -0700 Subject: [PATCH 1/3] 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. --- MerlinAU.sh | 95 +++++++++++++++++++++++++++++++++-------------------- README.md | 2 +- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b0d9fbf6..4679babb 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-Mar-18 +# Last Modified: 2025-Mar-19 ################################################################### set -u @@ -208,13 +208,24 @@ case "$fwInstalledBranchVer" in esac ##----------------------------------------## -## Modified by Martinski W. [2025-Mar-18] ## +## Modified by Martinski W. [2025-Mar-19] ## ##----------------------------------------## -nvramSWmode="$(nvram get sw_mode)" -## FOR TESTING WebGUI support when AP Mode ## -if [ "$nvramSWmode" -eq 1 ] || [ "$nvramSWmode" -eq 3 ] -then inRouterSWmode=true -else inRouterSWmode=false +aiMeshNodes_OK=false +mountWebGUI_OK=false +inMainRouterMode=false +inAccessPointMode=false + +readonly nvramSWmode="$(nvram get sw_mode)" +if [ "$nvramSWmode" = "1" ] +then + mountWebGUI_OK=true + aiMeshNodes_OK=true + inMainRouterMode=true +elif [ "$nvramSWmode" = "3" ] +then + mountWebGUI_OK=true + aiMeshNodes_OK=true + inAccessPointMode=true fi readonly mainMenuReturnPromptStr="Press to return to the Main Menu..." @@ -505,10 +516,19 @@ _ShowLogo_() } ##----------------------------------------## -## Modified by Martinski W. [2025-Feb-22] ## +## Modified by Martinski W. [2025-Mar-19] ## ##----------------------------------------## _ShowAbout_() { + local webUI_Page webUI_URL="[Not Available]" + if "$mountWebGUI_OK" + then + webUI_Page="$(_Check_WebGUI_Page_Exists_)" + if [ "$webUI_Page" != "NONE" ] + then webUI_URL="$(_GetRouterURL_)/$webUI_Page" + fi + fi + clear _ShowLogo_ cat </dev/null fi - ! "$inRouterSWmode" && return 0 + ! "$mountWebGUI_OK" && return 0 ln -sf "$CONFIG_FILE" "${SCRIPT_WEB_DIR}/config.htm" 2>/dev/null ln -sf "$HELPER_JSFILE" "${SCRIPT_WEB_DIR}/checkHelper.js" 2>/dev/null @@ -2382,7 +2405,7 @@ _WriteVarDefToHelperJSFile_() ##-------------------------------------## _WebUI_AutoFWUpdateCheckCronSchedule_() { - ! "$inRouterSWmode" && return 0 + ! "$mountWebGUI_OK" && return 0 local fwUpdtCronScheduleRaw fwUpdtCronScheduleStr fwUpdtCronScheduleRaw="$(Get_Custom_Setting FW_New_Update_Cron_Job_Schedule)" fwUpdtCronScheduleStr="$(_TranslateCronSchedHR_ "$fwUpdtCronScheduleRaw")" @@ -2394,7 +2417,7 @@ _WebUI_AutoFWUpdateCheckCronSchedule_() ##-------------------------------------## _WebUI_AutoScriptUpdateCronSchedule_() { - ! "$inRouterSWmode" && return 0 + ! "$mountWebGUI_OK" && return 0 local scriptUpdtCronSchedRaw scriptUpdtCronSchedStr scriptUpdtCronSchedRaw="$(_GetScriptAutoUpdateCronSchedule_)" scriptUpdtCronSchedStr="$(_TranslateCronSchedHR_ "$scriptUpdtCronSchedRaw")" @@ -2406,7 +2429,7 @@ _WebUI_AutoScriptUpdateCronSchedule_() ##-------------------------------------## _WebUI_SetEmailConfigFileFromAMTM_() { - ! "$inRouterSWmode" && return 0 + ! "$mountWebGUI_OK" && return 0 _CheckEMailConfigFileFromAMTM_ 0 _WriteVarDefToHelperJSFile_ "isEMailConfigEnabledInAMTM" "$isEMailConfigEnabledInAMTM" true } @@ -2634,7 +2657,7 @@ _DownloadScriptFiles_() retCode=1 Say "${REDct}**ERROR**${NOct}: Unable to download latest version file for $SCRIPT_NAME." fi - if "$inRouterSWmode" && \ + if "$mountWebGUI_OK" && \ _CurlFileDownload_ "$SCRIPT_WEB_ASP_FILE" "$SCRIPT_WEB_ASP_PATH" then chmod 664 "$SCRIPT_WEB_ASP_PATH" @@ -2650,7 +2673,7 @@ _DownloadScriptFiles_() "$isUpdateAction" && _Mount_WebUI_ fi retCode=0 - elif "$inRouterSWmode" + elif "$mountWebGUI_OK" then retCode=1 Say "${REDct}**ERROR**${NOct}: Unable to download latest WebUI ASP file for $SCRIPT_NAME." @@ -2687,7 +2710,7 @@ _SCRIPT_UPDATE_() if _DownloadScriptFiles_ update then printf "${CYANct}$SCRIPT_NAME files were successfully updated.${NOct}\n\n" - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _SetVersionSharedSettings_ local "$DLRepoVersion" _SetVersionSharedSettings_ server "$DLRepoVersion" @@ -2709,7 +2732,7 @@ _SCRIPT_UPDATE_() printf "${CYANct}Version Currently Installed: ${YLWct}${SCRIPT_VERSION}${NOct}\n" printf "${CYANct}Update Version Available Now: ${YLWct}${DLRepoVersion}${NOct}\n\n" - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _SetVersionSharedSettings_ server "$DLRepoVersion" ; fi if [ "$SCRIPT_VERSION" = "$DLRepoVersion" ] @@ -2722,7 +2745,7 @@ _SCRIPT_UPDATE_() if _DownloadScriptFiles_ update then - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _SetVersionSharedSettings_ local "$DLRepoVersion" ; fi printf "\n${CYANct}Download successful!${NOct}\n" printf "$(date) - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n" @@ -2743,7 +2766,7 @@ _SCRIPT_UPDATE_() if _DownloadScriptFiles_ update then - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _SetVersionSharedSettings_ local "$DLRepoVersion" ; fi printf "\n$(date) - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n" printf "${CYANct}Update successful! Restarting script...${NOct}\n" @@ -2885,7 +2908,7 @@ _CreateEMailContent_() } > "$tempEMailBodyMsg" ;; AGGREGATED_UPDATE_NOTIFICATION) - if "$inRouterSWmode" && [ -n "$node_list" ]; then + if "$aiMeshNodes_OK" && [ -n "$node_list" ]; then nodefwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromNode_ 1)" fi if [ -z "$nodefwNewUpdateVersion" ] @@ -7349,7 +7372,7 @@ _CheckNewUpdateFirmwareNotification_() fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Vers "$fwNewUpdateNotificationVers" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" - "$inRouterSWmode" && sendNewUpdateStatusEmail=true + "$mountWebGUI_OK" && sendNewUpdateStatusEmail=true if ! "$FlashStarted" then if "$isGNUtonFW" @@ -7367,7 +7390,7 @@ _CheckNewUpdateFirmwareNotification_() then fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" - "$inRouterSWmode" && sendNewUpdateStatusEmail=true + "$mountWebGUI_OK" && sendNewUpdateStatusEmail=true if ! "$FlashStarted" then if "$isGNUtonFW" @@ -9126,7 +9149,7 @@ _DoStartupInit_() _InitHelperJSFile_ _SetVersionSharedSettings_ local "$SCRIPT_VERSION" - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _Mount_WebUI_ _AutoStartupHook_ create 2>/dev/null @@ -9151,7 +9174,7 @@ _DoInstallation_() _SetVersionSharedSettings_ server "$SCRIPT_VERSION" _DownloadScriptFiles_ install - if "$inRouterSWmode" + if "$mountWebGUI_OK" then ! _Mount_WebUI_ && webguiOK=false _AutoStartupHook_ create 2>/dev/null @@ -9196,7 +9219,7 @@ _DoUnInstallation_() _DelPostUpdateEmailNotifyScriptHook_ _SetVersionSharedSettings_ delete - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _Unmount_WebUI_ _AutoStartupHook_ delete 2>/dev/null @@ -9447,7 +9470,7 @@ _ProcessMeshNodes_() if ! node_list="$(_GetNodeIPv4List_)" then node_list="" ; fi - if "$inRouterSWmode" + if "$aiMeshNodes_OK" then if [ -n "$node_list" ] then @@ -10115,7 +10138,7 @@ _ShowMainMenuOptions_() printf "\n ${GRNct}ad${NOct}. Advanced Options\n" # Check for AiMesh Nodes # - if "$inRouterSWmode" && [ -n "$node_list" ]; then + if "$aiMeshNodes_OK" && [ -n "$node_list" ]; then printf "\n ${GRNct}mn${NOct}. AiMesh Node(s) Info\n" fi @@ -10266,7 +10289,7 @@ _ShowAdvancedOptionsMenu_() if _CheckEMailConfigFileFromAMTM_ 0 then # F/W Update Email Notifications # - if "$inRouterSWmode" + if "$mountWebGUI_OK" then printf "\n ${GRNct}em${NOct}. Toggle F/W Update Email Notifications" else @@ -10565,7 +10588,7 @@ _MainMenu_() ;; ad) _AdvancedOptionsMenu_ ;; - mn) if "$inRouterSWmode" && [ -n "$node_list" ] + mn) if "$aiMeshNodes_OK" && [ -n "$node_list" ] then _ShowNodesMenuOptions_ else _InvalidMenuSelection_ fi @@ -10610,7 +10633,7 @@ _DoInitializationStartup_() _InitHelperJSFile_ _SetVersionSharedSettings_ local "$SCRIPT_VERSION" - if "$inRouterSWmode" + if "$mountWebGUI_OK" then _AutoStartupHook_ create 2>/dev/null _AutoServiceEvent_ create 2>/dev/null diff --git a/README.md b/README.md index 3a4cd927..e8f3d68c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater ## v1.4.0 -## 2025-Mar-18 +## 2025-Mar-19 ## WebUI: ![image](https://github.com/user-attachments/assets/10d0971c-b3c6-477a-8904-d4bf013f72df) From 8198a233ca1e8192f2571708812fd196de1f5c89 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 19 Mar 2025 04:42:29 -0700 Subject: [PATCH 2/3] More Improvements Improvements to detect AP Mode. --- MerlinAU.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 4679babb..d189d16d 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -221,11 +221,14 @@ then mountWebGUI_OK=true aiMeshNodes_OK=true inMainRouterMode=true -elif [ "$nvramSWmode" = "3" ] -then - mountWebGUI_OK=true - aiMeshNodes_OK=true - inAccessPointMode=true +else + if [ "$nvramSWmode" = "3" ] && \ + [ "$(nvram get wlc_psta)" = "0" ] + then + mountWebGUI_OK=true + aiMeshNodes_OK=true ##??TBD??## + inAccessPointMode=true + fi fi readonly mainMenuReturnPromptStr="Press to return to the Main Menu..." From 4b5174c9c692937557d48ffa863e6955bb6801d3 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 20 Mar 2025 20:57:54 -0700 Subject: [PATCH 3/3] Disable AiMesh Nodes menu from APs. --- MerlinAU.sh | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index d189d16d..f1dd5a46 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-Mar-19 +# Last Modified: 2025-Mar-20 ################################################################### set -u @@ -226,7 +226,7 @@ else [ "$(nvram get wlc_psta)" = "0" ] then mountWebGUI_OK=true - aiMeshNodes_OK=true ##??TBD??## + aiMeshNodes_OK=false inAccessPointMode=true fi fi diff --git a/README.md b/README.md index e8f3d68c..b147e0d0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater ## v1.4.0 -## 2025-Mar-19 +## 2025-Mar-20 ## WebUI: ![image](https://github.com/user-attachments/assets/10d0971c-b3c6-477a-8904-d4bf013f72df)