44#
55# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7- # Last Modified: 2024-Apr-07
7+ # Last Modified: 2024-Apr-15
88# ##################################################################
99set -u
1010
11- readonly SCRIPT_VERSION=1.1.0
11+ readonly SCRIPT_VERSION=1.1.1
1212readonly SCRIPT_NAME=" MerlinAU"
1313
1414# #-------------------------------------##
@@ -2039,15 +2039,15 @@ _TestLoginCredentials_()
20392039}
20402040
20412041# #----------------------------------------##
2042- # # Modified by Martinski W. [2024-Mar-03 ] ##
2042+ # # Modified by Martinski W. [2024-Apr-15 ] ##
20432043# #----------------------------------------##
20442044_GetPasswordInput_ ()
20452045{
20462046 local PSWDstrLenMIN=1 PSWDstrLenMAX=64
20472047 local PSWDstring PSWDtmpStr PSWDprompt
20482048 local retCode charNum pswdLength showPSWD
20492049 # Added for TAB keypress debounce #
2050- local lastTabTime=0 currentTime timeDiff
2050+ local lastTabTime=0 currentTime
20512051
20522052 if [ $# -eq 0 ] || [ -z " $1 " ]
20532053 then
@@ -2065,7 +2065,15 @@ _GetPasswordInput_()
20652065 stty " $savedSettings "
20662066 }
20672067
2068- _showPSWDPrompt_ ()
2068+ _ShowAsterisks_ ()
2069+ {
2070+ if [ $# -eq 0 ] || [ " $1 " -eq 0 ]
2071+ then echo " "
2072+ else printf " %*s" " $1 " ' ' | tr ' ' ' *'
2073+ fi
2074+ }
2075+
2076+ _ShowPSWDPrompt_ ()
20692077 {
20702078 local pswdTemp LENct LENwd
20712079 [ " $showPSWD " = " 1" ] && pswdTemp=" $PSWDstring " || pswdTemp=" $PSWDtmpStr "
@@ -2080,12 +2088,10 @@ _GetPasswordInput_()
20802088 charNum=" "
20812089 PSWDstring=" $pswdString "
20822090 pswdLength=" ${# PSWDstring} "
2083- if [ -z " $PSWDstring " ]
2084- then PSWDtmpStr=" "
2085- else PSWDtmpStr=" $( printf " %*s" " $pswdLength " " " | tr ' ' ' *' ) "
2086- fi
2087- echo ; _showPSWDPrompt_
2091+ PSWDtmpStr=" $( _ShowAsterisks_ " $pswdLength " ) "
2092+ echo ; _ShowPSWDPrompt_
20882093
2094+ local savedIFS=" $IFS "
20892095 while IFS=' ' theChar=" $( _GetKeypress_) "
20902096 do
20912097 charNum=" $( printf " %d" " '$theChar " ) "
@@ -2119,12 +2125,11 @@ _GetPasswordInput_()
21192125 if [ " $charNum " -eq 9 ]
21202126 then
21212127 currentTime=" $( date +%s) "
2122- timeDiff=" $(( currentTime - lastTabTime)) "
2123- if [ " $timeDiff " -gt 0 ]
2128+ if [ " $(( currentTime - lastTabTime)) " -gt 0 ]
21242129 then
21252130 showPSWD=" $(( ! showPSWD)) "
2126- lastTabTime=" $currentTime " # Update last TAB press time #
2127- _showPSWDPrompt_
2131+ lastTabTime=" $currentTime " # Update TAB keypress time #
2132+ _ShowPSWDPrompt_
21282133 fi
21292134 continue
21302135 fi
@@ -2134,10 +2139,10 @@ _GetPasswordInput_()
21342139 then
21352140 if [ " $pswdLength " -gt 0 ]
21362141 then
2137- PSWDtmpStr=" ${PSWDtmpStr% ?} "
21382142 PSWDstring=" ${PSWDstring% ?} "
2139- pswdLength=" $(( pswdLength - 1 )) "
2140- _showPSWDPrompt_
2143+ pswdLength=" ${# PSWDstring} "
2144+ PSWDtmpStr=" $( _ShowAsterisks_ " $pswdLength " ) "
2145+ _ShowPSWDPrompt_
21412146 continue
21422147 fi
21432148 fi
@@ -2147,13 +2152,15 @@ _GetPasswordInput_()
21472152 then
21482153 if [ " $pswdLength " -le " $PSWDstrLenMAX " ]
21492154 then
2150- PSWDtmpStr=" ${PSWDtmpStr} *"
2151- pswdLength=" $(( pswdLength + 1 )) "
21522155 PSWDstring=" ${PSWDstring}${theChar} "
2156+ pswdLength=" ${# PSWDstring} "
2157+ PSWDtmpStr=" $( _ShowAsterisks_ " $pswdLength " ) "
2158+ _ShowPSWDPrompt_
2159+ continue
21532160 fi
2154- _showPSWDPrompt_
21552161 fi
21562162 done
2163+ IFS=" $savedIFS "
21572164
21582165 pswdString=" $PSWDstring "
21592166 return " $retCode "
@@ -3008,7 +3015,7 @@ _Set_FW_UpdateCronSchedule_()
30083015}
30093016
30103017# #------------------------------------------##
3011- # # Modified by ExtremeFiretop [2024-Jan-26 ] ##
3018+ # # Modified by ExtremeFiretop [2024-Apr-13 ] ##
30123019# #------------------------------------------##
30133020_CheckNewUpdateFirmwareNotification_ ()
30143021{
@@ -3043,7 +3050,10 @@ _CheckNewUpdateFirmwareNotification_()
30433050 fwNewUpdateNotificationDate=" $( date +" $FW_UpdateNotificationDateFormat " ) "
30443051 Update_Custom_Settings FW_New_Update_Notification_Vers " $fwNewUpdateNotificationVers "
30453052 Update_Custom_Settings FW_New_Update_Notification_Date " $fwNewUpdateNotificationDate "
3046- _SendEMailNotification_ NEW_FW_UPDATE_STATUS
3053+ if " $inRouterSWmode "
3054+ then
3055+ _SendEMailNotification_ NEW_FW_UPDATE_STATUS
3056+ fi
30473057 fi
30483058 fi
30493059
@@ -3052,7 +3062,10 @@ _CheckNewUpdateFirmwareNotification_()
30523062 then
30533063 fwNewUpdateNotificationDate=" $( date +" $FW_UpdateNotificationDateFormat " ) "
30543064 Update_Custom_Settings FW_New_Update_Notification_Date " $fwNewUpdateNotificationDate "
3055- _SendEMailNotification_ NEW_FW_UPDATE_STATUS
3065+ if " $inRouterSWmode "
3066+ then
3067+ _SendEMailNotification_ NEW_FW_UPDATE_STATUS
3068+ fi
30563069 fi
30573070 return 0
30583071}
@@ -3427,11 +3440,12 @@ Please manually update to version $minimum_supported_version or higher to use th
34273440
34283441 # Use set to read the output of the function into variables
34293442 set -- $( _GetLatestFWUpdateVersionFromWebsite_ " $FW_URL_RELEASE " )
3430- release_version=" $1 "
3431- release_link=" $2 "
3432-
3433- if [ " $release_version " = " **ERROR**" ] && [ " $release_link " = " **NO_URL**" ]
3443+ if [ $? -eq 0 ] && [ $# -eq 2 ] && \
3444+ [ " $1 " != " **ERROR**" ] && [ " $2 " != " **NO_URL**" ]
34343445 then
3446+ release_version=" $1 "
3447+ release_link=" $2 "
3448+ else
34353449 Say " ${REDct} **ERROR**${NOct} : No firmware release URL was found for [$PRODUCT_ID ] router model."
34363450 " $inMenuMode " && _WaitForEnterKey_ " $mainMenuReturnPromptStr "
34373451 return 1
@@ -4729,13 +4743,8 @@ _ProcessMeshNodes_()
47294743 else
47304744 if [ " $includeExtraLogic " -eq 1 ]; then
47314745 printf " \n${padStr}${padStr}${padStr}${REDct} No AiMesh Node(s)${NOct} "
4732- else
4733- Say " No AiMesh Node(s). Disabling AiMesh verification."
47344746 fi
47354747 fi
4736- else
4737- # Else statement for when not running on primary router #
4738- Say " Not running on Primary Router. Skipping AiMesh verification."
47394748 fi
47404749}
47414750
@@ -4853,15 +4862,14 @@ _ShowNodesMenuOptions_()
48534862# Main Menu loop
48544863inMenuMode=true
48554864HIDE_ROUTER_SECTION=false
4865+ if ! node_list=" $( _GetNodeIPv4List_) "
4866+ then node_list=" " ; fi
48564867
48574868while true
48584869do
48594870 # Check if the directory exists again before attempting to navigate to it
48604871 [ -d " $FW_BIN_DIR " ] && cd " $FW_BIN_DIR "
48614872
4862- if ! node_list=" $( _GetNodeIPv4List_) "
4863- then node_list=" " ; fi
4864-
48654873 _ShowMainMenu_
48664874 printf " Enter selection: " ; read -r userChoice
48674875 echo
0 commit comments