From 5014ec8bf10b867e889d27b53776602223f1f0f5 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 12 Feb 2025 22:18:55 -0800 Subject: [PATCH] Functional Improvement Added and modified code so that every time the SSH CLI menu is run, it checks if the WebGUI page has already been mounted. If not found mounted, the script will run the code to remount the WebGUI. --- MerlinAU.sh | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index c47088bf..b1718a18 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1776,35 +1776,46 @@ then fi ##-------------------------------------## -## Added by Martinski W. [2025-Jan-11] ## +## Added by Martinski W. [2025-Feb-12] ## ##-------------------------------------## -_GetWebUIPage_() +_Check_WebGUI_Page_Exists_() { - local webPageFile webPagePath webPageTemp webPageEntry + local webPageStr webPageFile theWebPage - webPageFile="NONE" + if [ ! -f "$TEMP_MENU_TREE" ] + then echo "NONE" ; return 1 ; fi - if [ -f "$TEMP_MENU_TREE" ] + theWebPage="NONE" + webPageStr="$(grep -E -m1 "$webPageLineRegExp" "$TEMP_MENU_TREE")" + if [ -n "$webPageStr" ] then - webPageEntry="$(grep -E "$webPageLineRegExp" "$TEMP_MENU_TREE")" - if [ -n "$webPageEntry" ] - then - webPageTemp="$(echo "$webPageEntry" | grep -owE "$webPageFileRegExp")" - [ -n "$webPageTemp" ] && webPageFile="$webPageTemp" - fi + webPageFile="$(echo "$webPageStr" | grep -owE "$webPageFileRegExp" | head -n1)" + if [ -n "$webPageFile" ] && [ -s "${SHARED_WEB_DIR}/$webPageFile" ] + then theWebPage="$webPageFile" ; fi fi + echo "$theWebPage" +} + +##----------------------------------------## +## Modified by Martinski W. [2025-Feb-12] ## +##----------------------------------------## +_GetWebUIPage_() +{ + local webPageFile webPagePath webPageTemp + + webPageFile="$(_Check_WebGUI_Page_Exists_)" for index in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do webPageTemp="user${index}.asp" webPagePath="${SHARED_WEB_DIR}/$webPageTemp" - if [ -f "$webPagePath" ] && \ + if [ -s "$webPagePath" ] && \ [ "$(md5sum < "$1")" = "$(md5sum < "$webPagePath")" ] then webPageFile="$webPageTemp" break - elif [ "$webPageFile" = "NONE" ] && [ ! -f "$webPagePath" ] + elif [ "$webPageFile" = "NONE" ] && [ ! -s "$webPagePath" ] then webPageFile="$webPageTemp" fi @@ -1824,7 +1835,7 @@ _Mount_WebUI_() fi local webPageFile - Say "Mounting WebUI page for $SCRIPT_NAME" + Say "Mounting WebUI page for ${SCRIPT_NAME}..." eval exec "$WEBUI_LOCKFD>$WEBUI_LOCKFILE" flock -x "$WEBUI_LOCKFD" @@ -1856,6 +1867,16 @@ _Mount_WebUI_() return 0 } +##-------------------------------------## +## Added by Martinski W. [2025-Feb-12] ## +##-------------------------------------## +_CheckFor_WebGUI_Page_() +{ + if "$inRouterSWmode" && \ + [ "$(_Check_WebGUI_Page_Exists_)" = "NONE" ] + then _Mount_WebUI_ ; fi +} + ##----------------------------------------## ## Modified by Martinski W. [2025-Jan-11] ## ##----------------------------------------## @@ -10263,7 +10284,7 @@ FW_InstalledVerStr="${GRNct}${FW_InstalledVersion}${NOct}" FW_NewUpdateVerInit=TBD ##----------------------------------------## -## Modified by Martinski W. [2025-Jan-10] ## +## Modified by Martinski W. [2025-Feb-12] ## ##----------------------------------------## if [ $# -eq 0 ] || [ -z "$1" ] || \ { [ $# -gt 1 ] && [ "$1" = "reload" ] ; } @@ -10281,6 +10302,7 @@ then if [ "$ScriptAutoUpdateSetting" = "ENABLED" ] then _AddScriptAutoUpdateCronJob_ ; fi _ConfirmCronJobForFWAutoUpdates_ + _CheckFor_WebGUI_Page_ _MainMenu_ "$@" _DoExit_ 0