From 51bc8c04057fd76fbc704c83ca031d178b058c2f Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Mon, 20 May 2024 00:11:39 -0700 Subject: [PATCH 01/14] Modified top section/header of the Main Menu. The top section/header of the Main Menu was modified to allow for a bit longer/better description of the listed items. --- MerlinAU.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 3a79d265..daaf39a7 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,11 +4,11 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2024-May-18 +# Last Modified: 2024-May-19 ################################################################### set -u -readonly SCRIPT_VERSION=1.1.3 +readonly SCRIPT_VERSION=1.1.4 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -4874,6 +4874,7 @@ theExitStr="${GRNct}e${NOct}=Exit to Main Menu" theADExitStr="${GRNct}e${NOct}=Exit to Advanced Menu" padStr=" " SEPstr="-----------------------------------------------------" +SEPtop="----------------------------------------------------------" FW_RouterProductID="${GRNct}${PRODUCT_ID}${NOct}" if [ "$PRODUCT_ID" = "$MODEL_ID" ] @@ -5188,7 +5189,7 @@ _ShowMainMenu_() clear logo - printf "${YLWct}========= By ExtremeFiretop & Martinski W. ==========${NOct}\n\n" + printf "${YLWct}============ By ExtremeFiretop & Martinski W. ============${NOct}\n\n" # New Script Update Notification # if [ "$UpdateNotify" != "0" ]; then @@ -5220,26 +5221,25 @@ _ShowMainMenu_() else notificationStr="${GRNct}$(_SimpleNotificationDate_ "$notifyDate")${NOct}" fi - ##------------------------------------------## - ## Modified by ExtremeFiretop [2024-Mar-27] ## - ##------------------------------------------## - printf "${SEPstr}" + ##----------------------------------------## + ## Modified by Martinski W. [2024-May-19] ## + ##----------------------------------------## + printf "${SEPtop}" if [ "$HIDE_ROUTER_SECTION" = "false" ] then if ! FW_NewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" then FW_NewUpdateVersion="${REDct}NONE FOUND${NOct}" else FW_NewUpdateVersion="${GRNct}${FW_NewUpdateVersion}${NOct}$arrowStr" fi - printf "\n${padStr}F/W Product/Model ID: $FW_RouterModelID ${padStr}(H)ide" - printf "\n${padStr}USB Storage Connected: $USBConnected" - printf "\n${padStr}F/W Version Installed: $FW_InstalledVersion" - printf "\n${padStr}F/W Update Available: $FW_NewUpdateVersion" - printf "\n${padStr}F/W Upd Expected ETA: $ExpectedFWUpdateRuntime" + printf "\n Router's Product Name/Model ID: $FW_RouterModelID ${padStr}(H)ide" + printf "\n USB-Attached Storage Connected: $USBConnected" + printf "\n F/W Version Currently Installed: $FW_InstalledVersion" + printf "\n F/W Update Currently Available: $FW_NewUpdateVersion" + printf "\n F/W Update Run Estimated Date: $ExpectedFWUpdateRuntime" else - printf "\n${padStr}F/W Product/Model ID: $FW_RouterModelID ${padStr}(S)how" + printf "\n Router's Product Name/Model ID: $FW_RouterModelID ${padStr}(S)how" fi - - printf "\n${SEPstr}" + printf "\n${SEPtop}" printf "\n ${GRNct}1${NOct}. Run F/W Update Check Now\n" printf "\n ${GRNct}2${NOct}. Set Router Login Credentials\n" @@ -5282,7 +5282,7 @@ _ShowMainMenu_() printf "\n ${GRNct}un${NOct}. Uninstall\n" printf "\n ${GRNct}e${NOct}. Exit\n" - printf "${SEPstr}\n" + printf "${SEPtop}\n" } ##------------------------------------------## From c4a48b918f1495a2918b2228b6b0245c03e5803a Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 02:07:03 -0400 Subject: [PATCH 02/14] Update MerlinAU.sh --- MerlinAU.sh | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index daaf39a7..367abcfd 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: 2024-May-19 +# Last Modified: 2024-May-21 ################################################################### set -u @@ -496,17 +496,18 @@ readonly FW_FileName="${PRODUCT_ID}_firmware" readonly FW_URL_RELEASE="${FW_URL_BASE}/${PRODUCT_ID}/${FW_URL_RELEASE_SUFFIX}/" ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Feb-01] ## +## Modified by ExtremeFiretop [2024-May-21] ## ##------------------------------------------## logo() { echo -e "${YLWct}" - echo -e " __ __ _ _ _ _ " - echo -e " | \/ | | (_) /\ | | | |" - echo -e " | \ / | ___ _ __| |_ _ __ / \ | | | |" - echo -e " | |\/| |/ _ | '__| | | '_ \ / /\ \| | | |" - echo -e " | | | | __| | | | | | | |/ ____ | |__| |" - echo -e " |_| |_|\___|_| |_|_|_| |_/_/ \_\____/ ${GRNct}v${SCRIPT_VERSION}" + echo -e " __ __ _ _ _ _ " + echo -e " | \/ | | (_) /\ | | | |" + echo -e " | \ / | ___ _ __| |_ _ __ / \ | | | |" + echo -e " | |\/| |/ _ | '__| | | '_ \ / /\ \| | | |" + echo -e " | | | | __| | | | | | | |/ ____ | |__| |" + echo -e " |_| |_|\___|_| |_|_|_| |_/_/ \_\____/ ${GRNct}v${SCRIPT_VERSION}" echo -e " ${NOct}" + printf "${YLWct}============ By ExtremeFiretop & Martinski W. ============${NOct}\n\n" } ##-----------------------------------------------## @@ -2626,12 +2627,12 @@ change_build_type() doReturnToMenu=false while true do - printf "\n${SEPstr}" + printf "\n${SEPtop}" printf "\nChoose your preferred option for the build type to flash:\n" printf "\n ${GRNct}1${NOct}. Original ${REDct}ROG${NOct} themed user interface${NOct}\n" printf "\n ${GRNct}2${NOct}. Pure ${GRNct}non-ROG${NOct} themed user interface ${GRNct}(Recommended)${NOct}\n" printf "\n ${GRNct}e${NOct}. Exit to Advanced Menu\n" - printf "${SEPstr}\n" + printf "${SEPtop}\n" printf "[$display_choice] Enter selection: " read -r choice @@ -4532,12 +4533,12 @@ _SetEMailFormatType_() doReturnToMenu=false while true do - printf "\n${SEPstr}" + printf "\n${SEPtop}" printf "\nChoose the format type for email notifications:\n" printf "\n ${GRNct}1${NOct}. HTML\n" printf "\n ${GRNct}2${NOct}. Plain Text\n" printf "\n ${GRNct}e${NOct}. Exit to Advanced Menu\n" - printf "${SEPstr}\n" + printf "${SEPtop}\n" printf "[$currFormatStr] Enter selection: " read -r userInput @@ -4873,7 +4874,6 @@ fi theExitStr="${GRNct}e${NOct}=Exit to Main Menu" theADExitStr="${GRNct}e${NOct}=Exit to Advanced Menu" padStr=" " -SEPstr="-----------------------------------------------------" SEPtop="----------------------------------------------------------" FW_RouterProductID="${GRNct}${PRODUCT_ID}${NOct}" @@ -5231,13 +5231,13 @@ _ShowMainMenu_() then FW_NewUpdateVersion="${REDct}NONE FOUND${NOct}" else FW_NewUpdateVersion="${GRNct}${FW_NewUpdateVersion}${NOct}$arrowStr" fi - printf "\n Router's Product Name/Model ID: $FW_RouterModelID ${padStr}(H)ide" + printf "\n Router's Product Name/Model ID: $FW_RouterModelID${padStr}(H)ide" printf "\n USB-Attached Storage Connected: $USBConnected" printf "\n F/W Version Currently Installed: $FW_InstalledVersion" - printf "\n F/W Update Currently Available: $FW_NewUpdateVersion" - printf "\n F/W Update Run Estimated Date: $ExpectedFWUpdateRuntime" + printf "\n F/W Update Version Available: $FW_NewUpdateVersion" + printf "\n F/W Update Estimate Run Date: $ExpectedFWUpdateRuntime" else - printf "\n Router's Product Name/Model ID: $FW_RouterModelID ${padStr}(S)how" + printf "\n Router's Product Name/Model ID: $FW_RouterModelID${padStr}(S)how" fi printf "\n${SEPtop}" @@ -5292,8 +5292,8 @@ _ShowAdvancedOptionsMenu_() { clear logo - printf "=============== Advanced Options Menu ===============\n" - printf "${SEPstr}\n" + printf "================== Advanced Options Menu =================\n" + printf "${SEPtop}\n" printf "\n ${GRNct}1${NOct}. Set Directory for F/W Update ZIP File" printf "\n${padStr}[Current Path: ${GRNct}${FW_ZIP_DIR}${NOct}]\n" @@ -5387,7 +5387,7 @@ _ShowAdvancedOptionsMenu_() fi printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" - printf "${SEPstr}" + printf "${SEPtop}" } ##---------------------------------------## @@ -5397,8 +5397,8 @@ _ShowNodesMenu_() { clear logo - printf "============== AiMesh Node(s) Info Menu ==============\n" - printf "${SEPstr}\n" + printf "================= AiMesh Node(s) Info Menu ================\n" + printf "${SEPtop}\n" if ! node_online_status="$(_NodeActiveStatus_)" then node_online_status="" ; fi @@ -5414,7 +5414,7 @@ _ShowNodesMenu_() echo "" printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" - printf "${SEPstr}" + printf "${SEPtop}" } _ShowNodesMenuOptions_() @@ -5484,8 +5484,8 @@ _ShowLogsMenu_() { clear logo - printf "===================== Logs Menu =====================\n" - printf "${SEPstr}\n" + printf "======================== Logs Menu =======================\n" + printf "${SEPtop}\n" printf "\n ${GRNct}1${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" @@ -5498,7 +5498,7 @@ _ShowLogsMenu_() printf "\n ${GRNct}cl${NOct}. View latest F/W Changelog\n" printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" - printf "${SEPstr}" + printf "${SEPtop}" } ##----------------------------------------## From a1b91624898e82f7c26b8c2cc61013b428f5155f Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 02:13:03 -0400 Subject: [PATCH 03/14] Update MerlinAU.sh --- MerlinAU.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 367abcfd..5792a242 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -5189,7 +5189,6 @@ _ShowMainMenu_() clear logo - printf "${YLWct}============ By ExtremeFiretop & Martinski W. ============${NOct}\n\n" # New Script Update Notification # if [ "$UpdateNotify" != "0" ]; then From 19fd2221f0876aa2f0b4e7e3cf9fa1a138ae5fab Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 11:42:34 -0400 Subject: [PATCH 04/14] Update MerlinAU.sh --- MerlinAU.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 5792a242..50680008 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1287,11 +1287,19 @@ _CreateEMailContent_() ;; STOP_FW_UPDATE_APPROVAL) emailBodyTitle="WARNING" + high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended" + if $isEMailFormatHTML; then + # Highlight high-risk terms using HTML with a yellow background + highlighted_changelog_contents=$(echo "$changelog_contents" | sed -E "s/($high_risk_terms)/\1<\/span>/gi") + else + # Highlight high-risk terms in plain text using asterisks + highlighted_changelog_contents=$(echo "$changelog_contents" | sed -E "s/($high_risk_terms)/*\1*/gi") + fi { - echo "Found high-risk phrases in the change-logs while Auto-Updating to version ${fwNewUpdateVersion} on the ${MODEL_ID} router." - echo "Changelog contents include the following changes:" - echo "$changelog_contents" - printf "\nPlease run script interactively to approve this F/W Update from current version:\n${fwInstalledVersion}\n" + echo "Found high-risk phrases in the change-logs while Auto-Updating to version ${fwNewUpdateVersion} on the ${MODEL_ID} router." + echo "Changelog contents include the following changes:" + echo "$highlighted_changelog_contents" + printf "\nPlease run script interactively to approve this F/W Update from current version:\n${fwInstalledVersion}\n" } > "$tempEMailBodyMsg" ;; NEW_BM_BACKUP_FAILED) @@ -1692,7 +1700,7 @@ _GetCurrentFWInstalledLongVersion_() _GetCurrentFWInstalledShortVersion_() { ##FOR TESTING/DEBUG ONLY## -if false ; then echo "388.6.2" ; return 0 ; fi +if true ; then echo "388.6.2" ; return 0 ; fi ##FOR TESTING/DEBUG ONLY## local theVersionStr extVersNum @@ -3937,11 +3945,11 @@ Please manually update to version $minimum_supported_version or higher to use th fi # Convert version strings to comparable numbers - current_version="$(_ScriptVersionStrToNum_ "$BM_VERSION")" - required_version="$(_ScriptVersionStrToNum_ "1.5.3")" + local currentBM_version="$(_ScriptVersionStrToNum_ "$BM_VERSION")" + local requiredBM_version="$(_ScriptVersionStrToNum_ "1.5.3")" # Check if BACKUPMON version is greater than or equal to 1.5.3 - if [ "$current_version" -ge "$required_version" ]; then + if [ "$currentBM_version" -ge "$requiredBM_version" ]; then # Execute the backup script if it exists # echo "" Say "Backup Started (by BACKUPMON)" From 87ba2da4d8ca4dc57bcc0c203ec90cf71da8ff32 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 11:43:33 -0400 Subject: [PATCH 05/14] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 50680008..2df53c5b 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1700,7 +1700,7 @@ _GetCurrentFWInstalledLongVersion_() _GetCurrentFWInstalledShortVersion_() { ##FOR TESTING/DEBUG ONLY## -if true ; then echo "388.6.2" ; return 0 ; fi +if false ; then echo "388.6.2" ; return 0 ; fi ##FOR TESTING/DEBUG ONLY## local theVersionStr extVersNum From b05092be2f5c050f29d981c2383117845db14d7f Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 12:20:44 -0400 Subject: [PATCH 06/14] Update MerlinAU.sh --- MerlinAU.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 2df53c5b..96d06dd8 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4227,28 +4227,33 @@ Please manually update to version $minimum_supported_version or higher to use th fi ##------------------------------------------## - ## Modified by ExtremeFiretop [2024-Feb-03] ## + ## Modified by ExtremeFiretop [2024-May-21] ## ##------------------------------------------## - if [ -f "sha256sum.sha256" ] && [ -f "$firmware_file" ]; then + + # Fetch the latest checksums from ASUSWRT-Merlin website + checksums=$(curl -s https://www.asuswrt-merlin.net/download | sed -n '/
/,/
/p' | sed -e 's/<[^>]*>//g') + + if [ -f "$firmware_file" ]; then fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)" - dl_sig="$(grep "$firmware_file" sha256sum.sha256 | cut -d' ' -f1)" + # Extract the corresponding checksum for the firmware file from the fetched data + dl_sig="$(echo "$checksums" | grep "$(basename $firmware_file)" | cut -d' ' -f1)" if [ "$fw_sig" != "$dl_sig" ]; then - Say "${REDct}**ERROR**${NOct}: Extracted firmware does not match the SHA256 signature!" + Say "${REDct}**ERROR**${NOct}: Extracted firmware does not match the SHA256 signature from the website!" _DoCleanUp_ 1 _SendEMailNotification_ FAILED_FW_CHECKSUM_STATUS if [ "$inMenuMode" = true ]; then _WaitForEnterKey_ "$mainMenuReturnPromptStr" return 1 else - # Assume non-interactive mode; perform exit. - _DoExit_ 1 + # Assume non-interactive mode; perform exit. + _DoExit_ 1 fi fi else - Say "${REDct}**ERROR**${NOct}: SHA256 signature file not found!" + Say "${REDct}**ERROR**${NOct}: Firmware file not found!" _DoCleanUp_ 1 if [ "$inMenuMode" = true ]; then - _WaitForEnterKey_ "$mainMenuReturnPromptStr" + _WaitForEnterKey_ "$mainMenuReturnPromptStr" return 1 else # Assume non-interactive mode; perform exit. From 8fe74bf61b98d6cf38265096ebd673b1b9e877c5 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 12:22:39 -0400 Subject: [PATCH 07/14] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 96d06dd8..5855892b 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4253,7 +4253,7 @@ Please manually update to version $minimum_supported_version or higher to use th Say "${REDct}**ERROR**${NOct}: Firmware file not found!" _DoCleanUp_ 1 if [ "$inMenuMode" = true ]; then - _WaitForEnterKey_ "$mainMenuReturnPromptStr" + _WaitForEnterKey_ "$mainMenuReturnPromptStr" return 1 else # Assume non-interactive mode; perform exit. From e62f7fee73d19c1fe02a67261be8a4a8d46d08e7 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 13:05:19 -0400 Subject: [PATCH 08/14] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 5855892b..c0871ad9 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1700,7 +1700,7 @@ _GetCurrentFWInstalledLongVersion_() _GetCurrentFWInstalledShortVersion_() { ##FOR TESTING/DEBUG ONLY## -if false ; then echo "388.6.2" ; return 0 ; fi +if true ; then echo "388.6.2" ; return 0 ; fi ##FOR TESTING/DEBUG ONLY## local theVersionStr extVersNum @@ -4231,7 +4231,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##------------------------------------------## # Fetch the latest checksums from ASUSWRT-Merlin website - checksums=$(curl -s https://www.asuswrt-merlin.net/download | sed -n '/
/,/
/p' | sed -e 's/<[^>]*>//g') + checksums=$(curl --silent --connect-timeout 10 --retry 4 --max-time 12 https://www.asuswrt-merlin.net/download | sed -n '/
/,/
/p' | sed -e 's/<[^>]*>//g') if [ -f "$firmware_file" ]; then fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)" From b2fba2c180bf1e6f4ebff4f81fc293df2bdb73b4 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 21 May 2024 13:07:06 -0400 Subject: [PATCH 09/14] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index c0871ad9..2a709f27 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1700,7 +1700,7 @@ _GetCurrentFWInstalledLongVersion_() _GetCurrentFWInstalledShortVersion_() { ##FOR TESTING/DEBUG ONLY## -if true ; then echo "388.6.2" ; return 0 ; fi +if false ; then echo "388.6.2" ; return 0 ; fi ##FOR TESTING/DEBUG ONLY## local theVersionStr extVersNum From e49f95f4e4b4dee6d4aa06f9aefd70f0d8ae2dc2 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Thu, 23 May 2024 00:52:14 -0400 Subject: [PATCH 10/14] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 2a709f27..2b408fe9 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -507,7 +507,6 @@ logo() { echo -e " | | | | __| | | | | | | |/ ____ | |__| |" echo -e " |_| |_|\___|_| |_|_|_| |_/_/ \_\____/ ${GRNct}v${SCRIPT_VERSION}" echo -e " ${NOct}" - printf "${YLWct}============ By ExtremeFiretop & Martinski W. ============${NOct}\n\n" } ##-----------------------------------------------## @@ -5202,6 +5201,7 @@ _ShowMainMenu_() clear logo + printf "${YLWct}============ By ExtremeFiretop & Martinski W. ============${NOct}\n\n" # New Script Update Notification # if [ "$UpdateNotify" != "0" ]; then @@ -5247,7 +5247,7 @@ _ShowMainMenu_() printf "\n USB-Attached Storage Connected: $USBConnected" printf "\n F/W Version Currently Installed: $FW_InstalledVersion" printf "\n F/W Update Version Available: $FW_NewUpdateVersion" - printf "\n F/W Update Estimate Run Date: $ExpectedFWUpdateRuntime" + printf "\n F/W Update Estimated Run Date: $ExpectedFWUpdateRuntime" else printf "\n Router's Product Name/Model ID: $FW_RouterModelID${padStr}(S)how" fi From 986ec0b6ef04f42b869b99b69b044ea38c9b6138 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 23 May 2024 02:32:34 -0700 Subject: [PATCH 11/14] Minor code fixes & improvements. Various minor code fixes & improvements. --- MerlinAU.sh | 147 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 87 insertions(+), 60 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 2b408fe9..6c6194a2 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: 2024-May-21 +# Last Modified: 2024-May-23 ################################################################### set -u @@ -25,9 +25,10 @@ readonly FW_URL_RELEASE_SUFFIX="Release" ##---------------------------------------## ## Added by ExtremeFiretop [2024-May-03] ## ##---------------------------------------## -# Changelog URL Info # +# Changelog Info # readonly CL_URL_NG="${FW_URL_BASE}/Documentation/Changelog-NG.txt/download" readonly CL_URL_386="${FW_URL_BASE}/Documentation/Changelog-386.txt/download" +readonly high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended" # For new script version updates from source repository # UpdateNotify=0 @@ -98,8 +99,9 @@ then inRouterSWmode=true else inRouterSWmode=false fi -mainMenuReturnPromptStr="Press to return to the Main Menu..." -advnMenuReturnPromptStr="Press to return to the Advanced Menu..." +readonly mainMenuReturnPromptStr="Press to return to the Main Menu..." +readonly advnMenuReturnPromptStr="Press to return to the Advanced Menu..." +readonly logsMenuReturnPromptStr="Press to return to the Logs Menu..." [ -t 0 ] && ! tty | grep -qwi "NOT" && isInteractive=true @@ -201,10 +203,10 @@ _AcquireLock_() then Say "Stale lock found (older than $LockFileMaxSecs secs.) Reset lock file." oldPID="$(cat "$LockFilePath")" - if [ -n "$oldPID" ] && kill -EXIT $oldPID 2>/dev/null && \ - echo "$(pidof "$ScriptFileName")" | grep -qow "$oldPID" + if [ -n "$oldPID" ] && kill -EXIT "$oldPID" 2>/dev/null && \ + pidof "$ScriptFileName" | grep -qow "$oldPID" then - kill -TERM $oldPID ; wait $oldPID + kill -TERM "$oldPID" ; wait "$oldPID" fi rm -f "$LockFilePath" echo "$$" > "$LockFilePath" @@ -506,7 +508,7 @@ logo() { echo -e " | |\/| |/ _ | '__| | | '_ \ / /\ \| | | |" echo -e " | | | | __| | | | | | | |/ ____ | |__| |" echo -e " |_| |_|\___|_| |_|_|_| |_/_/ \_\____/ ${GRNct}v${SCRIPT_VERSION}" - echo -e " ${NOct}" + echo -e "${NOct}" } ##-----------------------------------------------## @@ -1286,12 +1288,12 @@ _CreateEMailContent_() ;; STOP_FW_UPDATE_APPROVAL) emailBodyTitle="WARNING" - high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended" - if $isEMailFormatHTML; then - # Highlight high-risk terms using HTML with a yellow background + if $isEMailFormatHTML + then + # Highlight high-risk terms using HTML with a yellow background # highlighted_changelog_contents=$(echo "$changelog_contents" | sed -E "s/($high_risk_terms)/\1<\/span>/gi") else - # Highlight high-risk terms in plain text using asterisks + # Highlight high-risk terms in plain text using asterisks # highlighted_changelog_contents=$(echo "$changelog_contents" | sed -E "s/($high_risk_terms)/*\1*/gi") fi { @@ -2052,15 +2054,15 @@ _TestLoginCredentials_() } ##----------------------------------------## -## Modified by Martinski W. [2024-Apr-15] ## +## Modified by Martinski W. [2024-May-23] ## ##----------------------------------------## _GetPasswordInput_() { local PSWDstrLenMIN=1 PSWDstrLenMAX=64 local PSWDstring PSWDtmpStr PSWDprompt local retCode charNum pswdLength showPSWD - # Added for TAB keypress debounce # - local lastTabTime=0 currentTime + # For more responsive TAB keypress debounce # + local tabKeyDebounceSem="/tmp/var/tmp/${ScriptFNameTag}_TabKeySEM.txt" if [ $# -eq 0 ] || [ -z "$1" ] then @@ -2078,6 +2080,13 @@ _GetPasswordInput_() stty "$savedSettings" } + _TabKeyDebounceWait_() + { + touch "$tabKeyDebounceSem" + usleep 300000 #0.3 sec# + rm -f "$tabKeyDebounceSem" + } + _ShowAsterisks_() { if [ $# -eq 0 ] || [ "$1" -eq 0 ] @@ -2137,12 +2146,11 @@ _GetPasswordInput_() ## TAB keypress as toggle with debounce ## if [ "$charNum" -eq 9 ] then - currentTime="$(date +%s)" - if [ "$((currentTime - lastTabTime))" -gt 0 ] + if [ ! -f "$tabKeyDebounceSem" ] then showPSWD="$((! showPSWD))" - lastTabTime="$currentTime" # Update TAB keypress time # _ShowPSWDPrompt_ + _TabKeyDebounceWait_ & fi continue fi @@ -2634,12 +2642,12 @@ change_build_type() doReturnToMenu=false while true do - printf "\n${SEPtop}" + printf "\n${SEPstr}" printf "\nChoose your preferred option for the build type to flash:\n" printf "\n ${GRNct}1${NOct}. Original ${REDct}ROG${NOct} themed user interface${NOct}\n" printf "\n ${GRNct}2${NOct}. Pure ${GRNct}non-ROG${NOct} themed user interface ${GRNct}(Recommended)${NOct}\n" printf "\n ${GRNct}e${NOct}. Exit to Advanced Menu\n" - printf "${SEPtop}\n" + printf "${SEPstr}\n" printf "[$display_choice] Enter selection: " read -r choice @@ -3640,7 +3648,7 @@ _Toggle_FW_UpdateEmailNotifications_() if ! _WaitForYESorNO_ "Do you want to ${emailNotificationNewStateStr} F/W Update email notifications?" then - _RunEMailNotificationTest_ && _WaitForEnterKey_ "$mainMenuReturnPromptStr" + _RunEMailNotificationTest_ && _WaitForEnterKey_ "$advnMenuReturnPromptStr" return 1 fi @@ -3657,7 +3665,7 @@ _Toggle_FW_UpdateEmailNotifications_() printf "F/W Update email notifications are now ${emailNotificationNewStateStr}.\n" _RunEMailNotificationTest_ - _WaitForEnterKey_ "$mainMenuReturnPromptStr" + _WaitForEnterKey_ "$advnMenuReturnPromptStr" } ##------------------------------------------## @@ -4143,26 +4151,26 @@ Please manually update to version $minimum_supported_version or higher to use th release_version_regex="$formatted_release_version \([0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\)" current_version_regex="$formatted_current_version \([0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\)" - # Check if the current version is present in the changelog + # Check if the current version is present in the changelog # if ! grep -Eq "$current_version_regex" "$changeLogFile"; then Say "Current version not found in change-log. Bypassing change-log verification for this run." else - # Extract log contents between two firmware versions + # Extract log contents between two firmware versions # changelog_contents="$(awk "/$release_version_regex/,/$current_version_regex/" "$changeLogFile")" - # Define high-risk terms as a single string separated by '|' - high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended" - # Search for high-risk terms in the extracted log contents - if echo "$changelog_contents" | grep -Eiq "$high_risk_terms"; then - if [ "$inMenuMode" = true ]; then - printf "\n ${REDct}Warning: Found high-risk phrases in the change-log.${NOct}" + # Search for high-risk terms in the extracted log contents # + if echo "$changelog_contents" | grep -Eiq "$high_risk_terms" + then + if [ "$inMenuMode" = true ] + then + printf "\n ${REDct}*WARNING*: Found high-risk phrases in the change-log.${NOct}" printf "\n ${REDct}Would you like to continue anyways?${NOct}" if ! _WaitForYESorNO_ ; then Say "Exiting for change-log review." _DoCleanUp_ 1 ; return 1 fi else - Say "Warning: Found high-risk phrases in the change-log." + Say "*WARNING*: Found high-risk phrases in the change-log." Say "Please run script interactively to approve the upgrade." _SendEMailNotification_ STOP_FW_UPDATE_APPROVAL _DoCleanUp_ 1 @@ -4225,22 +4233,38 @@ Please manually update to version $minimum_supported_version or higher to use th firmware_file="$pure_file" fi - ##------------------------------------------## - ## Modified by ExtremeFiretop [2024-May-21] ## - ##------------------------------------------## + ##----------------------------------------## + ## Modified by Martinski W. [2024-May-23] ## + ##----------------------------------------## + # Fetch the latest SHA256 checksums from ASUSWRT-Merlin website # + checksums="$(curl --silent --connect-timeout 10 --retry 4 --max-time 12 https://www.asuswrt-merlin.net/download | sed -n '/
/,/
/p' | sed -e 's/<[^>]*>//g')" - # Fetch the latest checksums from ASUSWRT-Merlin website - checksums=$(curl --silent --connect-timeout 10 --retry 4 --max-time 12 https://www.asuswrt-merlin.net/download | sed -n '/
/,/
/p' | sed -e 's/<[^>]*>//g') + if [ -z "$checksums" ] + then + Say "${REDct}**ERROR**${NOct}: Could not download the firmware SHA256 signatures from the website." + _DoCleanUp_ 1 + if [ "$inMenuMode" = true ] + then + _WaitForEnterKey_ "$mainMenuReturnPromptStr" + return 1 + else + # Assume non-interactive mode; perform exit. + _DoExit_ 1 + fi + fi - if [ -f "$firmware_file" ]; then + if [ -f "$firmware_file" ] + then fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)" - # Extract the corresponding checksum for the firmware file from the fetched data + # Extract the corresponding signature for the firmware file from the fetched checksums # dl_sig="$(echo "$checksums" | grep "$(basename $firmware_file)" | cut -d' ' -f1)" - if [ "$fw_sig" != "$dl_sig" ]; then - Say "${REDct}**ERROR**${NOct}: Extracted firmware does not match the SHA256 signature from the website!" + if [ "$fw_sig" != "$dl_sig" ] + then + Say "${REDct}**ERROR**${NOct}: SHA256 signature from extracted firmware file does not match the SHA256 signature from the website." _DoCleanUp_ 1 _SendEMailNotification_ FAILED_FW_CHECKSUM_STATUS - if [ "$inMenuMode" = true ]; then + if [ "$inMenuMode" = true ] + then _WaitForEnterKey_ "$mainMenuReturnPromptStr" return 1 else @@ -4249,9 +4273,10 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi else - Say "${REDct}**ERROR**${NOct}: Firmware file not found!" + Say "${REDct}**ERROR**${NOct}: Firmware image file NOT found!" _DoCleanUp_ 1 - if [ "$inMenuMode" = true ]; then + if [ "$inMenuMode" = true ] + then _WaitForEnterKey_ "$mainMenuReturnPromptStr" return 1 else @@ -4545,12 +4570,12 @@ _SetEMailFormatType_() doReturnToMenu=false while true do - printf "\n${SEPtop}" + printf "\n${SEPstr}" printf "\nChoose the format type for email notifications:\n" printf "\n ${GRNct}1${NOct}. HTML\n" printf "\n ${GRNct}2${NOct}. Plain Text\n" printf "\n ${GRNct}e${NOct}. Exit to Advanced Menu\n" - printf "${SEPtop}\n" + printf "${SEPstr}\n" printf "[$currFormatStr] Enter selection: " read -r userInput @@ -4885,8 +4910,10 @@ fi # menu setup variables # theExitStr="${GRNct}e${NOct}=Exit to Main Menu" theADExitStr="${GRNct}e${NOct}=Exit to Advanced Menu" +theLGExitStr="${GRNct}e${NOct}=Exit to Logs Menu" + padStr=" " -SEPtop="----------------------------------------------------------" +SEPstr="----------------------------------------------------------" FW_RouterProductID="${GRNct}${PRODUCT_ID}${NOct}" if [ "$PRODUCT_ID" = "$MODEL_ID" ] @@ -4930,10 +4957,10 @@ _GetFileSelectionIndex_() if [ $# -lt 2 ] || [ "$2" != "-MULTIOK" ] then multiIndexListOK=false - promptStr="Enter selection [${selectStr}] [${theExitStr}]?" + promptStr="Enter selection [${selectStr}] [${theLGExitStr}]?" else multiIndexListOK=true - promptStr="Enter selection [${selectStr} | ${theAllStr}] [${theExitStr}]?" + promptStr="Enter selection [${selectStr} | ${theAllStr}] [${theLGExitStr}]?" fi fileIndex=0 multiIndex=false numRegEx="([1-9]|[1-9][0-9])" @@ -5236,22 +5263,22 @@ _ShowMainMenu_() ##----------------------------------------## ## Modified by Martinski W. [2024-May-19] ## ##----------------------------------------## - printf "${SEPtop}" + printf "${SEPstr}" if [ "$HIDE_ROUTER_SECTION" = "false" ] then if ! FW_NewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" then FW_NewUpdateVersion="${REDct}NONE FOUND${NOct}" else FW_NewUpdateVersion="${GRNct}${FW_NewUpdateVersion}${NOct}$arrowStr" fi - printf "\n Router's Product Name/Model ID: $FW_RouterModelID${padStr}(H)ide" + printf "\n Router's Product Name/Model ID: ${FW_RouterModelID}${padStr}(H)ide" printf "\n USB-Attached Storage Connected: $USBConnected" printf "\n F/W Version Currently Installed: $FW_InstalledVersion" printf "\n F/W Update Version Available: $FW_NewUpdateVersion" printf "\n F/W Update Estimated Run Date: $ExpectedFWUpdateRuntime" else - printf "\n Router's Product Name/Model ID: $FW_RouterModelID${padStr}(S)how" + printf "\n Router's Product Name/Model ID: ${FW_RouterModelID}${padStr}(S)how" fi - printf "\n${SEPtop}" + printf "\n${SEPstr}" printf "\n ${GRNct}1${NOct}. Run F/W Update Check Now\n" printf "\n ${GRNct}2${NOct}. Set Router Login Credentials\n" @@ -5294,7 +5321,7 @@ _ShowMainMenu_() printf "\n ${GRNct}un${NOct}. Uninstall\n" printf "\n ${GRNct}e${NOct}. Exit\n" - printf "${SEPtop}\n" + printf "${SEPstr}\n" } ##------------------------------------------## @@ -5305,7 +5332,7 @@ _ShowAdvancedOptionsMenu_() clear logo printf "================== Advanced Options Menu =================\n" - printf "${SEPtop}\n" + printf "${SEPstr}\n" printf "\n ${GRNct}1${NOct}. Set Directory for F/W Update ZIP File" printf "\n${padStr}[Current Path: ${GRNct}${FW_ZIP_DIR}${NOct}]\n" @@ -5399,7 +5426,7 @@ _ShowAdvancedOptionsMenu_() fi printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" - printf "${SEPtop}" + printf "${SEPstr}" } ##---------------------------------------## @@ -5410,7 +5437,7 @@ _ShowNodesMenu_() clear logo printf "================= AiMesh Node(s) Info Menu ================\n" - printf "${SEPtop}\n" + printf "${SEPstr}\n" if ! node_online_status="$(_NodeActiveStatus_)" then node_online_status="" ; fi @@ -5426,7 +5453,7 @@ _ShowNodesMenu_() echo "" printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" - printf "${SEPtop}" + printf "${SEPstr}" } _ShowNodesMenuOptions_() @@ -5485,7 +5512,7 @@ _DownloadChangelogs_() less "$changeLogFile" fi rm -f "$changeLogFile" "$wgetLogFile" - "$inMenuMode" && _WaitForEnterKey_ "$mainMenuReturnPromptStr" + "$inMenuMode" && _WaitForEnterKey_ "$logsMenuReturnPromptStr" return 1 } @@ -5497,7 +5524,7 @@ _ShowLogsMenu_() clear logo printf "======================== Logs Menu =======================\n" - printf "${SEPtop}\n" + printf "${SEPstr}\n" printf "\n ${GRNct}1${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" @@ -5510,7 +5537,7 @@ _ShowLogsMenu_() printf "\n ${GRNct}cl${NOct}. View latest F/W Changelog\n" printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" - printf "${SEPtop}" + printf "${SEPstr}" } ##----------------------------------------## From 69655bb73def39dbae30d5e5a3f6e2f4522b06dc Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 24 May 2024 06:23:34 -0400 Subject: [PATCH 12/14] Update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 781dcb07..65087b4f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.3 +1.1.4 From fe809b027b4321a7425005bdeca107fc49588d57 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 24 May 2024 06:43:08 -0400 Subject: [PATCH 13/14] Update README.md --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a54178b6..ac6f9a0a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater -## v1.1.3 -## 2024-05-19 - -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/c45b637b-e6b7-4442-9872-bec1872fdf41) -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/f945d7c2-29b8-4c54-bc06-c8d5ce9e5b96) -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/df14f1f1-3b67-46fc-8a19-189886f3748e) -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/fcda5abe-5537-4474-96b5-adb0ca130ad6) +## v1.1.4 +## 2024-05-24 +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/0d34c5d0-f497-4c86-bac6-c80a7463f0cb) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/1cbd3938-ff53-45c8-82e8-ebdb21a4725a) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/3d877fab-3f70-4422-84ad-a4581cf094bc) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/81946a34-644f-4e3e-bc76-308a73c3e37c) ## TESTED MODELS (Multi-image models) - i.e. Any model that uses a .w or a .pkgtb file From 745904bd5e4a8ea856d25134b51b33c69a902491 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 24 May 2024 06:44:22 -0400 Subject: [PATCH 14/14] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac6f9a0a..8b772522 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ ## v1.1.4 ## 2024-05-24 -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/0d34c5d0-f497-4c86-bac6-c80a7463f0cb) -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/1cbd3938-ff53-45c8-82e8-ebdb21a4725a) -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/3d877fab-3f70-4422-84ad-a4581cf094bc) -![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/81946a34-644f-4e3e-bc76-308a73c3e37c) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/798a7a6a-7120-419c-b1eb-c6037bc8a4d5) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/5a670e26-d972-4980-bf1d-af4450705cfd) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/efc6e437-3f32-4de8-ad4a-86fd3a47ddc3) +![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/8d94554b-f1aa-45c8-9b1f-70fc4e4a277d) ## TESTED MODELS (Multi-image models) - i.e. Any model that uses a .w or a .pkgtb file