|
4 | 4 | # |
5 | 5 | # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. |
6 | 6 | # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 |
7 | | -# Last Modified: 2026-May-16 |
| 7 | +# Last Modified: 2026-May-21 |
8 | 8 | ################################################################### |
9 | 9 | set -u |
10 | 10 |
|
11 | 11 | ## Set version for each Production Release ## |
12 | | -readonly SCRIPT_VERSION=1.6.2 |
13 | | -readonly SCRIPT_VERSTAG="26051600" |
| 12 | +readonly SCRIPT_VERSION=1.6.3 |
| 13 | +readonly SCRIPT_VERSTAG="26052123" |
14 | 14 | readonly SCRIPT_NAME="MerlinAU" |
15 | 15 | ## Set to "master" for Production Releases ## |
16 | 16 | SCRIPT_BRANCH="master" |
|
173 | 173 | inMenuMode=true |
174 | 174 | webguiMode=false |
175 | 175 | isVerbose=false |
176 | | -isInteractive=false |
177 | 176 | FlashStarted=false |
178 | 177 | MerlinChangeLogURL="" |
179 | 178 | GnutonChangeLogURL="" |
180 | 179 | keepConfigFile=false |
181 | 180 | bypassPostponedDays=false |
182 | 181 | runLoginCredentialsTest=false |
183 | 182 |
|
| 183 | +if [ -t 0 ] && ! tty | grep -qwi "NOT" |
| 184 | +then |
| 185 | + isVerbose=true |
| 186 | + readonly isInteractive=true |
| 187 | + readonly gSavedSTTY="$(stty -g)" |
| 188 | +else |
| 189 | + readonly isInteractive=false |
| 190 | +fi |
| 191 | + |
| 192 | +if [ "$isInteractive" = "false" ] && { [ $# -eq 0 ] || [ -z "$1" ] ; } |
| 193 | +then |
| 194 | + logger -st "${SCRIPT_NAME}_[$$]" -p 3 "**ERROR**: CLI Menu is NOT available in a non-interactive shell" |
| 195 | + exit 1 |
| 196 | +fi |
| 197 | + |
184 | 198 | # Main LAN Network Info # |
185 | 199 | readonly myLAN_HostName="$(nvram get lan_hostname)" |
186 | 200 | readonly mainLAN_IFname="$(nvram get lan_ifname)" |
@@ -277,12 +291,6 @@ routerLoginFailureMsg="Please try the following: |
277 | 291 | to restrict access to the router webGUI from the router's IP address [${GRNct}${mainLAN_IPaddr}${NOct}]. |
278 | 292 | 3. Confirm your password via the \"Set Router Login Password\" option from the Main Menu." |
279 | 293 |
|
280 | | -if [ -t 0 ] && ! tty | grep -qwi "NOT" |
281 | | -then |
282 | | - isInteractive=true ; isVerbose=true |
283 | | - readonly gSavedSTTY="$(stty -g)" |
284 | | -fi |
285 | | - |
286 | 294 | ##----------------------------------------## |
287 | 295 | ## Modified by Martinski W. [2023-Dec-23] ## |
288 | 296 | ##----------------------------------------## |
@@ -3011,7 +3019,7 @@ _CheckNewScriptMinFWBeforeUpdate_() |
3011 | 3019 | } |
3012 | 3020 |
|
3013 | 3021 | ##----------------------------------------## |
3014 | | -## Modified by Martinski W. [2026-Feb-22] ## |
| 3022 | +## Modified by Martinski W. [2026-May-21] ## |
3015 | 3023 | ##----------------------------------------## |
3016 | 3024 | _SCRIPT_UPDATE_() |
3017 | 3025 | { |
@@ -3062,14 +3070,13 @@ _SCRIPT_UPDATE_() |
3062 | 3070 | _SendEMailNotification_ SUCCESS_SCRIPT_UPDATE_STATUS |
3063 | 3071 | fi |
3064 | 3072 | sleep 1 |
3065 | | - if [ $# -lt 2 ] || [ -z "$2" ] |
| 3073 | + if "$isInteractive" && { [ $# -lt 2 ] || [ -z "$2" ] ; } |
3066 | 3074 | then |
3067 | 3075 | _ReleaseLock_ |
3068 | 3076 | exec "$ScriptFilePath" |
3069 | 3077 | exit 0 |
3070 | | - elif [ "$2" = "unattended" ] |
3071 | | - then |
3072 | | - return 0 |
| 3078 | + else |
| 3079 | + return 0 #Unattended# |
3073 | 3080 | fi |
3074 | 3081 | else |
3075 | 3082 | if ! "$isInteractive" |
@@ -3197,9 +3204,9 @@ ScriptUpdateFromAMTM() |
3197 | 3204 | return "$retCode" |
3198 | 3205 | } |
3199 | 3206 |
|
3200 | | -##------------------------------------------## |
3201 | | -## Modified by ExtremeFiretop [2025-May-10] ## |
3202 | | -##------------------------------------------## |
| 3207 | +##----------------------------------------## |
| 3208 | +## Modified by Martinski W. [2026-May-21] ## |
| 3209 | +##----------------------------------------## |
3203 | 3210 | _CheckForNewScriptUpdates_() |
3204 | 3211 | { |
3205 | 3212 | local verStr DLScriptVerPath="${SCRIPT_VERPATH}.DL.tmp" |
@@ -3254,13 +3261,19 @@ _CheckForNewScriptUpdates_() |
3254 | 3261 | scriptUpdateNotify="New script update available. |
3255 | 3262 | ${REDct}v${SCRIPT_VERSION}${NOct} --> ${GRNct}v${DLRepoVersion}${NOct}" |
3256 | 3263 | _WriteVarDefToHelperJSFile_ "isScriptUpdateAvailable" "$DLRepoVersion" |
| 3264 | + |
3257 | 3265 | if [ $# -gt 0 ] && [ "$1" = "-quietcheck" ] |
3258 | 3266 | then return 0 |
3259 | 3267 | fi |
3260 | 3268 | Say "$myLAN_HostName - A new script version update (v$DLRepoVersion) is available to download." |
3261 | 3269 | if [ "$ScriptAutoUpdateSetting" = "ENABLED" ] |
3262 | 3270 | then |
3263 | | - _SCRIPT_UPDATE_ force |
| 3271 | + if "$isInteractive" && { [ $# -eq 0 ] || [ -z "$1" ] ; } |
| 3272 | + then |
| 3273 | + _SCRIPT_UPDATE_ force |
| 3274 | + else |
| 3275 | + _SCRIPT_UPDATE_ force unattended |
| 3276 | + fi |
3264 | 3277 | fi |
3265 | 3278 | else |
3266 | 3279 | scriptUpdateNotify=0 |
@@ -4631,6 +4644,12 @@ _GetKeypressInput_() |
4631 | 4644 | local offlineUpdKeyFlag execReloadKeyFlag |
4632 | 4645 | local specialKeyCharCodes="12 16 18 24 25 27" |
4633 | 4646 |
|
| 4647 | + if [ "$isInteractive" = "false" ] |
| 4648 | + then |
| 4649 | + theUserInputStr="exit" |
| 4650 | + return 0 #Defensive Exit# |
| 4651 | + fi |
| 4652 | + |
4634 | 4653 | if [ -n "${offlineUpdTrigger:+xSETx}" ] |
4635 | 4654 | then |
4636 | 4655 | offlineUpdKeyFlag=true |
@@ -12085,7 +12104,8 @@ if [ $# -eq 0 ] || [ -z "$1" ] || \ |
12085 | 12104 | { [ $# -gt 1 ] && [ "$1" = "reload" ] ; } |
12086 | 12105 | then |
12087 | 12106 | if ! _AcquireLock_ cliMenuLock |
12088 | | - then Say "Exiting..." ; exit 1 ; fi |
| 12107 | + then Say "Exiting..." ; exit 1 |
| 12108 | + fi |
12089 | 12109 |
|
12090 | 12110 | inMenuMode=true |
12091 | 12111 | _DoInitializationStartup_ |
@@ -12147,7 +12167,7 @@ then |
12147 | 12167 | checkupdates) |
12148 | 12168 | if _AcquireLock_ cliFileLock |
12149 | 12169 | then |
12150 | | - _CheckForNewScriptUpdates_ |
| 12170 | + _CheckForNewScriptUpdates_ unattended |
12151 | 12171 | _ReleaseLock_ cliFileLock |
12152 | 12172 | fi |
12153 | 12173 | ;; |
@@ -12234,8 +12254,8 @@ then |
12234 | 12254 | if _AcquireLock_ cliFileLock |
12235 | 12255 | then |
12236 | 12256 | if [ "$3" = "${SCRIPT_NAME}scrptupdate_force" ] |
12237 | | - then _SCRIPT_UPDATE_ force |
12238 | | - else _CheckForNewScriptUpdates_ |
| 12257 | + then _SCRIPT_UPDATE_ force unattended |
| 12258 | + else _CheckForNewScriptUpdates_ unattended |
12239 | 12259 | fi |
12240 | 12260 | _ReleaseLock_ cliFileLock |
12241 | 12261 | fi |
|
0 commit comments