44#
55# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7- # Last Modified: 2025-Jan-10
7+ # Last Modified: 2025-Feb-15
88# ##################################################################
99set -u
1010
@@ -56,18 +56,22 @@ MinSupportedFirmwareVers="3004.386.12.6"
5656routerModelCheckFailed=false
5757offlineUpdateTrigger=false
5858
59- # #-------------------------------------------- ##
60- # # Modified by ExtremeFiretop [2023-Nov-26] ##
61- # #-------------------------------------------- ##
59+ # #----------------------------------------##
60+ # # Modified by Martinski W. [2025-Feb-15] ##
61+ # #----------------------------------------##
6262readonly NOct=" \e[0m"
63+ readonly BOLDct=" \e[1m"
64+ readonly BLKct=" \e[1;30m"
6365readonly REDct=" \e[1;31m"
6466readonly GRNct=" \e[1;32m"
65- readonly BLKct=" \e[1;30m"
6667readonly YLWct=" \e[1;33m"
6768readonly BLUEct=" \e[1;34m"
6869readonly MAGENTAct=" \e[1;35m"
6970readonly CYANct=" \e[1;36m"
7071readonly WHITEct=" \e[1;37m"
72+ readonly CRITct=" \e[1;41m"
73+ readonly InvREDct=" \e[1;41m"
74+ readonly InvGRNct=" \e[1;42m"
7175
7276readonly ScriptFileName=" ${0##*/ } "
7377readonly ScriptFNameTag=" ${ScriptFileName%% .* } "
@@ -260,15 +264,16 @@ _UserLogMsg_()
260264}
261265
262266# #----------------------------------------##
263- # # Modified by Martinski W. [2023-Dec-21 ] ##
267+ # # Modified by Martinski W. [2025-Feb-15 ] ##
264268# #----------------------------------------##
265269Say ()
266270{
271+ local logMsg
267272 " $isInteractive " && printf " ${1} \n"
268- # Clean out the "color escape sequences" from the log file #
269- local logMsg=" $( echo " $1 " | sed ' s/\\\e\[0m //g ; s/\\\e\[[0-1];3 [0-9]m//g' ) "
273+ # Remove all "color escape sequences" from the system log file entries #
274+ logMsg=" $( echo " $1 " | sed ' s/\\\e\[[0-1]m //g ; s/\\\e\[[0-1];[3-4] [0-9]m//g' ) "
270275 _UserLogMsg_ " $logMsg "
271- printf " $logMsg " | logger -t " [$( basename " $0 " ) ] $$ "
276+ printf " $logMsg " | logger -t " [${SCRIPT_NAME} ] $$ "
272277}
273278
274279# #----------------------------------------------##
@@ -1522,16 +1527,18 @@ _CheckForNewGUIVersionUpdate_()
15221527}
15231528
15241529# #----------------------------------------##
1525- # # Modified by Martinski W. [2025-Jan-06 ] ##
1530+ # # Modified by Martinski W. [2025-Feb-15 ] ##
15261531# #----------------------------------------##
15271532_CurlFileDownload_ ()
15281533{
15291534 if [ $# -lt 2 ] || [ -z " $1 " ] || [ -z " $2 " ]
15301535 then return 1 ; fi
1531- local retCode tempFilePathDL=" ${2} .DL.TMP"
1536+ local retCode=1
1537+ local tempFilePathDL=" ${2} .DL.TMP"
1538+ local srceFilePathDL=" ${SCRIPT_URL_REPO} /$1 "
15321539
15331540 curl -LSs --retry 4 --retry-delay 5 --retry-connrefused \
1534- " $1 " -o " $tempFilePathDL "
1541+ " $srceFilePathDL " -o " $tempFilePathDL "
15351542 if [ $? -ne 0 ] || [ ! -s " $tempFilePathDL " ] || \
15361543 grep -iq " ^404: Not Found" " $tempFilePathDL "
15371544 then rm -f " $tempFilePathDL " ; retCode=1
@@ -1541,23 +1548,23 @@ _CurlFileDownload_()
15411548}
15421549
15431550# #----------------------------------------##
1544- # # Modified by Martinski W. [2025-Jan-06 ] ##
1551+ # # Modified by Martinski W. [2025-Feb-15 ] ##
15451552# #----------------------------------------##
15461553_SCRIPTUPDATE_ ()
15471554{
1548- local urlScriptVers theScriptVers extraParam=" "
1555+ local extraParam=" "
15491556
15501557 _DownloadScriptFiles_ ()
15511558 {
15521559 local retCode
1553- if _CurlFileDownload_ " ${SCRIPT_URL_REPO} / version.txt" " $SCRIPTVERPATH "
1560+ if _CurlFileDownload_ " version.txt" " $SCRIPTVERPATH "
15541561 then
15551562 retCode=0 ; chmod 664 " $SCRIPTVERPATH "
15561563 else
15571564 retCode=1
15581565 Say " ${REDct} **ERROR**${NOct} : Unable to download latest version file for $SCRIPT_NAME ."
15591566 fi
1560- if _CurlFileDownload_ " ${SCRIPT_URL_REPO} / ${ SCRIPT_NAME} .sh" " $ScriptFilePath "
1567+ if _CurlFileDownload_ " ${SCRIPT_NAME} .sh" " $ScriptFilePath "
15611568 then
15621569 retCode=0 ; chmod 755 " $ScriptFilePath "
15631570 else
@@ -1570,19 +1577,19 @@ _SCRIPTUPDATE_()
15701577 if [ $# -gt 0 ] && [ " $1 " = " force" ]
15711578 then
15721579 printf " \n${CYANct} Force downloading latest script version...${NOct} \n"
1573- theScriptVers=" $SCRIPT_VERSION "
1574- [ -s " $SCRIPTVERPATH " ] && theScriptVers=" $( cat " $SCRIPTVERPATH " ) "
1575- urlScriptVers=" $( /usr/sbin/curl -LSs --retry 4 --retry-delay 5 " ${SCRIPT_URL_REPO} /version.txt" ) "
1576- printf " ${CYANct} Downloading latest version ($urlScriptVers ) of ${SCRIPT_NAME}${NOct} \n"
1580+ if ! _CheckForNewScriptUpdates_ -quietcheck
1581+ then
1582+ DLRepoVersion=" $( /usr/sbin/curl -LSs --retry 4 --retry-delay 5 " ${SCRIPT_URL_REPO} /version.txt" ) "
1583+ fi
1584+ if _CheckForNewGUIVersionUpdate_ " $SCRIPT_VERSION " " $DLRepoVersion "
1585+ then extraParam=" install"
1586+ fi
1587+ printf " ${CYANct} Downloading latest version [$DLRepoVersion ] of ${SCRIPT_NAME}${NOct} \n"
15771588
15781589 if _DownloadScriptFiles_
15791590 then
15801591 printf " ${CYANct} $SCRIPT_NAME was successfully updated.${NOct} \n\n"
15811592 sleep 1
1582- [ -s " $SCRIPTVERPATH " ] && urlScriptVers=" $( cat " $SCRIPTVERPATH " ) "
1583- if [ $# -gt 1 ] && [ " $2 " = " newgui" ] && \
1584- _CheckForNewGUIVersionUpdate_ " $theScriptVers " " $urlScriptVers "
1585- then extraParam=" install" ; fi
15861593 _ReleaseLock_
15871594 exec " $ScriptFilePath " $extraParam
15881595 exit 0
@@ -1609,7 +1616,7 @@ _SCRIPTUPDATE_()
16091616 if _DownloadScriptFiles_
16101617 then
16111618 printf " \n${CYANct} Download successful!${NOct} \n"
1612- printf " $( date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion} \n"
1619+ printf " $( date) - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion} \n"
16131620 fi
16141621 _WaitForEnterKey_
16151622 return
@@ -1627,7 +1634,7 @@ _SCRIPTUPDATE_()
16271634
16281635 if _DownloadScriptFiles_
16291636 then
1630- printf " \n$( date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion} \n"
1637+ printf " \n$( date) - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion} \n"
16311638 printf " ${CYANct} Update successful! Restarting script...${NOct} \n"
16321639 sleep 1
16331640 _CheckForNewGUIVersionUpdate_ && extraParam=" install"
@@ -1647,18 +1654,16 @@ _SCRIPTUPDATE_()
16471654}
16481655
16491656# #----------------------------------------##
1650- # # Modified by Martinski W. [2025-Jan-01 ] ##
1657+ # # Modified by Martinski W. [2025-Feb-15 ] ##
16511658# #----------------------------------------##
16521659_CheckForNewScriptUpdates_ ()
16531660{
1654- local extraParam=" "
1655-
16561661 echo
16571662 DLRepoVersion=" $SCRIPT_VERSION "
16581663 [ -s " $SCRIPTVERPATH " ] && DLRepoVersion=" $( cat " $SCRIPTVERPATH " ) "
16591664 rm -f " $SCRIPTVERPATH "
16601665
1661- if ! _CurlFileDownload_ " ${SCRIPT_URL_REPO} / version.txt" " $SCRIPTVERPATH "
1666+ if ! _CurlFileDownload_ " version.txt" " $SCRIPTVERPATH "
16621667 then
16631668 Say " ${REDct} **ERROR**${NOct} : Unable to download latest version file for $SCRIPT_NAME ."
16641669 scriptUpdateNotify=0
@@ -1680,21 +1685,24 @@ _CheckForNewScriptUpdates_()
16801685 then
16811686 scriptUpdateNotify=" New script update available.
16821687${REDct} v${SCRIPT_VERSION}${NOct} --> ${GRNct} v${DLRepoVersion}${NOct} "
1688+
1689+ if [ $# -gt 0 ] && [ " $1 " = " -quietcheck" ]
1690+ then return 0
1691+ fi
16831692 Say " $myLAN_HostName - A new script version update (v$DLRepoVersion ) is available to download."
16841693 if [ " $ScriptAutoUpdateSetting " = " ENABLED" ]
16851694 then
1686- _CheckForNewGUIVersionUpdate_ && extraParam=" newgui"
1687- _SCRIPTUPDATE_ force $extraParam
1695+ _SCRIPTUPDATE_ force
16881696 fi
16891697 else
16901698 scriptUpdateNotify=0
16911699 fi
16921700 return 0
16931701}
16941702
1695- # #---------------------------------------------- ##
1696- # # Added/ Modified by Martinski W. [2023-Nov-22] ##
1697- # #---------------------------------------------- ##
1703+ # #----------------------------------------##
1704+ # # Modified by Martinski W. [2023-Nov-22] ##
1705+ # #----------------------------------------##
16981706_GetLatestFWUpdateVersionFromRouter_ ()
16991707{
17001708 local retCode=0 webState newVersionStr
@@ -6227,8 +6235,9 @@ _CheckTimeToUpdateFirmware_()
62276235 Say " The firmware update is expected to occur on ${GRNct}${nextCronTimeSecs}${NOct} ."
62286236 echo " "
62296237
6230- # Check if running in a menu environment #
6231- if " $isInteractive " && _WaitForYESorNO_ " Would you like to proceed with the update now?"
6238+ " $isInteractive " && \
6239+ printf " \n${BOLDct} Would you like to proceed with the update now${NOct} "
6240+ if _WaitForYESorNO_
62326241 then return 0
62336242 else return 1
62346243 fi
@@ -6819,9 +6828,9 @@ _RunBackupmon_()
68196828 return 0
68206829}
68216830
6822- # #------------------------------------------ ##
6823- # # Modified by ExtremeFiretop [2024-Oct-13 ] ##
6824- # #------------------------------------------ ##
6831+ # #----------------------------------------##
6832+ # # Modified by Martinski W. [2025-Feb-15 ] ##
6833+ # #----------------------------------------##
68256834_RunOfflineUpdateNow_ ()
68266835{
68276836 local retCode
@@ -6941,7 +6950,7 @@ _RunOfflineUpdateNow_()
69416950 _RunFirmwareUpdateNow_
69426951 _ClearOfflineUpdateState_
69436952 else
6944- Say " ${REDct} **ERROR**${NOct} : No firmware release URL was found for [$PRODUCT_ID ] router model."
6953+ Say " ${REDct} **ERROR**${NOct} : No firmware release URL was found for [$MODEL_ID ] router model."
69456954 _ClearOfflineUpdateState_ 1
69466955 return 1
69476956 fi
@@ -6955,9 +6964,9 @@ _RunOfflineUpdateNow_()
69556964 fi
69566965}
69576966
6958- # #------------------------------------------ ##
6959- # # Modified by ExtremeFiretop [2024-Jul-31 ] ##
6960- # #------------------------------------------ ##
6967+ # #----------------------------------------##
6968+ # # Modified by Martinski W. [2025-Feb-15 ] ##
6969+ # #----------------------------------------##
69616970_RunFirmwareUpdateNow_ ()
69626971{
69636972 # Double-check the directory exists before using it #
@@ -7077,7 +7086,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or
70777086 if ! release_version=" $( _GetLatestFWUpdateVersionFromRouter_) " || \
70787087 ! _CheckNewUpdateFirmwareNotification_ " $current_version " " $release_version "
70797088 then
7080- Say " No new firmware version update is found for [$PRODUCT_ID ] router model."
7089+ Say " No new firmware version update is found for [$MODEL_ID ] router model."
70817090 " $inMenuMode " && _WaitForEnterKey_ " $mainMenuReturnPromptStr "
70827091 return 1
70837092 fi
@@ -7102,7 +7111,7 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or
71027111 release_version=" $1 "
71037112 release_link=" $2 "
71047113 else
7105- Say " ${REDct} **ERROR**${NOct} : No firmware release URL was found for [$PRODUCT_ID ] router model."
7114+ Say " ${REDct} **ERROR**${NOct} : No firmware release URL was found for [$MODEL_ID ] router model."
71067115 " $inMenuMode " && _WaitForEnterKey_ " $mainMenuReturnPromptStr "
71077116 return 1
71087117 fi
@@ -8058,7 +8067,7 @@ check_version_support
80588067_CheckEMailConfigFileFromAMTM_ 0
80598068
80608069# #----------------------------------------##
8061- # # Modified by Martinski W. [2024-Dec-31 ] ##
8070+ # # Modified by Martinski W. [2025-Feb-15 ] ##
80628071# #----------------------------------------##
80638072if [ $# -gt 0 ] && [ -n " $1 " ]
80648073then
@@ -8082,7 +8091,7 @@ then
80828091 ;;
80838092 checkupdates) _CheckForNewScriptUpdates_
80848093 ;;
8085- forceupdate) _SCRIPTUPDATE_ force " $( [ $# -gt 1 ] && echo " $2 " || echo ) "
8094+ forceupdate) _SCRIPTUPDATE_ force
80868095 ;;
80878096 develop) _ChangeToDev_
80888097 ;;
@@ -8471,7 +8480,7 @@ _InvalidMenuSelection_()
84718480}
84728481
84738482# #----------------------------------------##
8474- # # Modified by Martinski W. [2024-Jul-03 ] ##
8483+ # # Modified by Martinski W. [2025-Feb-15 ] ##
84758484# #----------------------------------------##
84768485_ShowMainMenu_ ()
84778486{
@@ -8490,29 +8499,34 @@ _ShowMainMenu_()
84908499 printf " ${YLWct} ============ By ExtremeFiretop & Martinski W. ============${NOct} \n\n"
84918500
84928501 # New Script Update Notification #
8493- if [ " $scriptUpdateNotify " != " 0" ]; then
8494- Say " ${REDct} *WARNING*:${NOct} ${scriptUpdateNotify} \n"
8502+ if [ " $scriptUpdateNotify " != " 0" ]
8503+ then
8504+ Say " ${InvREDct} *NOTICE*:${NOct} ${scriptUpdateNotify} "
8505+ echo
84958506 fi
84968507
84978508 # Unsupported Model Check #
84988509 if " $routerModelCheckFailed "
84998510 then
85008511 Say " ${REDct} *WARNING*:${NOct} The current router model is not supported by this script.
8501- Please uninstall.\n"
8512+ Please uninstall."
8513+ echo
85028514 fi
85038515 if " $MinFirmwareVerCheckFailed "
85048516 then
85058517 Say " ${REDct} *WARNING*:${NOct} The current firmware version is below the minimum supported.
8506- Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or higher to use this script.\n"
8518+ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or higher to use this script."
8519+ echo
85078520 fi
85088521
85098522 if ! _HasRouterMoreThan256MBtotalRAM_ && ! _ValidateUSBMountPoint_ " $FW_ZIP_BASE_DIR "
85108523 then
85118524 Say " ${REDct} *WARNING*:${NOct} Limited RAM detected (256MB).
8512- A USB drive is required for F/W updates.\n"
8525+ A USB drive is required for F/W updates."
8526+ echo
85138527 fi
85148528
8515- arrowStr=" ${REDct} <<--- ${NOct} "
8529+ arrowStr=" ${InvREDct} <<<< ${NOct} "
85168530
85178531 _Calculate_NextRunTime_
85188532
@@ -8531,14 +8545,14 @@ _ShowMainMenu_()
85318545 if [ " $HIDE_ROUTER_SECTION " = " false" ]
85328546 then
85338547 if ! FW_NewUpdateVerStr=" $( _GetLatestFWUpdateVersionFromRouter_ 1) "
8534- then FW_NewUpdateVerStr=" ${REDct} NONE FOUND${NOct} "
8535- else FW_NewUpdateVerStr=" ${GRNct} ${FW_NewUpdateVerStr}${NOct} $arrowStr "
8548+ then FW_NewUpdateVerStr=" ${REDct} NONE FOUND${NOct} "
8549+ else FW_NewUpdateVerStr=" ${InvGRNct} ${FW_NewUpdateVerStr} ${NOct} $arrowStr "
85368550 fi
85378551 printf " \n Router's Product Name/Model ID: ${FW_RouterModelID}${padStr} (H)ide"
85388552 printf " \n USB-Attached Storage Connected: $USBConnected "
85398553 printf " \n F/W Variant Configuration Found: $FirmwareFlavor "
85408554 printf " \n F/W Version Currently Installed: $FW_InstalledVerStr "
8541- printf " \n F/W Update Version Available: $FW_NewUpdateVerStr "
8555+ printf " \n F/W Update Version Available: $FW_NewUpdateVerStr "
85428556 printf " \n F/W Update Estimated Run Date: $ExpectedFWUpdateRuntime "
85438557 else
85448558 printf " \n Router's Product Name/Model ID: ${FW_RouterModelID}${padStr} (S)how"
@@ -8553,11 +8567,11 @@ _ShowMainMenu_()
85538567 [ -z " $FW_UpdateCheckState " ] && FW_UpdateCheckState=0
85548568 if [ " $FW_UpdateCheckState " -eq 0 ]
85558569 then
8556- printf " \n ${GRNct} 3${NOct} . Toggle F/W Update Check "
8557- printf " \n${padStr} [Currently ${REDct} DISABLED${NOct} ]"
8570+ printf " \n ${GRNct} 3${NOct} . Toggle Automatic F/W Update Checks "
8571+ printf " \n${padStr} [Currently ${InvREDct} DISABLED ${NOct} ]"
85588572 else
8559- printf " \n ${GRNct} 3${NOct} . Toggle F/W Update Check "
8560- printf " \n${padStr} [Currently ${GRNct} ENABLED${NOct} ]"
8573+ printf " \n ${GRNct} 3${NOct} . Toggle Automatic F/W Update Checks "
8574+ printf " \n${padStr} [Currently ${InvGRNct} ENABLED ${NOct} ]"
85618575 fi
85628576 printf " \n${padStr} [Last Notification Date: $notificationStr ]\n"
85638577
@@ -8589,7 +8603,7 @@ _ShowMainMenu_()
85898603 if [ " $scriptUpdateNotify " != " 0" ]
85908604 then
85918605 printf " \n ${GRNct} up${NOct} . Update $SCRIPT_NAME Script"
8592- printf " \n${padStr} [Version ${GRNct} ${DLRepoVersion}${NOct} Available for Download]\n"
8606+ printf " \n${padStr} [Version ${InvGRNct} ${DLRepoVersion} ${NOct} Available for Download]\n"
85938607 else
85948608 printf " \n ${GRNct} up${NOct} . Force Update $SCRIPT_NAME Script"
85958609 printf " \n${padStr} [No Update Available]\n"
0 commit comments