From 073589f5bbfcac3ece37d4da98db7b664fc18d6c Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:49:51 -0800 Subject: [PATCH 01/63] Update MerlinAU.sh Increase maximum number of days to postpone new F/W updates to 60, and set default to 15 days for new installs. This should give users more time in case they want to review/check change logs, or read SNB Forums posts related to the specific new F/W version where some users report problems or bugs which may affect their network setup. --- MerlinAU.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 216b9241..ff91bacf 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION="0.2.54" +readonly SCRIPT_VERSION="0.2.55" readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -391,10 +391,13 @@ readonly WHITEct="\e[1;37m" readonly FW_Update_CRON_DefaultSchedule="0 0 * * 0" +##------------------------------------------## +## Modified by Martinski W. [2024-Jan-22] ## +##------------------------------------------## # To postpone a firmware update for a few days # readonly FW_UpdateMinimumPostponementDays=0 -readonly FW_UpdateDefaultPostponementDays=7 -readonly FW_UpdateMaximumPostponementDays=30 +readonly FW_UpdateDefaultPostponementDays=15 +readonly FW_UpdateMaximumPostponementDays=60 readonly FW_UpdateNotificationDateFormat="%Y-%m-%d_12:00:00" readonly MODEL_ID="$(_GetRouterModelID_)" From dda9413089e2ed44de2267cb5bb4e3190211811c Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 13:46:00 -0500 Subject: [PATCH 02/63] Update MerlinAU.sh for Change-Log Check --- MerlinAU.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index ff91bacf..f4b4074d 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-Jan-22 +# Last Modified: 2024-Jan-23 ################################################################### set -u -readonly SCRIPT_VERSION="0.2.55" +readonly SCRIPT_VERSION="0.2.56" readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -1748,11 +1748,11 @@ _RunFirmwareUpdateNow_() printf "\nWould you like to uninstall the script now?" if _WaitForYESorNO_; then _DoUninstall_ - return 1 + return 0 else Say "Uninstallation cancelled. Exiting script." _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 + return 0 fi else Say "Exiting script due to unsupported router model." @@ -1790,7 +1790,7 @@ Please manually update to version $minimum_supported_version or higher to use th then Say "Expected directory path $FW_ZIP_BASE_DIR is NOT found." Say "Using temporary fallback directory: /home/root" - "$inMenuMode" && { _WaitForYESorNO_ "Continue" || return 1 ; } + "$inMenuMode" && { _WaitForYESorNO_ "Continue?" || return 1 ; } # Continue # FW_ZIP_BASE_DIR="/home/root" FW_ZIP_DIR="${FW_ZIP_BASE_DIR}/$FW_ZIP_SUBDIR" @@ -1810,7 +1810,7 @@ Please manually update to version $minimum_supported_version or higher to use th # Get current firmware version # current_version="$(_GetCurrentFWInstalledShortVersion_)" - ##FOR DEBUG ONLY##current_version="388.3.0" + ##FOR DEBUG ONLY##current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -1909,9 +1909,9 @@ Please manually update to version $minimum_supported_version or higher to use th return 1 fi - ##---------------------------------------## - ## Added by ExtremeFiretop [2024-Jan-22] ## - ##---------------------------------------## + ##------------------------------------------## + ## Modified by ExtremeFiretop [2024-Jan-22] ## + ##------------------------------------------## availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -1956,6 +1956,50 @@ Please manually update to version $minimum_supported_version or higher to use th # Navigate to the firmware directory cd "$FW_BIN_DIR" + + ##---------------------------------------## + ## Added by ExtremeFiretop [2024-Jan-23] ## + ##---------------------------------------## + # Define the path to the log file + changelog_file="${FW_BIN_DIR}/Changelog-NG.txt" + + # Check if the log file exists + if [ ! -f "$changelog_file" ]; then + Say "Change-log file does not exist at $changelog_file" + _DoCleanUp_ + return 1 + else + # Format current_version by removing the last '.0' + formatted_current_version=$(echo $current_version | awk -F. '{print $1"."$2}') + + # Format release_version by removing the prefix '3004.' and the last '.0' + formatted_release_version=$(echo $release_version | awk -F. '{print $2"."$3}') + + # Extract log contents between two firmware versions + changelog_contents=$(awk "/$formatted_release_version/,/$formatted_current_version/" "$changelog_file") + + # Define high-risk terms as a single string separated by '|' + high_risk_terms="factory default reset|dropped support|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-logs.${NOct}" + printf "\n ${REDct}Would you like to continue anyways?${NOct}" + if ! _WaitForYESorNO_ ; then + Say "Exiting for change-log review." + _DoCleanUp_ + return 1 + fi + else + Say "Warning: Found high-risk phrases in the change-logs." + Say "Please run script interactively to approve the flash." + _DoExit_ 1 + fi + else + Say "No high-risk phrases found in the change-logs." + fi + fi # Detect ROG and pure firmware files rog_file="$(ls | grep -i '_rog_')" @@ -2024,7 +2068,7 @@ Please manually update to version $minimum_supported_version or higher to use th printf "${GRNct}**IMPORTANT**:${NOct}\nThe firmware flash is about to start.\n" printf "Press Enter to stop now, or type ${GRNct}Y${NOct} to continue.\n" printf "Once started, the flashing process CANNOT be interrupted.\n" - if ! _WaitForYESorNO_ "Continue" + if ! _WaitForYESorNO_ "Continue?" then _DoCleanUp_ 1 "$keepZIPfile" ; return 1 ; fi fi From ad48d37ab5ba0958a9c3839dadd430fafcf84207 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 13:48:51 -0500 Subject: [PATCH 03/63] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index f4b4074d..5cbc3c23 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1985,7 +1985,7 @@ Please manually update to version $minimum_supported_version or higher to use th 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-logs.${NOct}" - printf "\n ${REDct}Would you like to continue anyways?${NOct}" + printf "\n ${REDct}Would you like to continue anyways?${NOct}" if ! _WaitForYESorNO_ ; then Say "Exiting for change-log review." _DoCleanUp_ @@ -1993,7 +1993,7 @@ Please manually update to version $minimum_supported_version or higher to use th fi else Say "Warning: Found high-risk phrases in the change-logs." - Say "Please run script interactively to approve the flash." + Say "Please run script interactively to approve the flash." _DoExit_ 1 fi else From dac60679716df9d6bc927fbf9d0fc6c2b0362fd0 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 13:53:22 -0500 Subject: [PATCH 04/63] Update MerlinAU.sh --- MerlinAU.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/MerlinAU.sh b/MerlinAU.sh index 5cbc3c23..41c7892b 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1967,6 +1967,7 @@ Please manually update to version $minimum_supported_version or higher to use th if [ ! -f "$changelog_file" ]; then Say "Change-log file does not exist at $changelog_file" _DoCleanUp_ + "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" return 1 else # Format current_version by removing the last '.0' From a1b11928a850f4636ca860b99e4705374e6c9ba7 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 18:55:12 -0500 Subject: [PATCH 05/63] Update MerlinAU.sh --- MerlinAU.sh | 88 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 41c7892b..cb15b3d0 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -759,7 +759,7 @@ _Set_FW_UpdateLOG_DirectoryPath_() while true do printf "\nEnter the directory path where the LOG subdirectory [${GRNct}${FW_LOG_SUBDIR}${NOct}] will be stored.\n" - printf "[${theExitStr}] [CURRENT: ${GRNct}${FW_LOG_BASE_DIR}${NOct}]: " + printf "[${theADExitStr}] [CURRENT: ${GRNct}${FW_LOG_BASE_DIR}${NOct}]: " read -r userInput if [ -z "$userInput" ] || echo "$userInput" | grep -qE "^(e|exit|Exit)$" @@ -842,7 +842,7 @@ _Set_FW_UpdateZIP_DirectoryPath_() while true do printf "\nEnter the directory path where the ZIP subdirectory [${GRNct}${FW_ZIP_SUBDIR}${NOct}] will be stored.\n" - printf "[${theExitStr}] [CURRENT: ${GRNct}${FW_ZIP_BASE_DIR}${NOct}]: " + printf "[${theADExitStr}] [CURRENT: ${GRNct}${FW_ZIP_BASE_DIR}${NOct}]: " read -r userInput if [ -z "$userInput" ] || echo "$userInput" | grep -qE "^(e|exit|Exit)$" @@ -1366,7 +1366,7 @@ change_build_type() { printf "Would you like to use the original ${REDct}ROG${NOct} themed user interface?${NOct}\n" while true; do - printf "\n [${theExitStr}] Enter your choice (y/n): " + printf "\n [${theADExitStr}] Enter your choice (y/n): " read -r choice choice="${choice:-$previous_choice}" choice="$(echo "$choice" | tr '[:upper:]' '[:lower:]')" @@ -1542,8 +1542,8 @@ _Set_FW_UpdateCronSchedule_() while true; do # Loop to keep asking for input printf "\nEnter new cron job schedule (e.g. '${GRNct}0 0 * * 0${NOct}' for every Sunday at midnight)" if [ -z "$current_schedule" ] - then printf "\n[${theExitStr}] [Default Schedule: ${GRNct}${new_schedule}${NOct}]: " - else printf "\n[${theExitStr}] [Current Schedule: ${GRNct}${current_schedule}${NOct}]: " + then printf "\n[${theADExitStr}] [Default Schedule: ${GRNct}${new_schedule}${NOct}]: " + else printf "\n[${theADExitStr}] [Current Schedule: ${GRNct}${current_schedule}${NOct}]: " fi read -r userInput @@ -2438,15 +2438,9 @@ A USB drive is required for F/W updates.\n" printf "\n ${GRNct}4${NOct}. Set F/W Update Postponement Days" printf "\n${padStr}[Current Days: ${GRNct}${FW_UpdatePostponementDays}${NOct}]\n" - - printf "\n ${GRNct}5${NOct}. Set F/W Update Check Schedule" - printf "\n${padStr}[Current Schedule: ${GRNct}${FW_UpdateCronJobSchedule}${NOct}]\n" - - printf "\n ${GRNct}6${NOct}. Set Directory for F/W Update ZIP File" - printf "\n${padStr}[Current Path: ${GRNct}${FW_ZIP_DIR}${NOct}]\n" - - printf "\n ${GRNct}7${NOct}. Set Directory for F/W Update Log Files" - printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" + + # In the show_menu function, add an option for Advanced Options + printf "\n ${GRNct}ad${NOct}. Advanced Options\n" # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") @@ -2460,12 +2454,6 @@ A USB drive is required for F/W updates.\n" current_build_type_menu="Not Set" fi - if echo "$PRODUCT_ID" | grep -q "^GT-"; then - # Display the option with the current build type - printf "\n ${GRNct}8${NOct}. Change ROG F/W Build Type" - printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" - fi - # Check for new script updates # if [ "$UpdateNotify" != "0" ]; then printf "\n ${GRNct}up${NOct}. Update $SCRIPT_NAME Script Now" @@ -2477,8 +2465,57 @@ A USB drive is required for F/W updates.\n" printf "${SEPstr}\n" } +##---------------------------------------## +## Added by ExtremeFiretop [2024-Jan-23] ## +##---------------------------------------## + +_advanced_options_menu_() { + theADExitStr="${GRNct}e${NOct}=Exit to advanced menu" + while true; do + clear + logo + printf "=============== Advanced Options Menu ===============\n" + printf "${SEPstr}\n" + printf "\n ${GRNct}1${NOct}. Set F/W Update Check Schedule" + printf "\n${padStr}[Current Schedule: ${GRNct}${FW_UpdateCronJobSchedule}${NOct}]\n" + + printf "\n ${GRNct}2${NOct}. Set Directory for F/W Update ZIP File" + printf "\n${padStr}[Current Path: ${GRNct}${FW_ZIP_DIR}${NOct}]\n" + + printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" + printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" + if echo "$PRODUCT_ID" | grep -q "^GT-"; then + printf "\n ${GRNct}4${NOct}. Change ROG F/W Build Type" + printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" + fi + printf "\n ${GRNct}e${NOct}. Exit to Main Menu\n" + printf "${SEPstr}" + + printf "\nEnter selection: " + read -r advancedChoice + echo + case $advancedChoice in + 1) _Set_FW_UpdateCronSchedule_ + ;; + 2) _Set_FW_UpdateZIP_DirectoryPath_ + ;; + 3) _Set_FW_UpdateLOG_DirectoryPath_ + ;; + 4) if echo "$PRODUCT_ID" | grep -q "^GT-"; then + change_build_type && _WaitForEnterKey_ + fi + ;; + e|exit) break + ;; + *) printf "${REDct}INVALID selection.${NOct} Please try again." + _WaitForEnterKey_ + ;; + esac + done +} + ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-22] ## +## Modified by ExtremeFiretop [2024-Jan-23] ## ##------------------------------------------## # Main Menu loop inMenuMode=true @@ -2507,14 +2544,7 @@ do ;; 4) _Set_FW_UpdatePostponementDays_ ;; - 5) _Set_FW_UpdateCronSchedule_ - ;; - 6) _Set_FW_UpdateZIP_DirectoryPath_ - ;; - 7) _Set_FW_UpdateLOG_DirectoryPath_ - ;; - 8) if echo "$PRODUCT_ID" | grep -q "^GT-"; then - change_build_type && _WaitForEnterKey_ ; fi + ad) _advanced_options_menu_ ;; up) _SCRIPTUPDATE_ ;; From 052b8151d8d258f676e7cce3f31f6945c0c98569 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 18:57:26 -0500 Subject: [PATCH 06/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index cb15b3d0..610f6079 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2364,7 +2364,7 @@ FW_NewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" FW_InstalledVersion="${GRNct}$(_GetCurrentFWInstalledLongVersion_)${NOct}" ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-22] ## +## Modified by ExtremeFiretop [2024-Jan-23] ## ##------------------------------------------## show_menu() { From 646ff19823da3ea8ff4fca0d88ef20ad02434eec Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 19:53:48 -0500 Subject: [PATCH 07/63] Update MerlinAU.sh --- MerlinAU.sh | 105 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 38 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 610f6079..a07e5da4 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -609,6 +609,7 @@ _Init_Custom_Settings_Config_() echo "FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" echo "FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" echo "FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" + echo "CheckChangeLog Enabled" } > "$SETTINGSFILE" return 1 fi @@ -635,6 +636,11 @@ _Init_Custom_Settings_Config_() retCode=1 # Default log directory path can be changed as needed fi + if ! grep -q "^CheckChangeLog" "$SETTINGSFILE" + then + sed -i "5 i CheckChangeLog Enabled" "$SETTINGSFILE" + retCode=1 + fi return "$retCode" } @@ -652,7 +658,7 @@ Get_Custom_Setting() if [ -f "$SETTINGSFILE" ]; then case "$setting_type" in - "ROGBuild" | "credentials_base64" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") setting_value="$(grep "^${setting_type} " "$SETTINGSFILE" | awk -F ' ' '{print $2}')" @@ -688,7 +694,7 @@ Update_Custom_Settings() [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" case "$setting_type" in - "ROGBuild" | "credentials_base64" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") if [ -f "$SETTINGSFILE" ]; then @@ -1341,6 +1347,21 @@ _GetLatestFWUpdateVersionFromWebsite_() echo "$correct_link" } +##---------------------------------------## +## Added by ExtremeFiretop [2024-Jan-23] ## +##---------------------------------------## + +_toggle_change_log_check_() { + local currentSetting="$(Get_Custom_Setting "CheckChangeLog")" + if [ "$currentSetting" = "Enabled" ]; then + Update_Custom_Settings "CheckChangeLog" "Disabled" + echo "Change-Log Check is now disabled." + else + Update_Custom_Settings "CheckChangeLog" "Enabled" + echo "Change-Log Check is now enabled." + fi +} + ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-07] ## ##------------------------------------------## @@ -1960,45 +1981,49 @@ Please manually update to version $minimum_supported_version or higher to use th ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-23] ## ##---------------------------------------## - # Define the path to the log file - changelog_file="${FW_BIN_DIR}/Changelog-NG.txt" - - # Check if the log file exists - if [ ! -f "$changelog_file" ]; then - Say "Change-log file does not exist at $changelog_file" - _DoCleanUp_ - "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 - else - # Format current_version by removing the last '.0' - formatted_current_version=$(echo $current_version | awk -F. '{print $1"."$2}') - - # Format release_version by removing the prefix '3004.' and the last '.0' - formatted_release_version=$(echo $release_version | awk -F. '{print $2"."$3}') - - # Extract log contents between two firmware versions - changelog_contents=$(awk "/$formatted_release_version/,/$formatted_current_version/" "$changelog_file") - - # Define high-risk terms as a single string separated by '|' - high_risk_terms="factory default reset|dropped support|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-logs.${NOct}" - printf "\n ${REDct}Would you like to continue anyways?${NOct}" - if ! _WaitForYESorNO_ ; then - Say "Exiting for change-log review." - _DoCleanUp_ - return 1 + local checkChangeLog="$(Get_Custom_Setting "CheckChangeLog")" + + if [ "$checkChangeLog" = "enabled" ]; then + # Define the path to the log file + changelog_file="${FW_BIN_DIR}/Changelog-NG.txt" + + # Check if the log file exists + if [ ! -f "$changelog_file" ]; then + Say "Change-log file does not exist at $changelog_file" + _DoCleanUp_ + "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" + return 1 + else + # Format current_version by removing the last '.0' + formatted_current_version=$(echo $current_version | awk -F. '{print $1"."$2}') + + # Format release_version by removing the prefix '3004.' and the last '.0' + formatted_release_version=$(echo $release_version | awk -F. '{print $2"."$3}') + + # Extract log contents between two firmware versions + changelog_contents=$(awk "/$formatted_release_version/,/$formatted_current_version/" "$changelog_file") + + # Define high-risk terms as a single string separated by '|' + high_risk_terms="factory default reset|dropped support|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-logs.${NOct}" + printf "\n ${REDct}Would you like to continue anyways?${NOct}" + if ! _WaitForYESorNO_ ; then + Say "Exiting for change-log review." + _DoCleanUp_ + return 1 + fi + else + Say "Warning: Found high-risk phrases in the change-logs." + Say "Please run script interactively to approve the flash." + _DoExit_ 1 fi else - Say "Warning: Found high-risk phrases in the change-logs." - Say "Please run script interactively to approve the flash." - _DoExit_ 1 + Say "No high-risk phrases found in the change-logs." fi - else - Say "No high-risk phrases found in the change-logs." fi fi @@ -2488,6 +2513,8 @@ _advanced_options_menu_() { printf "\n ${GRNct}4${NOct}. Change ROG F/W Build Type" printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" fi + printf "\n ${GRNct}5${NOct}. Toggle Change-Log Check\n" + printf "\n ${GRNct}e${NOct}. Exit to Main Menu\n" printf "${SEPstr}" @@ -2505,6 +2532,8 @@ _advanced_options_menu_() { change_build_type && _WaitForEnterKey_ fi ;; + 5) _toggle_change_log_check_ && _WaitForEnterKey_ + ;; e|exit) break ;; *) printf "${REDct}INVALID selection.${NOct} Please try again." From 9bee3d727f1fd16196aafa7cb2784caa2d845c98 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 22:46:26 -0500 Subject: [PATCH 08/63] Update MerlinAU.sh --- MerlinAU.sh | 60 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index a07e5da4..6e128e35 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -609,7 +609,7 @@ _Init_Custom_Settings_Config_() echo "FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" echo "FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" echo "FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" - echo "CheckChangeLog Enabled" + echo "CheckChangeLog ENABLED" } > "$SETTINGSFILE" return 1 fi @@ -638,7 +638,7 @@ _Init_Custom_Settings_Config_() fi if ! grep -q "^CheckChangeLog" "$SETTINGSFILE" then - sed -i "5 i CheckChangeLog Enabled" "$SETTINGSFILE" + sed -i "5 i CheckChangeLog ENABLED" "$SETTINGSFILE" retCode=1 fi return "$retCode" @@ -1353,12 +1353,12 @@ _GetLatestFWUpdateVersionFromWebsite_() _toggle_change_log_check_() { local currentSetting="$(Get_Custom_Setting "CheckChangeLog")" - if [ "$currentSetting" = "Enabled" ]; then - Update_Custom_Settings "CheckChangeLog" "Disabled" - echo "Change-Log Check is now disabled." + if [ "$currentSetting" = "ENABLED" ]; then + Update_Custom_Settings "CheckChangeLog" "DISABLED" + printf "Change-Log verification check is now ${REDct}disabled.${NOct}" else - Update_Custom_Settings "CheckChangeLog" "Enabled" - echo "Change-Log Check is now enabled." + Update_Custom_Settings "CheckChangeLog" "ENABLED" + printf "Change-Log verification check is now ${GRNct}enabled.${NOct}" fi } @@ -1387,7 +1387,7 @@ change_build_type() { printf "Would you like to use the original ${REDct}ROG${NOct} themed user interface?${NOct}\n" while true; do - printf "\n [${theADExitStr}] Enter your choice (y/n): " + printf "\n[${theADExitStr}] Enter your choice (y/n): " read -r choice choice="${choice:-$previous_choice}" choice="$(echo "$choice" | tr '[:upper:]' '[:lower:]')" @@ -1981,9 +1981,9 @@ Please manually update to version $minimum_supported_version or higher to use th ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-23] ## ##---------------------------------------## - local checkChangeLog="$(Get_Custom_Setting "CheckChangeLog")" + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" - if [ "$checkChangeLog" = "enabled" ]; then + if [ "$checkChangeLogSetting" = "ENABLED" ]; then # Define the path to the log file changelog_file="${FW_BIN_DIR}/Changelog-NG.txt" @@ -2025,6 +2025,8 @@ Please manually update to version $minimum_supported_version or higher to use th Say "No high-risk phrases found in the change-logs." fi fi + else + Say "Change-logs check disabled." fi # Detect ROG and pure firmware files @@ -2467,18 +2469,6 @@ A USB drive is required for F/W updates.\n" # In the show_menu function, add an option for Advanced Options printf "\n ${GRNct}ad${NOct}. Advanced Options\n" - # Retrieve the current build type setting - local current_build_type=$(Get_Custom_Setting "ROGBuild") - - # Convert the setting to a descriptive text - if [ "$current_build_type" = "y" ]; then - current_build_type_menu="ROG Build" - elif [ "$current_build_type" = "n" ]; then - current_build_type_menu="Pure Build" - else - current_build_type_menu="Not Set" - fi - # Check for new script updates # if [ "$UpdateNotify" != "0" ]; then printf "\n ${GRNct}up${NOct}. Update $SCRIPT_NAME Script Now" @@ -2509,11 +2499,33 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" + + # Retrieve the current build type setting + local current_build_type=$(Get_Custom_Setting "ROGBuild") + + # Convert the setting to a descriptive text + if [ "$current_build_type" = "y" ]; then + current_build_type_menu="ROG Build" + elif [ "$current_build_type" = "n" ]; then + current_build_type_menu="Pure Build" + else + current_build_type_menu="NOT SET" + fi + if echo "$PRODUCT_ID" | grep -q "^GT-"; then printf "\n ${GRNct}4${NOct}. Change ROG F/W Build Type" - printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" + if [ "$current_build_type_menu" = "NOT SET" ] + then printf "\n${padStr}[Current Build Type: ${REDct}${current_build_type_menu}${NOct}]\n" + else printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" + fi fi - printf "\n ${GRNct}5${NOct}. Toggle Change-Log Check\n" + printf "\n ${GRNct}5${NOct}. Toggle Change-Log Check" + + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" + if [ "$checkChangeLogSetting" = "DISABLED" ] + then printf "\n${padStr}[Currently: ${REDct}${checkChangeLogSetting}${NOct}]\n" + else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" + fi printf "\n ${GRNct}e${NOct}. Exit to Main Menu\n" printf "${SEPstr}" From 21f84df1fae57c71511b38a80ef98a6b7b3ce91f Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 23 Jan 2024 22:51:06 -0500 Subject: [PATCH 09/63] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 6e128e35..b872bf09 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2004,7 +2004,7 @@ Please manually update to version $minimum_supported_version or higher to use th changelog_contents=$(awk "/$formatted_release_version/,/$formatted_current_version/" "$changelog_file") # Define high-risk terms as a single string separated by '|' - high_risk_terms="factory default reset|dropped support|features are disabled|break backward compatibility|must be manually|strongly recommended" + 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 @@ -2527,7 +2527,7 @@ _advanced_options_menu_() { else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" fi - printf "\n ${GRNct}e${NOct}. Exit to Main Menu\n" + printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" printf "${SEPstr}" printf "\nEnter selection: " From dbd634961dc2f667ce8a680d93b8a88b8121a29f Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Wed, 24 Jan 2024 00:46:53 -0500 Subject: [PATCH 10/63] Update MerlinAU.sh --- MerlinAU.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b872bf09..8cbe78e1 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2500,7 +2500,15 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" - # Retrieve the current build type setting + printf "\n ${GRNct}4${NOct}. Toggle Change-Log Check" + + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" + if [ "$checkChangeLogSetting" = "DISABLED" ] + then printf "\n${padStr}[Currently: ${REDct}${checkChangeLogSetting}${NOct}]\n" + else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" + fi + + # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") # Convert the setting to a descriptive text @@ -2513,19 +2521,12 @@ _advanced_options_menu_() { fi if echo "$PRODUCT_ID" | grep -q "^GT-"; then - printf "\n ${GRNct}4${NOct}. Change ROG F/W Build Type" + printf "\n ${GRNct}5${NOct}. Change ROG F/W Build Type" if [ "$current_build_type_menu" = "NOT SET" ] then printf "\n${padStr}[Current Build Type: ${REDct}${current_build_type_menu}${NOct}]\n" else printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" fi fi - printf "\n ${GRNct}5${NOct}. Toggle Change-Log Check" - - local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" - if [ "$checkChangeLogSetting" = "DISABLED" ] - then printf "\n${padStr}[Currently: ${REDct}${checkChangeLogSetting}${NOct}]\n" - else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" - fi printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" printf "${SEPstr}" From 0e9783b52147381ec3d4e316d6e822c4733da762 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Wed, 24 Jan 2024 00:48:44 -0500 Subject: [PATCH 11/63] Update MerlinAU.sh --- MerlinAU.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 8cbe78e1..942a5a0e 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2541,12 +2541,12 @@ _advanced_options_menu_() { ;; 3) _Set_FW_UpdateLOG_DirectoryPath_ ;; - 4) if echo "$PRODUCT_ID" | grep -q "^GT-"; then + 4) _toggle_change_log_check_ && _WaitForEnterKey_ + ;; + 5) if echo "$PRODUCT_ID" | grep -q "^GT-"; then change_build_type && _WaitForEnterKey_ fi ;; - 5) _toggle_change_log_check_ && _WaitForEnterKey_ - ;; e|exit) break ;; *) printf "${REDct}INVALID selection.${NOct} Please try again." From 8cf17e9da0b70acd2a9712855696ba6aeabfa7ce Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Wed, 24 Jan 2024 01:07:47 -0500 Subject: [PATCH 12/63] Update MerlinAU.sh --- MerlinAU.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 942a5a0e..1aa16818 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1353,12 +1353,33 @@ _GetLatestFWUpdateVersionFromWebsite_() _toggle_change_log_check_() { local currentSetting="$(Get_Custom_Setting "CheckChangeLog")" + if [ "$currentSetting" = "ENABLED" ]; then - Update_Custom_Settings "CheckChangeLog" "DISABLED" - printf "Change-Log verification check is now ${REDct}disabled.${NOct}" + printf "${REDct}WARNING:${NOct} Disabling Change-Log check may risk unanticipated changes.\n" + printf "Only proceed if you review the change-logs manually.\n" + printf "\nProceed to disable? [y/N]: " + read -r response + case $response in + [Yy]* ) + Update_Custom_Settings "CheckChangeLog" "DISABLED" + printf "Change-Log verification check is now ${REDct}DISABLED.${NOct}\n" + ;; + *) + printf "Change-Log verification check remains ${GRNct}ENABLED.${NOct}\n" + ;; + esac else - Update_Custom_Settings "CheckChangeLog" "ENABLED" - printf "Change-Log verification check is now ${GRNct}enabled.${NOct}" + printf "Are you sure you want to enable the Change-Log verification check? [y/N]: " + read -r response + case $response in + [Yy]* ) + Update_Custom_Settings "CheckChangeLog" "ENABLED" + printf "Change-Log verification check is now ${GRNct}ENABLED.${NOct}\n" + ;; + *) + printf "Change-Log verification check remains ${REDct}DISABLED.${NOct}\n" + ;; + esac fi } From 23cfacb5802564c6858e2c8abd08b7023672d5be Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Wed, 24 Jan 2024 09:07:36 -0500 Subject: [PATCH 13/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 1aa16818..67ac7f9a 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -609,7 +609,7 @@ _Init_Custom_Settings_Config_() echo "FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" echo "FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" echo "FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" - echo "CheckChangeLog ENABLED" + echo "CheckChangeLog ENABLED" } > "$SETTINGSFILE" return 1 fi From 08c32a83e5eaf0f3a1ee3eaa745ef49a26f46ac2 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Wed, 24 Jan 2024 22:17:11 -0500 Subject: [PATCH 14/63] Update MerlinAU.sh --- MerlinAU.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 67ac7f9a..c65eb3ce 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2034,12 +2034,12 @@ Please manually update to version $minimum_supported_version or higher to use th printf "\n ${REDct}Would you like to continue anyways?${NOct}" if ! _WaitForYESorNO_ ; then Say "Exiting for change-log review." - _DoCleanUp_ - return 1 + _DoCleanUp_ 1 ; return 1 fi else Say "Warning: Found high-risk phrases in the change-logs." - Say "Please run script interactively to approve the flash." + Say "Please run script interactively to approve the flash upgrade." + _DoCleanUp 1 _DoExit_ 1 fi else From 73f72eca5fde12425fe46841b57127bda994f28f Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 24 Jan 2024 22:09:45 -0800 Subject: [PATCH 15/63] Update MerlinAU.sh Added code to support email notifications for the following events: - When a new F/W Update version is available. - At the start of flashing a new F/W Update version. - At the completion of flashing the F/W - post reboot. The email notification mechanism uses AMTM email configuration setup. --- MerlinAU.sh | 467 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 432 insertions(+), 35 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 67ac7f9a..24966ce0 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-Jan-23 +# Last Modified: 2024-Jan-24 ################################################################### set -u -readonly SCRIPT_VERSION="0.2.56" +readonly SCRIPT_VERSION="0.2.57" readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -51,6 +51,21 @@ readonly SETTINGS_DIR="${ADDONS_PATH}/${ScriptFNameTag}.d" readonly SETTINGSFILE="${SETTINGS_DIR}/custom_settings.txt" readonly SCRIPTVERPATH="${SETTINGS_DIR}/version.txt" +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +#-------------------------------------------------------# +# We'll use the built-in AMTM email configuration file +# to send email notifications *IF* enabled by the user. +#-------------------------------------------------------# +readonly FW_UpdateEMailNotificationDefault=false +readonly amtmMailDirPath="/jffs/addons/amtm/mail" +readonly amtmMailConfFile="${amtmMailDirPath}/email.conf" +readonly amtmMailPswdFile="${amtmMailDirPath}/emailpw.enc" +readonly tempEMailContent="/tmp/var/tmp/tempEMailContent.$$.TXT" +readonly tempEMailBodyMsg="/tmp/var/tmp/tempEMailBodyMsg.$$.TXT" +readonly saveEMailInfoMsg="${SETTINGS_DIR}/savedEMailInfoMsg.SAVE.TXT" + cronCmd="$(which crontab) -l" [ "$cronCmd" = " -l" ] && cronCmd="$(which cru) l" @@ -257,7 +272,7 @@ Toggle_LEDs() _Reset_LEDs_() { local doTrace=false - [ $# -gt 0 ] && [ "$1" -eq 1 ] && doTrace=true + [ $# -gt 0 ] && [ "$1" -eq 1 ] && doTrace=false if "$doTrace" then Say "START _Reset_LEDs_" @@ -593,9 +608,9 @@ else readonly FW_Update_LOG_BASE_DefaultDIR="$ADDONS_PATH" fi -##------------------------------------------## -## Modified by ExtremeFiretop [2023-Nov-23] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-24] ## +##----------------------------------------## _Init_Custom_Settings_Config_() { [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" @@ -606,6 +621,7 @@ _Init_Custom_Settings_Config_() echo "FW_New_Update_Notification_Date TBD" echo "FW_New_Update_Notification_Vers TBD" echo "FW_New_Update_Postponement_Days=$FW_UpdateDefaultPostponementDays" + echo "FW_New_Update_EMail_Notification=$FW_UpdateEMailNotificationDefault" echo "FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" echo "FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" echo "FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" @@ -615,37 +631,51 @@ _Init_Custom_Settings_Config_() fi local retCode=0 + if ! grep -q "^FW_New_Update_Notification_Date " "$SETTINGSFILE" + then + sed -i "1 i FW_New_Update_Notification_Date TBD" "$SETTINGSFILE" + retCode=1 + fi + if ! grep -q "^FW_New_Update_Notification_Vers " "$SETTINGSFILE" + then + sed -i "2 i FW_New_Update_Notification_Vers TBD" "$SETTINGSFILE" + retCode=1 + fi if ! grep -q "^FW_New_Update_Postponement_Days=" "$SETTINGSFILE" then - sed -i "1 i FW_New_Update_Postponement_Days=$FW_UpdateDefaultPostponementDays" "$SETTINGSFILE" + sed -i "3 i FW_New_Update_Postponement_Days=$FW_UpdateDefaultPostponementDays" "$SETTINGSFILE" + retCode=1 + fi + if ! grep -q "^FW_New_Update_EMail_Notification=" "$SETTINGSFILE" + then + sed -i "4 i FW_New_Update_EMail_Notification=$FW_UpdateEMailNotificationDefault" "$SETTINGSFILE" retCode=1 fi if ! grep -q "^FW_New_Update_Cron_Job_Schedule=" "$SETTINGSFILE" then - sed -i "2 i FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" "$SETTINGSFILE" + sed -i "5 i FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" "$SETTINGSFILE" retCode=1 fi if ! grep -q "^FW_New_Update_ZIP_Directory_Path=" "$SETTINGSFILE" then - sed -i "3 i FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" "$SETTINGSFILE" + sed -i "6 i FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" "$SETTINGSFILE" retCode=1 fi if ! grep -q "^FW_New_Update_LOG_Directory_Path=" "$SETTINGSFILE" then - sed -i "4 i FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" "$SETTINGSFILE" + sed -i "7 i FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" "$SETTINGSFILE" retCode=1 - # Default log directory path can be changed as needed fi if ! grep -q "^CheckChangeLog" "$SETTINGSFILE" then - sed -i "5 i CheckChangeLog ENABLED" "$SETTINGSFILE" + sed -i "8 i CheckChangeLog ENABLED" "$SETTINGSFILE" retCode=1 fi return "$retCode" } ##----------------------------------------## -## Modified by Martinski W. [2023-Dec-06] ## +## Modified by Martinski W. [2024-Jan-24] ## ##----------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() @@ -666,7 +696,8 @@ Get_Custom_Setting() "FW_New_Update_Postponement_Days" | \ "FW_New_Update_Cron_Job_Schedule" | \ "FW_New_Update_ZIP_Directory_Path" | \ - "FW_New_Update_LOG_Directory_Path") + "FW_New_Update_LOG_Directory_Path" | \ + "FW_New_Update_EMail_Notification") grep -q "^${setting_type}=" "$SETTINGSFILE" && \ setting_value="$(grep "^${setting_type}=" "$SETTINGSFILE" | awk -F '=' '{print $2}' | sed "s/['\"]//g")" ;; @@ -712,7 +743,8 @@ Update_Custom_Settings() "FW_New_Update_Postponement_Days" | \ "FW_New_Update_Cron_Job_Schedule" | \ "FW_New_Update_ZIP_Directory_Path" | \ - "FW_New_Update_LOG_Directory_Path") # Added this line + "FW_New_Update_LOG_Directory_Path" | \ + "FW_New_Update_EMail_Notification") if [ -f "$SETTINGSFILE" ] then if grep -q "^${setting_type}=" "$SETTINGSFILE" @@ -733,6 +765,10 @@ Update_Custom_Settings() then FW_UpdatePostponementDays="$setting_value" # + elif [ "$setting_type" = "FW_New_Update_EMail_Notification" ] + then + sendEMailNotificationsFlag="$setting_value" + # elif [ "$setting_type" = "FW_New_Update_Cron_Job_Schedule" ] then FW_UpdateCronJobSchedule="$setting_value" @@ -951,6 +987,10 @@ readonly hookScriptTagStr="#Added by $ScriptFNameTag#" # Postponement Days for F/W Update Check # FW_UpdatePostponementDays="$(Get_Custom_Setting FW_New_Update_Postponement_Days)" +# F/W Update Email Notifications # +isEMailConfigEnabledInAMTM=false +sendEMailNotificationsFlag="$(Get_Custom_Setting FW_New_Update_EMail_Notification)" + # Define the CRON job command to execute # FW_UpdateCronJobSchedule="$(Get_Custom_Setting FW_New_Update_Cron_Job_Schedule)" readonly CRON_JOB_RUN="sh $ScriptFilePath run_now" @@ -962,12 +1002,205 @@ readonly CRON_SCRIPT_HOOK="[ -f $ScriptFilePath ] && $CRON_SCRIPT_JOB" readonly POST_REBOOT_SCRIPT_JOB="sh $ScriptFilePath postRebootRun & $hookScriptTagStr" readonly POST_REBOOT_SCRIPT_HOOK="[ -f $ScriptFilePath ] && $POST_REBOOT_SCRIPT_JOB" +# Define post-update email notification job command to execute # +readonly POST_UPDATE_EMAIL_SCRIPT_JOB="sh $ScriptFilePath postUpdateEmail & $hookScriptTagStr" +readonly POST_UPDATE_EMAIL_SCRIPT_HOOK="[ -f $ScriptFilePath ] && $POST_UPDATE_EMAIL_SCRIPT_JOB" + if [ -d "$FW_LOG_DIR" ] then # Log rotation - delete logs older than 30 days # find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_CreateEMailContent_() +{ + if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi + local fwInstalledVersion fwNewUpdateVersion subjectStr + local savedInstalledVersion savedNewUpdateVersion + + rm -f "$tempEMailContent" "$tempEMailBodyMsg" + + fwInstalledVersion="$(_GetCurrentFWInstalledLongVersion_)" + fwNewUpdateVersion="$(_GetLatestFWUpdateVersionFromRouter_ 1)" + subjectStr="F/W Update Status for $MODEL_ID" + + case "$1" in + FW_UPDATE_TEST_EMAIL) + { + echo + echo "TESTING:" + echo "This is a test of the F/W Update email notification from $MODEL_ID router." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + ;; + NEW_FW_UPDATE_STATUS) + { + echo + echo "A new F/W Update version $fwNewUpdateVersion is available for $MODEL_ID router." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n" + printf "\nNumber of days to postpone flashing the new F/W Update version: ${FW_UpdatePostponementDays}\n\n" + } > "$tempEMailBodyMsg" + ;; + START_FW_UPDATE_STATUS) + { + echo + echo "Started flashing the new F/W Update version $fwNewUpdateVersion on $MODEL_ID router." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + ;; + FAILED_FW_UPDATE_STATUS) + { + echo + echo "**ERROR**:" + echo "Flashing of new F/W Update version $fwNewUpdateVersion for $MODEL_ID router failed." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + ;; + POST_REBOOT_FW_UPDATE_SETUP) + { + echo "FW_InstalledVersion=$fwInstalledVersion" + echo "FW_NewUpdateVersion=$fwNewUpdateVersion" + } > "$saveEMailInfoMsg" + _AddPostUpdateEmailNotifyScriptHook_ + return 0 + ;; + POST_REBOOT_FW_UPDATE_STATUS) + if [ ! -f "$saveEMailInfoMsg" ] + then + Say "${REDct}**ERROR**${NOct}: Unable to send post-update email notification [No saved info file]." + return 1 + fi + savedInstalledVersion="$(cat "$saveEMailInfoMsg" | grep "FW_InstalledVersion=" | awk -F '=' '{print $2}')" + savedNewUpdateVersion="$(cat "$saveEMailInfoMsg" | grep "FW_NewUpdateVersion=" | awk -F '=' '{print $2}')" + if [ -z "$savedInstalledVersion" ] || [ -z "$savedNewUpdateVersion" ] + then + Say "${REDct}**ERROR**${NOct}: Unable to send post-update email notification [Saved info is empty]." + return 1 + fi + if [ "$savedNewUpdateVersion" = "$fwInstalledVersion" ] && \ + [ "$savedInstalledVersion" != "$fwInstalledVersion" ] + then + { + echo + echo "Flashing of new F/W Update version $fwInstalledVersion for $MODEL_ID router was successful." + printf "\nThe F/W version that was previously installed:\n${savedInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + else + { + echo + echo "**ERROR**:" + echo "Flashing of new F/W Update version $savedNewUpdateVersion for $MODEL_ID router failed." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + fi + rm -f "$saveEMailInfoMsg" + ;; + *) return 1 + ;; + esac + + ## Header ## + cat < "$tempEMailContent" +From: "$FROM_NAME" <$FROM_ADDRESS> +To: "$TO_NAME" <$TO_ADDRESS> +Subject: $subjectStr +Date: $(date -R) +EOF + + cat "$tempEMailBodyMsg" >> "$tempEMailContent" + rm -f "$tempEMailBodyMsg" + + ## Footer ## + cat <> "$tempEMailContent" +Sent by the "$ScriptFNameTag" Utility. +From the "${FRIENDLY_ROUTER_NAME}" router. + +$(date +"%Y-%b-%d, %I:%M:%S %p %Z (%a)") +EOF + return 0 +} + +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_CheckEMailConfigFileFromAMTM_() +{ + local doLogMsgs + + if [ $# -gt 0 ] && [ "$1" -eq 1 ] + then doLogMsgs=true + else doLogMsgs=false + fi + + isEMailConfigEnabledInAMTM=false + + if [ ! -f "$amtmMailConfFile" ] || [ ! -f "$amtmMailPswdFile" ] + then + "$doLogMsgs" && \ + Say "${REDct}**ERROR**${NOct}: Unable to send email notification [No config file]." + return 1 + fi + + FROM_NAME="" TO_NAME="" FROM_ADDRESS="" TO_ADDRESS="" + USERNAME="" SMTP="" PORT="" PROTOCOL="" emailPwEnc="" + + . "$amtmMailConfFile" + + if [ -z "$TO_NAME" ] || [ -z "$USERNAME" ] || \ + [ -z "$FROM_ADDRESS" ] || [ -z "$TO_ADDRESS" ] || \ + [ -z "$SMTP" ] || [ -z "$PORT" ] || [ -z "$PROTOCOL" ] || [ -z "$emailPwEnc" ] + then + "$doLogMsgs" && \ + Say "${REDct}**ERROR**${NOct}: Unable to send email notification [Empty variables]." + return 1 + fi + + isEMailConfigEnabledInAMTM=true + return 0 +} + +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_SendEMailNotification_() +{ + if [ $# -eq 0 ] || [ -z "$1" ] || \ + ! "$sendEMailNotificationsFlag" || \ + ! _CheckEMailConfigFileFromAMTM_ 1 + then return 1 ; fi + + [ -z "$FROM_NAME" ] && FROM_NAME="$ScriptFNameTag" + [ -z "$FRIENDLY_ROUTER_NAME" ] && FRIENDLY_ROUTER_NAME="$MODEL_ID" + + ! _CreateEMailContent_ "$1" && return 1 + + [ "$1" = "POST_REBOOT_FW_UPDATE_SETUP" ] && return 0 + + printf "\nSending email notification [$1]...\n" + + echo "$(date +"$LOGdateFormat")" > "$userTraceFile" + + /usr/sbin/curl --url ${PROTOCOL}://${SMTP}:${PORT} \ + --mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \ + --user "${USERNAME}:$(/usr/sbin/openssl aes-256-cbc $emailPwEnc -d -in "$amtmMailPswdFile" -pass pass:ditbabot,isoi)" \ + --upload-file "$tempEMailContent" \ + $SSL_FLAG --ssl-reqd --crlf >> "$userTraceFile" 2>&1 + + if [ "$?" -eq 0 ] + then + sleep 2 + rm -f "$tempEMailContent" + Say "The email notification was sent successfully [$1]." + else + Say "${REDct}**ERROR**${NOct}: Failure to send email notification [$1]." + fi + + return 0 +} + ##-------------------------------------## ## Added by Martinski W. [2023-Oct-12] ## ##-------------------------------------## @@ -988,6 +1221,68 @@ _CreateDirectory_() return 0 } +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_DelPostUpdateEmailNotifyScriptHook_() +{ + local hookScriptFile + + if [ $# -gt 0 ] && [ -n "$1" ] + then hookScriptFile="$1" + else hookScriptFile="$hookScriptFPath" + fi + if [ ! -f "$hookScriptFile" ] ; then return 1 ; fi + + if grep -qE "$POST_UPDATE_EMAIL_SCRIPT_JOB" "$hookScriptFile" + then + sed -i -e '/\/'"$ScriptFileName"' postUpdateEmail & '"$hookScriptTagStr"'/d' "$hookScriptFile" + if [ $? -eq 0 ] + then + Say "Post-update email notification hook was deleted successfully from '$hookScriptFile' script." + fi + else + Say "${GRNct}Post-update email notification hook is not found in '$hookScriptFile' script.${NOct}" + fi +} + +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_AddPostUpdateEmailNotifyScriptHook_() +{ + local hookScriptFile jobHookAdded=false + + if [ $# -gt 0 ] && [ -n "$1" ] + then hookScriptFile="$1" + else hookScriptFile="$hookScriptFPath" + fi + + if [ ! -f "$hookScriptFile" ] + then + jobHookAdded=true + { + echo "#!/bin/sh" + echo "# $hookScriptFName" + echo "#" + echo "$POST_UPDATE_EMAIL_SCRIPT_HOOK" + } > "$hookScriptFile" + # + elif ! grep -qE "$POST_UPDATE_EMAIL_SCRIPT_JOB" "$hookScriptFile" + then + jobHookAdded=true + echo "$POST_UPDATE_EMAIL_SCRIPT_HOOK" >> "$hookScriptFile" + fi + chmod 0755 "$hookScriptFile" + + if "$jobHookAdded" + then Say "Post-update email notification hook was added successfully to '$hookScriptFile' script." + else Say "Post-update email notification hook already exists in '$hookScriptFile' script." + fi + + "$isInteractive" && _WaitForEnterKey_ +} + ##----------------------------------------------## ## Added/Modified by Martinski W. [2023-Nov-28] ## ##----------------------------------------------## @@ -1197,7 +1492,7 @@ _DoCleanUp_() local delBINfiles=false keepZIPfile=false moveZIPback=false local doTrace=false - [ $# -gt 0 ] && [ "$1" -eq 0 ] && doTrace=true + [ $# -gt 0 ] && [ "$1" -eq 0 ] && doTrace=false if "$doTrace" then Say "\nSTART _DoCleanUp_" @@ -1350,13 +1645,12 @@ _GetLatestFWUpdateVersionFromWebsite_() ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-23] ## ##---------------------------------------## - _toggle_change_log_check_() { local currentSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$currentSetting" = "ENABLED" ]; then - printf "${REDct}WARNING:${NOct} Disabling Change-Log check may risk unanticipated changes.\n" - printf "Only proceed if you review the change-logs manually.\n" + printf "${REDct}*WARNING*:${NOct} Disabling Change-Log check may risk unanticipated changes.\n" + printf "The advise is to proceed only if you review the change-logs manually.\n" printf "\nProceed to disable? [y/N]: " read -r response case $response in @@ -1631,9 +1925,9 @@ _Set_FW_UpdateCronSchedule_() return "$retCode" } -##-------------------------------------## -## Added by Martinski W. [2023-Oct-12] ## -##-------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-24] ## +##----------------------------------------## _CheckNewUpdateFirmwareNotification_() { if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] @@ -1667,6 +1961,7 @@ _CheckNewUpdateFirmwareNotification_() fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Vers "$fwNewUpdateNotificationVers" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" + _SendEMailNotification_ NEW_FW_UPDATE_STATUS fi fi @@ -1675,6 +1970,7 @@ _CheckNewUpdateFirmwareNotification_() then fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" + _SendEMailNotification_ NEW_FW_UPDATE_STATUS fi return 0 } @@ -1716,11 +2012,53 @@ _CheckTimeToUpdateFirmware_() upfwDateTimeSecs="$((notifyTimeSecs + postponeTimeSecs))" upfwDateTimeStrn="$(echo "$upfwDateTimeSecs" | awk '{print strftime("%Y-%b-%d",$1)}')" - Say "The firmware update to '${2}' version is postponed for '${fwNewUpdatePostponementDays}' day(s)." - Say "The firmware update is expected to occur on or after '${upfwDateTimeStrn}' depending on when your cron job is scheduled to check again." + Say "The firmware update to ${GRNct}${2}${NOct} version is currently postponed for ${GRNct}${fwNewUpdatePostponementDays}${NOct} day(s)." + Say "The firmware update is expected to occur on or after ${GRNct}${upfwDateTimeStrn}${NOct} depending on when your cron job is scheduled to check again." return 1 } +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_Toggle_FW_UpdateEmailNotifications_() +{ + local emailNotificationEnabled emailNotificationNewStateStr + local runEmailNotifyTestOK=false + + if "$sendEMailNotificationsFlag" + then + emailNotificationEnabled=true + emailNotificationNewStateStr="${REDct}DISABLE${NOct}" + else + emailNotificationEnabled=false + emailNotificationNewStateStr="${GRNct}ENABLE${NOct}" + fi + + if ! _WaitForYESorNO_ "Do you want to ${emailNotificationNewStateStr} F/W Update email notifications?" + then return 1 ; fi + + if "$emailNotificationEnabled" + then + runEmailNotifyTestOK=false + sendEMailNotificationsFlag=false + emailNotificationNewStateStr="${REDct}DISABLED${NOct}" + else + runEmailNotifyTestOK=true + sendEMailNotificationsFlag=true + emailNotificationNewStateStr="${GRNct}ENABLED${NOct}" + fi + + Update_Custom_Settings FW_New_Update_EMail_Notification "$sendEMailNotificationsFlag" + printf "F/W Update email notifications are now ${emailNotificationNewStateStr}.\n" + + if "$runEmailNotifyTestOK" && \ + _WaitForYESorNO_ "\nWould you like to run a test of the email notification?" + then + _SendEMailNotification_ FW_UPDATE_TEST_EMAIL + fi + _WaitForEnterKey_ "$menuReturnPromptStr" +} + ##------------------------------------------## ## Modified by ExtremeFiretop [2023-Nov-26] ## ##------------------------------------------## @@ -1998,13 +2336,13 @@ Please manually update to version $minimum_supported_version or higher to use th # Navigate to the firmware directory cd "$FW_BIN_DIR" - + ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-23] ## ##---------------------------------------## - local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" - - if [ "$checkChangeLogSetting" = "ENABLED" ]; then + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" + + if [ "$checkChangeLogSetting" = "ENABLED" ]; then # Define the path to the log file changelog_file="${FW_BIN_DIR}/Changelog-NG.txt" @@ -2046,7 +2384,7 @@ Please manually update to version $minimum_supported_version or higher to use th Say "No high-risk phrases found in the change-logs." fi fi - else + else Say "Change-logs check disabled." fi @@ -2127,6 +2465,8 @@ Please manually update to version $minimum_supported_version or higher to use th #------------------------------------------------------------# /sbin/service restart_httpd && sleep 5 + _SendEMailNotification_ START_FW_UPDATE_STATUS + curl_response="$(curl "${routerURLstr}/login.cgi" \ --referer ${routerURLstr}/Main_Login.asp \ --user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ @@ -2143,6 +2483,8 @@ Please manually update to version $minimum_supported_version or higher to use th if echo "$curl_response" | grep -q 'url=index.asp' then + _SendEMailNotification_ POST_REBOOT_FW_UPDATE_SETUP + Say "Flashing ${GRNct}${firmware_file}${NOct}... ${REDct}Please wait for reboot in about 4 minutes or less.${NOct}" echo @@ -2191,12 +2533,43 @@ Please manually update to version $minimum_supported_version or higher to use th Say "${REDct}**ERROR**${NOct}: Login failed. Please try the following: 1. Confirm you are not already logged into the router using a web browser. 2. Update credentials by selecting \"Configure Router Login Credentials\" from the Main Menu." + + _SendEMailNotification_ FAILED_FW_UPDATE_STATUS _DoCleanUp_ 1 "$keepZIPfile" fi "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" } +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_PostUpdateEmailNotification_() +{ + _DelPostUpdateEmailNotifyScriptHook_ + + local theWaitDelaySecs=10 + local maxWaitDelaySecs=360 #6 minutes# + local curWaitDelaySecs=0 + #--------------------------------------------------------- + # Wait until all services are started, including NTP + # so the system clock is updated with correct time. + #--------------------------------------------------------- + while [ "$curWaitDelaySecs" -lt "$maxWaitDelaySecs" ] + do + if [ "$(nvram get ntp_ready)" -eq 1 ] && \ + [ "$(nvram get start_service_ready)" -eq 1 ] && \ + [ "$(nvram get success_start_service)" -eq 1 ] + then sleep 30 ; break; fi + + echo "Waiting for all services to be started [$theWaitDelaySecs secs.]..." + sleep $theWaitDelaySecs + curWaitDelaySecs="$((curWaitDelaySecs + theWaitDelaySecs))" + done + + _SendEMailNotification_ POST_REBOOT_FW_UPDATE_STATUS +} + ##-------------------------------------## ## Added by Martinski W. [2023-Nov-20] ## ##-------------------------------------## @@ -2288,9 +2661,9 @@ _AddCronJobRunScriptHook_() fi } -##----------------------------------------------## -## Added/Modified by Martinski W. [2023-Dec-01] ## -##----------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-24] ## +##----------------------------------------## _DoUninstall_() { printf "Are you sure you want to uninstall $ScriptFileName script now" @@ -2299,6 +2672,8 @@ _DoUninstall_() _DelCronJobEntry_ _DelCronJobRunScriptHook_ _DelPostRebootRunScriptHook_ + _DelPostUpdateEmailNotifyScriptHook_ + if rm -fr "$SETTINGS_DIR" && \ rm -fr "${FW_BIN_BASE_DIR}/$ScriptFNameTag" && \ rm -fr "${FW_LOG_BASE_DIR}/$ScriptFNameTag" && \ @@ -2327,8 +2702,13 @@ then Say "Exiting..." ; exit 1 ; fi check_model_support check_version_support +##-------------------------------------## +## Added by Martinski W. [2024-Jan-24] ## +##-------------------------------------## +_CheckEMailConfigFileFromAMTM_ 0 + ##----------------------------------------## -## Modified by Martinski W. [2023-Dec-26] ## +## Modified by Martinski W. [2024-Jan-24] ## ##----------------------------------------## if [ $# -gt 0 ] then @@ -2340,6 +2720,8 @@ then ;; postRebootRun) _PostRebootRunNow_ ;; + postUpdateEmail) _PostUpdateEmailNotification_ + ;; uninstall) _DoUninstall_ ;; *) printf "${REDct}INVALID Parameter.${NOct}\n" @@ -2486,7 +2868,20 @@ A USB drive is required for F/W updates.\n" printf "\n ${GRNct}4${NOct}. Set F/W Update Postponement Days" printf "\n${padStr}[Current Days: ${GRNct}${FW_UpdatePostponementDays}${NOct}]\n" - + + # F/W Update EMail Notifications # + if _CheckEMailConfigFileFromAMTM_ 0 + then + if "$sendEMailNotificationsFlag" + then + printf "\n ${GRNct}em${NOct}. Disable F/W Update EMail Notifications" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" + else + printf "\n ${GRNct}em${NOct}. Enable F/W Update EMail Notifications" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + fi + fi + # In the show_menu function, add an option for Advanced Options printf "\n ${GRNct}ad${NOct}. Advanced Options\n" @@ -2504,7 +2899,6 @@ A USB drive is required for F/W updates.\n" ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-23] ## ##---------------------------------------## - _advanced_options_menu_() { theADExitStr="${GRNct}e${NOct}=Exit to advanced menu" while true; do @@ -2607,6 +3001,9 @@ do ;; 4) _Set_FW_UpdatePostponementDays_ ;; + em) "$isEMailConfigEnabledInAMTM" && \ + _Toggle_FW_UpdateEmailNotifications_ + ;; ad) _advanced_options_menu_ ;; up) _SCRIPTUPDATE_ From bea951330115ddd1cc8282527de490fee79b00f2 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 25 Jan 2024 03:32:43 -0800 Subject: [PATCH 16/63] Update MerlinAU.sh Just some rewording & reformatting of the email notifications using HTML. --- MerlinAU.sh | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index d8b1e107..8dc64cba 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION="0.2.57" +readonly SCRIPT_VERSION="0.2.58" readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -1032,31 +1032,31 @@ _CreateEMailContent_() { echo echo "TESTING:" - echo "This is a test of the F/W Update email notification from $MODEL_ID router." - printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + echo "This is a test of the F/W Update email notification from the ${MODEL_ID} router." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; NEW_FW_UPDATE_STATUS) { echo - echo "A new F/W Update version $fwNewUpdateVersion is available for $MODEL_ID router." - printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n" - printf "\nNumber of days to postpone flashing the new F/W Update version: ${FW_UpdatePostponementDays}\n\n" + echo "A new F/W Update version ${fwNewUpdateVersion} is available for the ${MODEL_ID} router." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n" + printf "\nNumber of days to postpone flashing the new F/W Update version: ${FW_UpdatePostponementDays}\n\n" } > "$tempEMailBodyMsg" ;; START_FW_UPDATE_STATUS) { echo - echo "Started flashing the new F/W Update version $fwNewUpdateVersion on $MODEL_ID router." - printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + echo "Started flashing the new F/W Update version ${fwNewUpdateVersion} on the ${MODEL_ID} router." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; FAILED_FW_UPDATE_STATUS) { echo - echo "**ERROR**:" - echo "Flashing of new F/W Update version $fwNewUpdateVersion for $MODEL_ID router failed." - printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + echo "**ERROR**:" + echo "Flashing of new F/W Update version ${fwNewUpdateVersion} for the ${MODEL_ID} router failed." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; POST_REBOOT_FW_UPDATE_SETUP) @@ -1085,15 +1085,15 @@ _CreateEMailContent_() then { echo - echo "Flashing of new F/W Update version $fwInstalledVersion for $MODEL_ID router was successful." - printf "\nThe F/W version that was previously installed:\n${savedInstalledVersion}\n\n" + echo "Flashing of new F/W Update version ${fwInstalledVersion} for the ${MODEL_ID} router was successful." + printf "\nThe F/W version that was previously installed:\n${savedInstalledVersion}\n\n" } > "$tempEMailBodyMsg" else { echo - echo "**ERROR**:" - echo "Flashing of new F/W Update version $savedNewUpdateVersion for $MODEL_ID router failed." - printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" + echo "**ERROR**:" + echo "Flashing of new F/W Update version ${savedNewUpdateVersion} for the ${MODEL_ID} router failed." + printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" fi rm -f "$saveEMailInfoMsg" @@ -1108,18 +1108,22 @@ From: "$FROM_NAME" <$FROM_ADDRESS> To: "$TO_NAME" <$TO_ADDRESS> Subject: $subjectStr Date: $(date -R) +MIME-Version: 1.0 +Content-Type: text/html; charset="UTF-8" +
+

EOF - cat "$tempEMailBodyMsg" >> "$tempEMailContent" - rm -f "$tempEMailBodyMsg" ## Footer ## cat <> "$tempEMailContent" -Sent by the "$ScriptFNameTag" Utility. -From the "${FRIENDLY_ROUTER_NAME}" router. +Sent by the "${ScriptFNameTag}" Utility. +From the "${FRIENDLY_ROUTER_NAME}" router. $(date +"%Y-%b-%d, %I:%M:%S %p %Z (%a)") +

EOF + rm -f "$tempEMailBodyMsg" return 0 } @@ -1179,7 +1183,7 @@ _SendEMailNotification_() [ "$1" = "POST_REBOOT_FW_UPDATE_SETUP" ] && return 0 - printf "\nSending email notification [$1]...\n" + printf "\nSending email notification [$1]. Please wait...\n" echo "$(date +"$LOGdateFormat")" > "$userTraceFile" From 50aa959c589e079801209777411414e33b6424ce Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:51:49 -0800 Subject: [PATCH 17/63] Update MerlinAU.sh Added code to explicitly stop all Entware services, if Entware is found installed, before starting to flash the F/W image. --- MerlinAU.sh | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 8dc64cba..30847052 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-Jan-24 +# Last Modified: 2024-Jan-25 ################################################################### set -u -readonly SCRIPT_VERSION="0.2.58" +readonly SCRIPT_VERSION="0.2.59" readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -1193,14 +1193,14 @@ _SendEMailNotification_() --upload-file "$tempEMailContent" \ $SSL_FLAG --ssl-reqd --crlf >> "$userTraceFile" 2>&1 - if [ "$?" -eq 0 ] + if [ $? -eq 0 ] then sleep 2 - rm -f "$tempEMailContent" Say "The email notification was sent successfully [$1]." else Say "${REDct}**ERROR**${NOct}: Failure to send email notification [$1]." fi + rm -f "$tempEMailContent" return 0 } @@ -2111,9 +2111,40 @@ _Toggle_FW_UpdateCheckSetting_() _WaitForEnterKey_ "$menuReturnPromptStr" } -##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-06] ## -##------------------------------------------## +##-------------------------------------## +## Added by Martinski W. [2024-Jan-25] ## +##-------------------------------------## +_EntwareServicesHandler_() +{ + if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi + + local fileCount entwOPT_init entwOPT_unslung actionStr="" + + entwOPT_init="/opt/etc/init.d" + entwOPT_unslung="${entwOPT_init}/rc.unslung" + + if [ ! -x /opt/bin/opkg ] || [ ! -x "$entwOPT_unslung" ] + then return 1 ; fi ## Entware is not found ## + + fileCount="$(/usr/bin/find "$entwOPT_init" -name "S*" -exec ls -1 {} \; 2>/dev/null | /bin/grep -cE "${entwOPT_init}/S[0-9]+")" + [ "$fileCount" -eq 0 ] && return 0 + + case "$1" in + stop) actionStr="Stopping" ;; + start) actionStr="Restarting" ;; + *) return 1 ;; + esac + + if [ -n "$actionStr" ] + then + printf "\n${actionStr} Entware services... Please wait.\n" + $entwOPT_unslung $1 ; sleep 5 + fi +} + +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-25] ## +##----------------------------------------## # Embed functions from second script, modified as necessary. _RunFirmwareUpdateNow_() { @@ -2467,8 +2498,10 @@ Please manually update to version $minimum_supported_version or higher to use th # Restart the WebGUI to make sure nobody else is logged in # so that the F/W Update can start without interruptions. #------------------------------------------------------------# + "$isInteractive" && printf "\nRestarting web server... Please wait.\n" /sbin/service restart_httpd && sleep 5 + _EntwareServicesHandler_ stop _SendEMailNotification_ START_FW_UPDATE_STATUS curl_response="$(curl "${routerURLstr}/login.cgi" \ @@ -2540,6 +2573,7 @@ Please manually update to version $minimum_supported_version or higher to use th _SendEMailNotification_ FAILED_FW_UPDATE_STATUS _DoCleanUp_ 1 "$keepZIPfile" + _EntwareServicesHandler_ start fi "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" From abebc6d6293111a9b4a25e512bdcec5e6accbbe1 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Thu, 25 Jan 2024 22:08:58 -0500 Subject: [PATCH 18/63] Update MerlinAU.sh --- MerlinAU.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 8dc64cba..6ecb9cf9 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION="0.2.58" +readonly SCRIPT_VERSION=0.9.55 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -1051,6 +1051,13 @@ _CreateEMailContent_() printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; + STOP_FW_UPDATE_APPROVAL) + { + echo + echo "Warning: Found high-risk phrases in the change-logs while Auto-Updating to: $fwNewUpdateVersion on $MODEL_ID router." + printf "\nPlease run script interactively to approve this upgrade from:\n${fwInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + ;; FAILED_FW_UPDATE_STATUS) { echo @@ -1653,29 +1660,29 @@ _toggle_change_log_check_() { local currentSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$currentSetting" = "ENABLED" ]; then - printf "${REDct}*WARNING*:${NOct} Disabling Change-Log check may risk unanticipated changes.\n" - printf "The advise is to proceed only if you review the change-logs manually.\n" + printf "${REDct}*WARNING*:${NOct} Disabling change-log verification may risk unanticipated changes.\n" + printf "The advice is to proceed only if you review the change-logs manually.\n" printf "\nProceed to disable? [y/N]: " read -r response case $response in [Yy]* ) Update_Custom_Settings "CheckChangeLog" "DISABLED" - printf "Change-Log verification check is now ${REDct}DISABLED.${NOct}\n" + printf "Change-log verification check is now ${REDct}DISABLED.${NOct}\n" ;; *) - printf "Change-Log verification check remains ${GRNct}ENABLED.${NOct}\n" + printf "Change-log verification check remains ${GRNct}ENABLED.${NOct}\n" ;; esac else - printf "Are you sure you want to enable the Change-Log verification check? [y/N]: " + printf "Are you sure you want to enable the Change-log verification check? [y/N]: " read -r response case $response in [Yy]* ) Update_Custom_Settings "CheckChangeLog" "ENABLED" - printf "Change-Log verification check is now ${GRNct}ENABLED.${NOct}\n" + printf "Change-log verification check is now ${GRNct}ENABLED.${NOct}\n" ;; *) - printf "Change-Log verification check remains ${REDct}DISABLED.${NOct}\n" + printf "Change-log verification check remains ${REDct}DISABLED.${NOct}\n" ;; esac fi @@ -2380,7 +2387,8 @@ Please manually update to version $minimum_supported_version or higher to use th fi else Say "Warning: Found high-risk phrases in the change-logs." - Say "Please run script interactively to approve the flash upgrade." + Say "Please run script interactively to approve the upgrade." + _SendEMailNotification_ STOP_FW_UPDATE_APPROVAL _DoCleanUp 1 _DoExit_ 1 fi @@ -2919,7 +2927,7 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" - printf "\n ${GRNct}4${NOct}. Toggle Change-Log Check" + printf "\n ${GRNct}4${NOct}. Toggle Change-log Check" local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$checkChangeLogSetting" = "DISABLED" ] From 5e7cce767665a54404c180ad74dd1e9d6c5d21b5 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 01:42:44 -0500 Subject: [PATCH 19/63] Update MerlinAU.sh --- MerlinAU.sh | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 6a548c81..1b33e1d1 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1054,8 +1054,16 @@ _CreateEMailContent_() STOP_FW_UPDATE_APPROVAL) { echo - echo "Warning: Found high-risk phrases in the change-logs while Auto-Updating to: $fwNewUpdateVersion on $MODEL_ID router." - printf "\nPlease run script interactively to approve this upgrade from:\n${fwInstalledVersion}\n\n" + echo "Warning: Found high-risk phrases in the change-logs while Auto-Updating to: ${fwNewUpdateVersion} on ${MODEL_ID} router." + printf "\nPlease run script interactively to approve this upgrade from:\n${fwInstalledVersion}\n\n" + } > "$tempEMailBodyMsg" + ;; + NEW_BM_BACKUP_FAILED) + { + echo + echo "Warning: Backup failed during firmware update process while Auto-Updating to: ${fwNewUpdateVersion} on ${MODEL_ID} router." + echo "Firmware update on ${MODEL_ID} router is now cancelled" + printf "\nPlease check backupmon.sh configuration and retry upgrade from:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; FAILED_FW_UPDATE_STATUS) @@ -1674,7 +1682,7 @@ _toggle_change_log_check_() { ;; esac else - printf "Are you sure you want to enable the Change-log verification check? [y/N]: " + printf "Are you sure you want to enable the change-log verification check? [y/N]: " read -r response case $response in [Yy]* ) @@ -2482,6 +2490,30 @@ Please manually update to version $minimum_supported_version or higher to use th return 1 fi fi + + ##---------------------------------------## + ## Added by ExtremeFiretop [2024-Jan-26] ## + ##---------------------------------------## + # Check for the presence of backupmon.sh script + if [ -f "/jffs/scripts/backupmon.sh" ]; then + # Execute the backup script if it exists + Say "\nBackup Started" + sh /jffs/scripts/backupmon.sh -backup >/dev/null + BE=$? + Say "Backup Finished\n" + if [ $BE -eq 0 ]; then + Say "Backup Completed Successfully\n" + else + Say "Backup Failed\n" + _SendEMailNotification_ NEW_BM_BACKUP_FAILED + _DoCleanUp_ 1 + _DoExit_ 1 + fi + else + # Print a message if the backup script is not installed + Say "Backup script (backupmon.sh) is not installed. Skipping backup.\n" + # Optionally, you can add additional handling here if needed + fi ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## From 8f81de51ed8b2174e0e753618a432fd19ce6ed4c Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 01:45:33 -0500 Subject: [PATCH 20/63] Update MerlinAU.sh --- MerlinAU.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 1b33e1d1..81290b48 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-Jan-25 +# Last Modified: 2024-Jan-26 ################################################################### set -u @@ -1012,9 +1012,9 @@ then find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi -##-------------------------------------## -## Added by Martinski W. [2024-Jan-24] ## -##-------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-26] ## +##------------------------------------------## _CreateEMailContent_() { if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi From 124c0d5a8bc8439a8fd9958737f989fbe013f87c Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 01:47:22 -0500 Subject: [PATCH 21/63] Update MerlinAU.sh --- MerlinAU.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 81290b48..d8052067 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2387,9 +2387,9 @@ Please manually update to version $minimum_supported_version or higher to use th # Navigate to the firmware directory cd "$FW_BIN_DIR" - ##---------------------------------------## - ## Added by ExtremeFiretop [2024-Jan-23] ## - ##---------------------------------------## + ##------------------------------------------## + ## Modified by ExtremeFiretop [2024-Jan-25] ## + ##------------------------------------------## local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$checkChangeLogSetting" = "ENABLED" ]; then From be69a50164c908d8b8c0be0b712fd12b34400843 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 03:21:41 -0500 Subject: [PATCH 22/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index d8052067..42dda2c6 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2497,7 +2497,7 @@ Please manually update to version $minimum_supported_version or higher to use th # Check for the presence of backupmon.sh script if [ -f "/jffs/scripts/backupmon.sh" ]; then # Execute the backup script if it exists - Say "\nBackup Started" + Say "\nBackup Started (by BACKUPMON)" sh /jffs/scripts/backupmon.sh -backup >/dev/null BE=$? Say "Backup Finished\n" From 6cd2f6bdf7097127be61ca0b8e9e00c326a284a1 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 04:43:04 -0500 Subject: [PATCH 23/63] Update MerlinAU.sh --- MerlinAU.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 42dda2c6..18d03428 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1298,8 +1298,6 @@ _AddPostUpdateEmailNotifyScriptHook_() then Say "Post-update email notification hook was added successfully to '$hookScriptFile' script." else Say "Post-update email notification hook already exists in '$hookScriptFile' script." fi - - "$isInteractive" && _WaitForEnterKey_ } ##----------------------------------------------## @@ -1980,7 +1978,9 @@ _CheckNewUpdateFirmwareNotification_() fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Vers "$fwNewUpdateNotificationVers" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" + if [ ! "$isInteractive" ]; then _SendEMailNotification_ NEW_FW_UPDATE_STATUS + fi fi fi @@ -1989,7 +1989,9 @@ _CheckNewUpdateFirmwareNotification_() then fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" + if [ ! "$isInteractive" ]; then _SendEMailNotification_ NEW_FW_UPDATE_STATUS + fi fi return 0 } @@ -2268,7 +2270,7 @@ Please manually update to version $minimum_supported_version or higher to use th then Say "No new firmware version update is found for [$PRODUCT_ID] router model." "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 + return 1 fi # Use set to read the output of the function into variables @@ -2316,7 +2318,7 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi - availableRAM_kb=$(_GetAvailableRAM_KB_) + availableRAM_kb=$(get_free_ram) Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2342,7 +2344,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-22] ## ##------------------------------------------## - availableRAM_kb=$(_GetAvailableRAM_KB_) + availableRAM_kb=$(get_free_ram) Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2494,6 +2496,10 @@ Please manually update to version $minimum_supported_version or higher to use th ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-26] ## ##---------------------------------------## + availableRAM_kb=$(get_free_ram) + Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" + check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" + # Check for the presence of backupmon.sh script if [ -f "/jffs/scripts/backupmon.sh" ]; then # Execute the backup script if it exists @@ -2511,14 +2517,14 @@ Please manually update to version $minimum_supported_version or higher to use th fi else # Print a message if the backup script is not installed - Say "Backup script (backupmon.sh) is not installed. Skipping backup.\n" + Say "Backup script (BACKUPMON) is not installed. Skipping backup.\n" # Optionally, you can add additional handling here if needed fi ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## ##----------------------------------------## - availableRAM_kb=$(_GetAvailableRAM_KB_) + availableRAM_kb=$(get_free_ram) Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" From 05fe298036930c65d44cee79f8999eb642d9f9a2 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 04:43:46 -0500 Subject: [PATCH 24/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 18d03428..0a6ee84b 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION=0.9.55 +readonly SCRIPT_VERSION=0.9.90 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## From 44e899573d5f81c74c59552e52cd4ec579c70644 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 14:25:13 -0500 Subject: [PATCH 25/63] Update MerlinAU.sh --- MerlinAU.sh | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 0a6ee84b..a22924e5 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -862,10 +862,7 @@ _Set_FW_UpdateLOG_DirectoryPath_() # Move any existing log files to new directory # mv -f "${FW_LOG_DIR}"/*.log "$newLogFileDirPath" 2>/dev/null # Remove now the obsolete directory path # - if [ "$FW_LOG_BASE_DIR" = "$FW_ZIP_BASE_DIR" ] - then rm -fr "$FW_LOG_DIR" - else rm -fr "${FW_LOG_BASE_DIR}/$ScriptFNameTag" - fi + rm -fr "$FW_LOG_DIR" # Update the log directory path after validation # Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$newLogBaseDirPath" echo "The directory path for the log files was updated successfully." @@ -939,10 +936,7 @@ _Set_FW_UpdateZIP_DirectoryPath_() return 1 fi # Remove now the obsolete directory path # - if [ "$FW_ZIP_BASE_DIR" = "$FW_LOG_BASE_DIR" ] - then rm -fr "$FW_ZIP_DIR" - else rm -fr "${FW_ZIP_BASE_DIR}/$ScriptFNameTag" - fi + rm -fr "$FW_ZIP_DIR" rm -f "${newZIP_FileDirPath}"/*.zip "${newZIP_FileDirPath}"/*.sha256 Update_Custom_Settings FW_New_Update_ZIP_Directory_Path "$newZIP_BaseDirPath" echo "The directory path for the F/W ZIP file was updated successfully." @@ -966,9 +960,9 @@ FW_BIN_BASE_DIR="/home/root" FW_ZIP_BASE_DIR="$(Get_Custom_Setting FW_New_Update_ZIP_Directory_Path)" FW_LOG_BASE_DIR="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" -readonly FW_LOG_SUBDIR="${ScriptFNameTag}/logs" -readonly FW_BIN_SUBDIR="${ScriptFNameTag}/$FW_FileName" -readonly FW_ZIP_SUBDIR="${ScriptFNameTag}/$FW_FileName" +readonly FW_LOG_SUBDIR="${ScriptFNameTag}.d/logs" +readonly FW_BIN_SUBDIR="${ScriptFNameTag}.d/$FW_FileName" +readonly FW_ZIP_SUBDIR="${ScriptFNameTag}.d/$FW_FileName" FW_BIN_DIR="${FW_BIN_BASE_DIR}/$FW_BIN_SUBDIR" FW_LOG_DIR="${FW_LOG_BASE_DIR}/$FW_LOG_SUBDIR" @@ -1012,6 +1006,15 @@ then find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi +if USBMountPoint="$(_GetDefaultUSBMountPoint_)" +then + mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null + rm -fr "$FW_LOG_DIR" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" +else + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" +fi + ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## @@ -1524,14 +1527,14 @@ _DoCleanUp_() # Move file temporarily to save it from deletion # "$keepZIPfile" && [ -f "$FW_ZIP_FPATH" ] && \ - mv -f "$FW_ZIP_FPATH" "${FW_ZIP_BASE_DIR}/$ScriptFNameTag" && moveZIPback=true + mv -f "$FW_ZIP_FPATH" "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}.d" && moveZIPback=true rm -f "${FW_ZIP_DIR}"/* "$delBINfiles" && rm -f "${FW_BIN_DIR}"/* # Move file back to original location # "$keepZIPfile" && "$moveZIPback" && \ - mv -f "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}/${FW_FileName}.zip" "$FW_ZIP_FPATH" + mv -f "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}.d/${FW_FileName}.zip" "$FW_ZIP_FPATH" if "$doTrace" then @@ -2165,13 +2168,6 @@ _EntwareServicesHandler_() # Embed functions from second script, modified as necessary. _RunFirmwareUpdateNow_() { - # Double-check the directory exists before using it # - [ ! -d "$FW_LOG_DIR" ] && mkdir -p -m 755 "$FW_LOG_DIR" - - # Set up the custom log file # - userLOGFile="${FW_LOG_DIR}/${MODEL_ID}_FW_Update_$(date '+%Y-%m-%d_%H_%M_%S').log" - touch "$userLOGFile" ## Must do this to indicate custom log file is enabled ## - # Check if the router model is supported OR if # it has the minimum firmware version supported. if [ "$ModelCheckFailed" != "0" ]; then @@ -2212,6 +2208,13 @@ Please manually update to version $minimum_supported_version or higher to use th "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" return 1 fi + + # Double-check the directory exists before using it # + [ ! -d "$FW_LOG_DIR" ] && mkdir -p -m 755 "$FW_LOG_DIR" + + # Set up the custom log file # + userLOGFile="${FW_LOG_DIR}/${MODEL_ID}_FW_Update_$(date '+%Y-%m-%d_%H_%M_%S').log" + touch "$userLOGFile" ## Must do this to indicate custom log file is enabled ## #---------------------------------------------------------# # If the expected directory path for the ZIP file is not @@ -2458,9 +2461,9 @@ Please manually update to version $minimum_supported_version or higher to use th Say "Pure Build selected for flashing" firmware_file="$pure_file" elif [ "$inMenuMode" = true ]; then - printf "\n ${REDct}Found ROG build: $rog_file.${NOct}" - printf "\n ${REDct}Would you like to use the ROG build?${NOct}\n" - printf "\n Enter your choice (y/n): " + printf "${REDct}Found ROG build: $rog_file.${NOct}\n" + printf "${REDct}Would you like to use the ROG build?${NOct}\n" + printf "Enter your choice (y/n): " read -r choice if [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then Say "ROG Build selected for flashing" @@ -2759,9 +2762,9 @@ _DoUninstall_() _DelPostUpdateEmailNotifyScriptHook_ if rm -fr "$SETTINGS_DIR" && \ - rm -fr "${FW_BIN_BASE_DIR}/$ScriptFNameTag" && \ - rm -fr "${FW_LOG_BASE_DIR}/$ScriptFNameTag" && \ - rm -fr "${FW_ZIP_BASE_DIR}/$ScriptFNameTag" && \ + rm -fr "${FW_BIN_BASE_DIR}/${ScriptFNameTag}.d" && \ + rm -fr "${FW_LOG_BASE_DIR}/${ScriptFNameTag}.d" && \ + rm -fr "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}.d" && \ rm -f "$ScriptFilePath" then Say "${GRNct}Successfully Uninstalled.${NOct}" From 41f249319323cc24326bb0fd76dcab3abb97e8d4 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 21:39:29 -0500 Subject: [PATCH 26/63] Update MerlinAU.sh --- MerlinAU.sh | 73 ++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index a22924e5..0a3be243 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -50,6 +50,9 @@ readonly SCRIPTS_PATH="/jffs/scripts" readonly SETTINGS_DIR="${ADDONS_PATH}/${ScriptFNameTag}.d" readonly SETTINGSFILE="${SETTINGS_DIR}/custom_settings.txt" readonly SCRIPTVERPATH="${SETTINGS_DIR}/version.txt" +USBConnected="${REDct}False${NOct}" # Default to False +readonly FW_Update_ZIP_DefaultSetupDIR="/home/root" # Default directory +readonly FW_Update_LOG_BASE_DefaultDIR="$ADDONS_PATH" # Default directory ##-------------------------------------## ## Added by Martinski W. [2024-Jan-24] ## @@ -518,28 +521,6 @@ _SCRIPTUPDATE_() fi } -##--------------------------------------## -## Added by Martinski W. [22023-Nov-24] ## -##--------------------------------------## -#---------------------------------------------------------# -# The USB-attached drives can have multiple partitions -# with different file systems (NTFS, ext3, ext4, etc.), -# which means that multiple mount points can be found. -# So for the purpose of choosing a default value here -# we will simply select the first mount point found. -# Users can later on change it by typing a different -# mount point path or directory using the Main Menu. -#---------------------------------------------------------# -_GetDefaultUSBMountPoint_() -{ - local mounPointPath retCode=0 - local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" - - mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" - [ -z "$mounPointPath" ] && retCode=1 - echo "$mounPointPath" ; return "$retCode" -} - ##-------------------------------------## ## Added by Martinski W. [2023-Dec-03] ## ##-------------------------------------## @@ -1006,15 +987,33 @@ then find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi -if USBMountPoint="$(_GetDefaultUSBMountPoint_)" -then - mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null - rm -fr "$FW_LOG_DIR" - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" +##-------------------------------------------## +## Modified by ExtremeFiretop [22023-Jan-26] ## +##-------------------------------------------## +#---------------------------------------------------------# +# The USB-attached drives can have multiple partitions +# with different file systems (NTFS, ext3, ext4, etc.), +# which means that multiple mount points can be found. +# So for the purpose of choosing a default value here +# we will simply select the first mount point found. +# Users can later on change it by typing a different +# mount point path or directory using the Main Menu. +#---------------------------------------------------------# +if USBMountPoint="$(_GetDefaultUSBMountPoint_)"; then + USBConnected="${GRNct}True${NOct}" + readonly FW_Update_ZIP_DefaultSetupDIR="$USBMountPoint" + readonly FW_Update_LOG_BASE_DefaultDIR="$USBMountPoint" + + # Actions specific to when USB is connected + mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null + rm -fr "$FW_LOG_DIR" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" else - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" + # Actions specific to when USB is not connected + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" fi + ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## @@ -2244,8 +2243,8 @@ Please manually update to version $minimum_supported_version or higher to use th ! _CreateDirectory_ "$FW_BIN_DIR" ; then return 1 ; fi # Get current firmware version # - current_version="$(_GetCurrentFWInstalledShortVersion_)" - ##FOR DEBUG ONLY##current_version="388.5.0" + ##FOR DEBUG ONLY##current_version="$(_GetCurrentFWInstalledShortVersion_)" + current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2268,13 +2267,13 @@ Please manually update to version $minimum_supported_version or higher to use th # "New F/W Release Version" from the router itself. # If no new F/W version update is available return. #------------------------------------------------------ - if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ - ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" - then - Say "No new firmware version update is found for [$PRODUCT_ID] router model." - "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 - fi + ##FOR DEBUG ONLY##if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ + ##FOR DEBUG ONLY## ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" + ##FOR DEBUG ONLY##then + ##FOR DEBUG ONLY## Say "No new firmware version update is found for [$PRODUCT_ID] router model." + ##FOR DEBUG ONLY## "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" + ##FOR DEBUG ONLY## return 1 + ##FOR DEBUG ONLY##fi # Use set to read the output of the function into variables set -- $(_GetLatestFWUpdateVersionFromWebsite_ "$FW_URL_RELEASE") From 8a00a7eece6c11b2c523d7631c80d5d723b3d6da Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 22:09:30 -0500 Subject: [PATCH 27/63] Update MerlinAU.sh --- MerlinAU.sh | 73 +++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 0a3be243..a22924e5 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -50,9 +50,6 @@ readonly SCRIPTS_PATH="/jffs/scripts" readonly SETTINGS_DIR="${ADDONS_PATH}/${ScriptFNameTag}.d" readonly SETTINGSFILE="${SETTINGS_DIR}/custom_settings.txt" readonly SCRIPTVERPATH="${SETTINGS_DIR}/version.txt" -USBConnected="${REDct}False${NOct}" # Default to False -readonly FW_Update_ZIP_DefaultSetupDIR="/home/root" # Default directory -readonly FW_Update_LOG_BASE_DefaultDIR="$ADDONS_PATH" # Default directory ##-------------------------------------## ## Added by Martinski W. [2024-Jan-24] ## @@ -521,6 +518,28 @@ _SCRIPTUPDATE_() fi } +##--------------------------------------## +## Added by Martinski W. [22023-Nov-24] ## +##--------------------------------------## +#---------------------------------------------------------# +# The USB-attached drives can have multiple partitions +# with different file systems (NTFS, ext3, ext4, etc.), +# which means that multiple mount points can be found. +# So for the purpose of choosing a default value here +# we will simply select the first mount point found. +# Users can later on change it by typing a different +# mount point path or directory using the Main Menu. +#---------------------------------------------------------# +_GetDefaultUSBMountPoint_() +{ + local mounPointPath retCode=0 + local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" + + mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" + [ -z "$mounPointPath" ] && retCode=1 + echo "$mounPointPath" ; return "$retCode" +} + ##-------------------------------------## ## Added by Martinski W. [2023-Dec-03] ## ##-------------------------------------## @@ -987,33 +1006,15 @@ then find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi -##-------------------------------------------## -## Modified by ExtremeFiretop [22023-Jan-26] ## -##-------------------------------------------## -#---------------------------------------------------------# -# The USB-attached drives can have multiple partitions -# with different file systems (NTFS, ext3, ext4, etc.), -# which means that multiple mount points can be found. -# So for the purpose of choosing a default value here -# we will simply select the first mount point found. -# Users can later on change it by typing a different -# mount point path or directory using the Main Menu. -#---------------------------------------------------------# -if USBMountPoint="$(_GetDefaultUSBMountPoint_)"; then - USBConnected="${GRNct}True${NOct}" - readonly FW_Update_ZIP_DefaultSetupDIR="$USBMountPoint" - readonly FW_Update_LOG_BASE_DefaultDIR="$USBMountPoint" - - # Actions specific to when USB is connected - mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null - rm -fr "$FW_LOG_DIR" - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" +if USBMountPoint="$(_GetDefaultUSBMountPoint_)" +then + mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null + rm -fr "$FW_LOG_DIR" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" else - # Actions specific to when USB is not connected - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" fi - ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## @@ -2243,8 +2244,8 @@ Please manually update to version $minimum_supported_version or higher to use th ! _CreateDirectory_ "$FW_BIN_DIR" ; then return 1 ; fi # Get current firmware version # - ##FOR DEBUG ONLY##current_version="$(_GetCurrentFWInstalledShortVersion_)" - current_version="388.5.0" + current_version="$(_GetCurrentFWInstalledShortVersion_)" + ##FOR DEBUG ONLY##current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2267,13 +2268,13 @@ Please manually update to version $minimum_supported_version or higher to use th # "New F/W Release Version" from the router itself. # If no new F/W version update is available return. #------------------------------------------------------ - ##FOR DEBUG ONLY##if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ - ##FOR DEBUG ONLY## ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" - ##FOR DEBUG ONLY##then - ##FOR DEBUG ONLY## Say "No new firmware version update is found for [$PRODUCT_ID] router model." - ##FOR DEBUG ONLY## "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - ##FOR DEBUG ONLY## return 1 - ##FOR DEBUG ONLY##fi + if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ + ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" + then + Say "No new firmware version update is found for [$PRODUCT_ID] router model." + "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" + return 1 + fi # Use set to read the output of the function into variables set -- $(_GetLatestFWUpdateVersionFromWebsite_ "$FW_URL_RELEASE") From 09f63f27ef8e6eaa860a4f1d9d44b6ec8a41dbe4 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 22:36:10 -0500 Subject: [PATCH 28/63] Update MerlinAU.sh --- MerlinAU.sh | 100 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 31 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index a22924e5..fe6dbe15 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -211,12 +211,40 @@ Toggle_LEDs_PID="" FW_UpdateCheckState="TBD" FW_UpdateCheckScript="/usr/sbin/webs_update.sh" + +##--------------------------------------## +## Added by Martinski W. [22023-Nov-24] ## +##--------------------------------------## +#---------------------------------------------------------# +# The USB-attached drives can have multiple partitions +# with different file systems (NTFS, ext3, ext4, etc.), +# which means that multiple mount points can be found. +# So for the purpose of choosing a default value here +# we will simply select the first mount point found. +# Users can later on change it by typing a different +# mount point path or directory using the Main Menu. +#---------------------------------------------------------# +_GetDefaultUSBMountPoint_() +{ + local mounPointPath retCode=0 + local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" + + mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" + [ -z "$mounPointPath" ] && retCode=1 + echo "$mounPointPath" ; return "$retCode" +} + ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-21] ## ##---------------------------------------## _migrate_settings_() { + local USBMountPoint="$(_GetDefaultUSBMountPoint_)" local old_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}" local new_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}.d" + local old_bin_dir="/home/root/${ScriptFNameTag}" + local new_bin_dir="/home/root/${ScriptFNameTag}.d" + local old_mnt_dir="${USBMountPoint}/${ScriptFNameTag}" + local new_mnt_dir="${USBMountPoint}/${ScriptFNameTag}.d" # Check if the old settings directory exists if [ -d "$old_settings_dir" ]; then @@ -233,6 +261,38 @@ _migrate_settings_() { fi fi fi + + # Check if the old settings directory exists + if [ -d "$old_bin_dir" ]; then + # Check if the new settings directory already exists + if [ -d "$new_bin_dir" ]; then + echo "The new settings directory already exists. Migration is not required." + else + # Move the old settings directory to the new location + mv "$old_bin_dir" "$new_bin_dir" + if [ $? -eq 0 ]; then + echo "Settings directory successfully migrated to the new location." + else + echo "Error occurred during migration of the settings directory." + fi + fi + fi + + # Check if the old settings directory exists + if [ -d "$old_mnt_dir" ]; then + # Check if the new settings directory already exists + if [ -d "$new_mnt_dir" ]; then + echo "The new settings directory already exists. Migration is not required." + else + # Move the old settings directory to the new location + mv "$old_mnt_dir" "$new_mnt_dir" + if [ $? -eq 0 ]; then + echo "Settings directory successfully migrated to the new location." + else + echo "Error occurred during migration of the settings directory." + fi + fi + fi } _migrate_settings_ @@ -518,28 +578,6 @@ _SCRIPTUPDATE_() fi } -##--------------------------------------## -## Added by Martinski W. [22023-Nov-24] ## -##--------------------------------------## -#---------------------------------------------------------# -# The USB-attached drives can have multiple partitions -# with different file systems (NTFS, ext3, ext4, etc.), -# which means that multiple mount points can be found. -# So for the purpose of choosing a default value here -# we will simply select the first mount point found. -# Users can later on change it by typing a different -# mount point path or directory using the Main Menu. -#---------------------------------------------------------# -_GetDefaultUSBMountPoint_() -{ - local mounPointPath retCode=0 - local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" - - mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" - [ -z "$mounPointPath" ] && retCode=1 - echo "$mounPointPath" ; return "$retCode" -} - ##-------------------------------------## ## Added by Martinski W. [2023-Dec-03] ## ##-------------------------------------## @@ -2244,8 +2282,8 @@ Please manually update to version $minimum_supported_version or higher to use th ! _CreateDirectory_ "$FW_BIN_DIR" ; then return 1 ; fi # Get current firmware version # - current_version="$(_GetCurrentFWInstalledShortVersion_)" - ##FOR DEBUG ONLY##current_version="388.5.0" + ##FOR DEBUG ONLY##current_version="$(_GetCurrentFWInstalledShortVersion_)" + current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2268,13 +2306,13 @@ Please manually update to version $minimum_supported_version or higher to use th # "New F/W Release Version" from the router itself. # If no new F/W version update is available return. #------------------------------------------------------ - if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ - ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" - then - Say "No new firmware version update is found for [$PRODUCT_ID] router model." - "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 - fi + ##FOR DEBUG ONLY##if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ + ##FOR DEBUG ONLY## ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" + ##FOR DEBUG ONLY##then + ##FOR DEBUG ONLY## Say "No new firmware version update is found for [$PRODUCT_ID] router model." + ##FOR DEBUG ONLY## "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" + ##FOR DEBUG ONLY## return 1 + ##FOR DEBUG ONLY##fi # Use set to read the output of the function into variables set -- $(_GetLatestFWUpdateVersionFromWebsite_ "$FW_URL_RELEASE") From a8b2e5b7692b880f90bfdeca880131c785cd0ee4 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 22:37:32 -0500 Subject: [PATCH 29/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index fe6dbe15..280c74d9 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -238,7 +238,7 @@ _GetDefaultUSBMountPoint_() ## Added by ExtremeFiretop [2024-Jan-21] ## ##---------------------------------------## _migrate_settings_() { - local USBMountPoint="$(_GetDefaultUSBMountPoint_)" + local USBMountPoint="$(_GetDefaultUSBMountPoint_)" local old_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}" local new_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}.d" local old_bin_dir="/home/root/${ScriptFNameTag}" From 2cbbc05b8cac00fd21edb41fe2be367e8afd0db7 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Fri, 26 Jan 2024 22:44:57 -0500 Subject: [PATCH 30/63] Update MerlinAU.sh --- MerlinAU.sh | 65 ++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 280c74d9..498c951a 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION=0.9.90 +readonly SCRIPT_VERSION=0.9.92 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -234,9 +234,9 @@ _GetDefaultUSBMountPoint_() echo "$mounPointPath" ; return "$retCode" } -##---------------------------------------## -## Added by ExtremeFiretop [2024-Jan-21] ## -##---------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-26] ## +##------------------------------------------## _migrate_settings_() { local USBMountPoint="$(_GetDefaultUSBMountPoint_)" local old_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}" @@ -829,9 +829,9 @@ Update_Custom_Settings() esac } -##----------------------------------------## -## Modified by Martinski W. [2023-Dec-22] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-24] ## +##------------------------------------------## _Set_FW_UpdateLOG_DirectoryPath_() { local newLogBaseDirPath="$FW_LOG_BASE_DIR" newLogFileDirPath="" @@ -909,9 +909,9 @@ _Set_FW_UpdateLOG_DirectoryPath_() return 0 } -##----------------------------------------## -## Modified by Martinski W. [2023-Dec-01] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-24] ## +##------------------------------------------## _Set_FW_UpdateZIP_DirectoryPath_() { local newZIP_BaseDirPath="$FW_ZIP_BASE_DIR" newZIP_FileDirPath="" @@ -985,9 +985,9 @@ _Set_FW_UpdateZIP_DirectoryPath_() _Init_Custom_Settings_Config_ -##----------------------------------------## -## Modified by Martinski W. [2023-Dec-01] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-24] ## +##------------------------------------------## # NOTE: # Depending on available RAM & storage capacity of the # target router, it may be required to have USB-attached @@ -1044,6 +1044,9 @@ then find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi +##---------------------------------------## +## Added by ExtremeFiretop [2024-Jan-24] ## +##---------------------------------------## if USBMountPoint="$(_GetDefaultUSBMountPoint_)" then mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null @@ -1542,9 +1545,9 @@ check_memory_and_prompt_reboot() { fi } -##----------------------------------------## -## Modified by Martinski W. [2023-Dec-26] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-24] ## +##------------------------------------------## _DoCleanUp_() { local delBINfiles=false keepZIPfile=false moveZIPback=false @@ -1983,9 +1986,9 @@ _Set_FW_UpdateCronSchedule_() return "$retCode" } -##----------------------------------------## -## Modified by Martinski W. [2024-Jan-24] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-24] ## +##------------------------------------------## _CheckNewUpdateFirmwareNotification_() { if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] @@ -2282,8 +2285,8 @@ Please manually update to version $minimum_supported_version or higher to use th ! _CreateDirectory_ "$FW_BIN_DIR" ; then return 1 ; fi # Get current firmware version # - ##FOR DEBUG ONLY##current_version="$(_GetCurrentFWInstalledShortVersion_)" - current_version="388.5.0" + current_version="$(_GetCurrentFWInstalledShortVersion_)" + ##FOR DEBUG ONLY##current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2306,13 +2309,13 @@ Please manually update to version $minimum_supported_version or higher to use th # "New F/W Release Version" from the router itself. # If no new F/W version update is available return. #------------------------------------------------------ - ##FOR DEBUG ONLY##if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ - ##FOR DEBUG ONLY## ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" - ##FOR DEBUG ONLY##then - ##FOR DEBUG ONLY## Say "No new firmware version update is found for [$PRODUCT_ID] router model." - ##FOR DEBUG ONLY## "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - ##FOR DEBUG ONLY## return 1 - ##FOR DEBUG ONLY##fi + if ! release_version="$(_GetLatestFWUpdateVersionFromRouter_)" || \ + ! _CheckNewUpdateFirmwareNotification_ "$current_version" "$release_version" + then + Say "No new firmware version update is found for [$PRODUCT_ID] router model." + "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" + return 1 + fi # Use set to read the output of the function into variables set -- $(_GetLatestFWUpdateVersionFromWebsite_ "$FW_URL_RELEASE") @@ -2786,9 +2789,9 @@ _AddCronJobRunScriptHook_() fi } -##----------------------------------------## -## Modified by Martinski W. [2024-Jan-24] ## -##----------------------------------------## +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-24] ## +##------------------------------------------## _DoUninstall_() { printf "Are you sure you want to uninstall $ScriptFileName script now" From 5b2a09c229a3264216de665265351f5d82a10aba Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 00:06:07 -0500 Subject: [PATCH 31/63] Update MerlinAU.sh --- MerlinAU.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 498c951a..6576872d 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2591,8 +2591,19 @@ Please manually update to version $minimum_supported_version or higher to use th "$isInteractive" && printf "\nRestarting web server... Please wait.\n" /sbin/service restart_httpd && sleep 5 - _EntwareServicesHandler_ stop + #Send last email notification before flash _SendEMailNotification_ START_FW_UPDATE_STATUS + #Stop entware services before flash + _EntwareServicesHandler_ stop + + # Check if '/opt/bin/diversion' exists + if [ -f /opt/bin/diversion ]; then + #Stop Divsersion services before flash + Say "Stopping Diversion service..." + /opt/bin/diversion unmount + else + Say "Diversion service not installed." + fi curl_response="$(curl "${routerURLstr}/login.cgi" \ --referer ${routerURLstr}/Main_Login.asp \ From fe9660509bedeabf93753b9f15552a0035869f74 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 00:07:16 -0500 Subject: [PATCH 32/63] Update MerlinAU.sh --- MerlinAU.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 6576872d..fdc65b59 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2593,8 +2593,6 @@ Please manually update to version $minimum_supported_version or higher to use th #Send last email notification before flash _SendEMailNotification_ START_FW_UPDATE_STATUS - #Stop entware services before flash - _EntwareServicesHandler_ stop # Check if '/opt/bin/diversion' exists if [ -f /opt/bin/diversion ]; then @@ -2604,6 +2602,9 @@ Please manually update to version $minimum_supported_version or higher to use th else Say "Diversion service not installed." fi + + #Stop entware services before flash + _EntwareServicesHandler_ stop curl_response="$(curl "${routerURLstr}/login.cgi" \ --referer ${routerURLstr}/Main_Login.asp \ From a4580e7cc6b7a2a4b567ac80a0b70374ee1a6697 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 00:08:38 -0500 Subject: [PATCH 33/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index fdc65b59..35eae4aa 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2603,7 +2603,7 @@ Please manually update to version $minimum_supported_version or higher to use th Say "Diversion service not installed." fi - #Stop entware services before flash + #Stop entware services before flash _EntwareServicesHandler_ stop curl_response="$(curl "${routerURLstr}/login.cgi" \ From 78b3dbdf907bdfbb75c5909d05b1993850db5f13 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 04:09:20 -0500 Subject: [PATCH 34/63] Update MerlinAU.sh --- MerlinAU.sh | 160 +++++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 77 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 35eae4aa..f357ccc7 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -234,69 +234,6 @@ _GetDefaultUSBMountPoint_() echo "$mounPointPath" ; return "$retCode" } -##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-26] ## -##------------------------------------------## -_migrate_settings_() { - local USBMountPoint="$(_GetDefaultUSBMountPoint_)" - local old_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}" - local new_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}.d" - local old_bin_dir="/home/root/${ScriptFNameTag}" - local new_bin_dir="/home/root/${ScriptFNameTag}.d" - local old_mnt_dir="${USBMountPoint}/${ScriptFNameTag}" - local new_mnt_dir="${USBMountPoint}/${ScriptFNameTag}.d" - - # Check if the old settings directory exists - if [ -d "$old_settings_dir" ]; then - # Check if the new settings directory already exists - if [ -d "$new_settings_dir" ]; then - echo "The new settings directory already exists. Migration is not required." - else - # Move the old settings directory to the new location - mv "$old_settings_dir" "$new_settings_dir" - if [ $? -eq 0 ]; then - echo "Settings directory successfully migrated to the new location." - else - echo "Error occurred during migration of the settings directory." - fi - fi - fi - - # Check if the old settings directory exists - if [ -d "$old_bin_dir" ]; then - # Check if the new settings directory already exists - if [ -d "$new_bin_dir" ]; then - echo "The new settings directory already exists. Migration is not required." - else - # Move the old settings directory to the new location - mv "$old_bin_dir" "$new_bin_dir" - if [ $? -eq 0 ]; then - echo "Settings directory successfully migrated to the new location." - else - echo "Error occurred during migration of the settings directory." - fi - fi - fi - - # Check if the old settings directory exists - if [ -d "$old_mnt_dir" ]; then - # Check if the new settings directory already exists - if [ -d "$new_mnt_dir" ]; then - echo "The new settings directory already exists. Migration is not required." - else - # Move the old settings directory to the new location - mv "$old_mnt_dir" "$new_mnt_dir" - if [ $? -eq 0 ]; then - echo "Settings directory successfully migrated to the new location." - else - echo "Error occurred during migration of the settings directory." - fi - fi - fi -} - -_migrate_settings_ - ##----------------------------------------## ## Modified by Martinski W. [2023-Dec-22] ## ##----------------------------------------## @@ -829,6 +766,69 @@ Update_Custom_Settings() esac } +##------------------------------------------## +## Modified by ExtremeFiretop [2024-Jan-26] ## +##------------------------------------------## +_migrate_settings_() { + local USBMountPoint="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" + local old_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}" + local new_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}.d" + local old_bin_dir="/home/root/${ScriptFNameTag}" + local new_bin_dir="/home/root/${ScriptFNameTag}.d" + local old_mnt_dir="${USBMountPoint}/${ScriptFNameTag}" + local new_mnt_dir="${USBMountPoint}/${ScriptFNameTag}.d" + + # Check if the old settings directory exists + if [ -d "$old_settings_dir" ]; then + # Check if the new settings directory already exists + if [ -d "$new_settings_dir" ]; then + echo "The new settings directory already exists. Migration is not required." + else + # Move the old settings directory to the new location + mv "$old_settings_dir" "$new_settings_dir" + if [ $? -eq 0 ]; then + echo "Settings directory successfully migrated to the new location." + else + echo "Error occurred during migration of the settings directory." + fi + fi + fi + + # Check if the old settings directory exists + if [ -d "$old_bin_dir" ]; then + # Check if the new settings directory already exists + if [ -d "$new_bin_dir" ]; then + echo "The new settings directory already exists. Migration is not required." + else + # Move the old settings directory to the new location + mv "$old_bin_dir" "$new_bin_dir" + if [ $? -eq 0 ]; then + echo "Settings directory successfully migrated to the new location." + else + echo "Error occurred during migration of the settings directory." + fi + fi + fi + + # Check if the old settings directory exists + if [ -d "$old_mnt_dir" ]; then + # Check if the new settings directory already exists + if [ -d "$new_mnt_dir" ]; then + echo "The new settings directory already exists. Migration is not required." + else + # Move the old settings directory to the new location + mv "$old_mnt_dir" "$new_mnt_dir" + if [ $? -eq 0 ]; then + echo "Settings directory successfully migrated to the new location." + else + echo "Error occurred during migration of the settings directory." + fi + fi + fi +} + +_migrate_settings_ + ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-24] ## ##------------------------------------------## @@ -1047,6 +1047,14 @@ fi ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-24] ## ##---------------------------------------## +#This vode is incase a no USBs are mounted anymore (Zero Default USB Mounts). +#If the USB is selected as the log location and it goes offline, any "Say" command creates a mnt directory. +#In such a case were the USB is unmounted. We need to change the log directory back to a local directory. +#Second part of else statement executes first, and updates it local jffs for logs if no USBs are found. +#if ANY DefaultUSBMountPoint found, then move the log files from their local jffs location to the default mount location. +#We don't know the user selected yet because it's local at this time and was changed by the else statement. +#Remove the old log directory location from jffs, and update the settings file again to the new default again. +#This creates a semi-perminant switch which can reset back to default if no USBmountpoints are valid anymore. if USBMountPoint="$(_GetDefaultUSBMountPoint_)" then mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null @@ -2022,9 +2030,7 @@ _CheckNewUpdateFirmwareNotification_() fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Vers "$fwNewUpdateNotificationVers" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" - if [ ! "$isInteractive" ]; then _SendEMailNotification_ NEW_FW_UPDATE_STATUS - fi fi fi @@ -2033,9 +2039,7 @@ _CheckNewUpdateFirmwareNotification_() then fwNewUpdateNotificationDate="$(date +"$FW_UpdateNotificationDateFormat")" Update_Custom_Settings FW_New_Update_Notification_Date "$fwNewUpdateNotificationDate" - if [ ! "$isInteractive" ]; then _SendEMailNotification_ NEW_FW_UPDATE_STATUS - fi fi return 0 } @@ -2362,8 +2366,9 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi - availableRAM_kb=$(get_free_ram) - Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" + freeRAM_kb=$(get_free_ram) + availableRAM_kb=$(_GetAvailableRAM_KB_) + Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Compare versions before deciding to download @@ -2388,8 +2393,9 @@ Please manually update to version $minimum_supported_version or higher to use th ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-22] ## ##------------------------------------------## - availableRAM_kb=$(get_free_ram) - Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" + freeRAM_kb=$(get_free_ram) + availableRAM_kb=$(_GetAvailableRAM_KB_) + Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Extracting the firmware binary image # @@ -2540,8 +2546,9 @@ Please manually update to version $minimum_supported_version or higher to use th ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-26] ## ##---------------------------------------## - availableRAM_kb=$(get_free_ram) - Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" + freeRAM_kb=$(get_free_ram) + availableRAM_kb=$(_GetAvailableRAM_KB_) + Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Check for the presence of backupmon.sh script @@ -2568,8 +2575,9 @@ Please manually update to version $minimum_supported_version or higher to use th ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## ##----------------------------------------## - availableRAM_kb=$(get_free_ram) - Say "Required RAM: ${required_space_kb} KB - Available RAM: ${availableRAM_kb} KB" + freeRAM_kb=$(get_free_ram) + availableRAM_kb=$(_GetAvailableRAM_KB_) + Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" routerURLstr="$(_GetRouterURL_)" @@ -2599,8 +2607,6 @@ Please manually update to version $minimum_supported_version or higher to use th #Stop Divsersion services before flash Say "Stopping Diversion service..." /opt/bin/diversion unmount - else - Say "Diversion service not installed." fi #Stop entware services before flash From 75d5c81987010c3c4343d37b00220af69bcd49fb Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 04:16:33 -0500 Subject: [PATCH 35/63] Update MerlinAU.sh --- MerlinAU.sh | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index f357ccc7..b6251dba 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1047,7 +1047,7 @@ fi ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-24] ## ##---------------------------------------## -#This vode is incase a no USBs are mounted anymore (Zero Default USB Mounts). +#This code is incase a no USBs are mounted anymore (Zero Default USB Mounts). #If the USB is selected as the log location and it goes offline, any "Say" command creates a mnt directory. #In such a case were the USB is unmounted. We need to change the log directory back to a local directory. #Second part of else statement executes first, and updates it local jffs for logs if no USBs are found. @@ -1554,7 +1554,7 @@ check_memory_and_prompt_reboot() { } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-24] ## +## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## _DoCleanUp_() { @@ -1995,7 +1995,7 @@ _Set_FW_UpdateCronSchedule_() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-24] ## +## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## _CheckNewUpdateFirmwareNotification_() { @@ -2551,26 +2551,25 @@ Please manually update to version $minimum_supported_version or higher to use th Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" - # Check for the presence of backupmon.sh script - if [ -f "/jffs/scripts/backupmon.sh" ]; then - # Execute the backup script if it exists - Say "\nBackup Started (by BACKUPMON)" - sh /jffs/scripts/backupmon.sh -backup >/dev/null - BE=$? - Say "Backup Finished\n" - if [ $BE -eq 0 ]; then - Say "Backup Completed Successfully\n" - else - Say "Backup Failed\n" - _SendEMailNotification_ NEW_BM_BACKUP_FAILED - _DoCleanUp_ 1 - _DoExit_ 1 - fi - else - # Print a message if the backup script is not installed - Say "Backup script (BACKUPMON) is not installed. Skipping backup.\n" - # Optionally, you can add additional handling here if needed - fi + # Check for the presence of backupmon.sh script (Commented out until issues resolved) + #if [ -f "/jffs/scripts/backupmon.sh" ]; then + # # Execute the backup script if it exists + # Say "\nBackup Started (by BACKUPMON)" + # sh /jffs/scripts/backupmon.sh -backup >/dev/null + # BE=$? + # Say "Backup Finished\n" + # if [ $BE -eq 0 ]; then + # Say "Backup Completed Successfully\n" + # else + # Say "Backup Failed\n" + # _SendEMailNotification_ NEW_BM_BACKUP_FAILED + # _DoCleanUp_ 1 + # _DoExit_ 1 + # fi + #else + # # Print a message if the backup script is not installed + # Say "Backup script (BACKUPMON) is not installed. Skipping backup.\n" + #fi ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## @@ -2808,7 +2807,7 @@ _AddCronJobRunScriptHook_() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-24] ## +## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## _DoUninstall_() { From aea737feddec28d6b3ab95c9102456593dfaa551 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 04:18:40 -0500 Subject: [PATCH 36/63] Update MerlinAU.sh --- MerlinAU.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b6251dba..cb06e6dd 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2366,7 +2366,7 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi - freeRAM_kb=$(get_free_ram) + freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2393,7 +2393,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-22] ## ##------------------------------------------## - freeRAM_kb=$(get_free_ram) + freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2546,7 +2546,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-26] ## ##---------------------------------------## - freeRAM_kb=$(get_free_ram) + freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2574,7 +2574,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## ##----------------------------------------## - freeRAM_kb=$(get_free_ram) + freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" From 6c0a3445e053186db60bd9c2f54616b8e286997b Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 05:01:26 -0500 Subject: [PATCH 37/63] Update MerlinAU.sh --- MerlinAU.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index cb06e6dd..6743242e 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1047,22 +1047,25 @@ fi ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-24] ## ##---------------------------------------## -#This code is incase a no USBs are mounted anymore (Zero Default USB Mounts). +#This code is incase the user selected USB mount isn't available anymore. #If the USB is selected as the log location and it goes offline, any "Say" command creates a mnt directory. #In such a case were the USB is unmounted. We need to change the log directory back to a local directory. -#Second part of else statement executes first, and updates it local jffs for logs if no USBs are found. +#First if statement executes first, and updates it local jffs for logs if no USBs are found. #if ANY DefaultUSBMountPoint found, then move the log files from their local jffs location to the default mount location. #We don't know the user selected yet because it's local at this time and was changed by the else statement. #Remove the old log directory location from jffs, and update the settings file again to the new default again. -#This creates a semi-perminant switch which can reset back to default if no USBmountpoints are valid anymore. +#This creates a semi-perminant switch which can reset back to default if no the user selected mount points aren't valid anymore. +UserSelectedMntPnt="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" +if [ ! -d "$UserSelectedMntPnt" ] || [ ! -r "$UserSelectedMntPnt" ]; then + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" +fi + if USBMountPoint="$(_GetDefaultUSBMountPoint_)" then mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null rm -fr "$FW_LOG_DIR" Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" -else - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" -fi +fin ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-26] ## From 04b486634c33dd5768afa1a5c4d950e052a4ff56 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 12:56:38 -0500 Subject: [PATCH 38/63] Update MerlinAU.sh --- MerlinAU.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 6743242e..d641f137 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1065,7 +1065,7 @@ then mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null rm -fr "$FW_LOG_DIR" Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" -fin +fi ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-26] ## @@ -2321,7 +2321,7 @@ Please manually update to version $minimum_supported_version or higher to use th then Say "No new firmware version update is found for [$PRODUCT_ID] router model." "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 + return 1 fi # Use set to read the output of the function into variables @@ -2601,12 +2601,12 @@ Please manually update to version $minimum_supported_version or higher to use th "$isInteractive" && printf "\nRestarting web server... Please wait.\n" /sbin/service restart_httpd && sleep 5 - #Send last email notification before flash + #Send last email notification before flash _SendEMailNotification_ START_FW_UPDATE_STATUS # Check if '/opt/bin/diversion' exists if [ -f /opt/bin/diversion ]; then - #Stop Divsersion services before flash + #Stop Divsersion services before flash Say "Stopping Diversion service..." /opt/bin/diversion unmount fi From 362c4145d7655c945e93317399e8394f169afd99 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 13:09:53 -0500 Subject: [PATCH 39/63] Update MerlinAU.sh --- MerlinAU.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index d641f137..81557f46 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2371,7 +2371,7 @@ Please manually update to version $minimum_supported_version or higher to use th freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) - Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" + Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Compare versions before deciding to download @@ -2398,7 +2398,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##------------------------------------------## freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) - Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" + Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Extracting the firmware binary image # @@ -2551,7 +2551,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##---------------------------------------## freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) - Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" + Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Check for the presence of backupmon.sh script (Commented out until issues resolved) @@ -2579,7 +2579,7 @@ Please manually update to version $minimum_supported_version or higher to use th ##----------------------------------------## freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) - Say "Required RAM: ${required_space_kb} KB - System RAM Available: ${availableRAM_kb} KB - WebUI RAM Free: ${freeRAM_kb} KB" + Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" routerURLstr="$(_GetRouterURL_)" From d9c8c8a8f3e4b6a29f5441bab4b069f128518256 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sat, 27 Jan 2024 11:49:57 -0800 Subject: [PATCH 40/63] Update MerlinAU.sh Very minor changes to email message to keep consistent wording & formatting. --- MerlinAU.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 6a548c81..997d1d98 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-Jan-25 +# Last Modified: 2024-Jan-27 ################################################################### set -u -readonly SCRIPT_VERSION=0.9.55 +readonly SCRIPT_VERSION=0.9.56 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -1054,8 +1054,9 @@ _CreateEMailContent_() STOP_FW_UPDATE_APPROVAL) { echo - echo "Warning: Found high-risk phrases in the change-logs while Auto-Updating to: $fwNewUpdateVersion on $MODEL_ID router." - printf "\nPlease run script interactively to approve this upgrade from:\n${fwInstalledVersion}\n\n" + echo "WARNING:" + echo "Found high-risk phrases in the change-logs while Auto-Updating to version ${fwNewUpdateVersion} on the ${MODEL_ID} router." + printf "\nPlease run script interactively to approve this F/W Update from current version:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; FAILED_FW_UPDATE_STATUS) From ae72854e73998ff24d3e7cac99dccce8c02490a5 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:57:05 -0800 Subject: [PATCH 41/63] Update MerlinAU.sh Some code cleanup & improvements. --- MerlinAU.sh | 225 +++++++++++++++++++++++++++------------------------- 1 file changed, 117 insertions(+), 108 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index aa7ad5ef..20112543 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION=0.9.92 +readonly SCRIPT_VERSION=0.9.93 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -32,6 +32,7 @@ ModelCheckFailed=0 readonly ScriptFileName="${0##*/}" readonly ScriptFNameTag="${ScriptFileName%%.*}" +readonly ScriptDirNameD="${ScriptFNameTag}.d" ScriptsDirPath="$(/usr/bin/dirname "$0")" if [ "$ScriptsDirPath" != "." ] @@ -47,7 +48,7 @@ fi ##------------------------------------------## readonly ADDONS_PATH="/jffs/addons" readonly SCRIPTS_PATH="/jffs/scripts" -readonly SETTINGS_DIR="${ADDONS_PATH}/${ScriptFNameTag}.d" +readonly SETTINGS_DIR="${ADDONS_PATH}/$ScriptDirNameD" readonly SETTINGSFILE="${SETTINGS_DIR}/custom_settings.txt" readonly SCRIPTVERPATH="${SETTINGS_DIR}/version.txt" @@ -211,7 +212,6 @@ Toggle_LEDs_PID="" FW_UpdateCheckState="TBD" FW_UpdateCheckScript="/usr/sbin/webs_update.sh" - ##--------------------------------------## ## Added by Martinski W. [22023-Nov-24] ## ##--------------------------------------## @@ -771,57 +771,57 @@ Update_Custom_Settings() ##------------------------------------------## _migrate_settings_() { local USBMountPoint="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" - local old_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}" - local new_settings_dir="${ADDONS_PATH}/${ScriptFNameTag}.d" - local old_bin_dir="/home/root/${ScriptFNameTag}" - local new_bin_dir="/home/root/${ScriptFNameTag}.d" - local old_mnt_dir="${USBMountPoint}/${ScriptFNameTag}" - local new_mnt_dir="${USBMountPoint}/${ScriptFNameTag}.d" - - # Check if the old settings directory exists + local old_settings_dir="${ADDONS_PATH}/$ScriptFNameTag" + local new_settings_dir="${ADDONS_PATH}/$ScriptDirNameD" + local old_bin_dir="/home/root/$ScriptFNameTag" + local new_bin_dir="/home/root/$ScriptDirNameD" + local old_log_dir="${USBMountPoint}/$ScriptFNameTag" + local new_log_dir="${USBMountPoint}/$ScriptDirNameD" + + # Check if the old SETTINGS directory exists # if [ -d "$old_settings_dir" ]; then - # Check if the new settings directory already exists + # Check if the new SETTINGS directory already exists if [ -d "$new_settings_dir" ]; then - echo "The new settings directory already exists. Migration is not required." + echo "The new SETTINGS directory already exists. Migration is not required." else - # Move the old settings directory to the new location + # Move the old SETTINGS directory to the new location mv "$old_settings_dir" "$new_settings_dir" if [ $? -eq 0 ]; then - echo "Settings directory successfully migrated to the new location." + echo "SETTINGS directory successfully migrated to the new location." else - echo "Error occurred during migration of the settings directory." + echo "Error occurred during migration of the SETTINGS directory." fi fi fi - - # Check if the old settings directory exists + + # Check if the old BIN directory exists # if [ -d "$old_bin_dir" ]; then - # Check if the new settings directory already exists + # Check if the new BIN directory already exists if [ -d "$new_bin_dir" ]; then - echo "The new settings directory already exists. Migration is not required." + echo "The new BIN directory already exists. Migration is not required." else - # Move the old settings directory to the new location + # Move the old BIN directory to the new location mv "$old_bin_dir" "$new_bin_dir" if [ $? -eq 0 ]; then - echo "Settings directory successfully migrated to the new location." + echo "BIN directory successfully migrated to the new location." else - echo "Error occurred during migration of the settings directory." + echo "Error occurred during migration of the BIN directory." fi fi fi - - # Check if the old settings directory exists - if [ -d "$old_mnt_dir" ]; then - # Check if the new settings directory already exists - if [ -d "$new_mnt_dir" ]; then - echo "The new settings directory already exists. Migration is not required." + + # Check if the old LOG directory exists # + if [ -d "$old_log_dir" ]; then + # Check if the new LOG directory already exists + if [ -d "$new_log_dir" ]; then + echo "The new LOG directory already exists. Migration is not required." else - # Move the old settings directory to the new location - mv "$old_mnt_dir" "$new_mnt_dir" + # Move the old LOG directory to the new location + mv "$old_log_dir" "$new_log_dir" if [ $? -eq 0 ]; then - echo "Settings directory successfully migrated to the new location." + echo "LOG directory successfully migrated to the new location." else - echo "Error occurred during migration of the settings directory." + echo "Error occurred during migration of the LOG directory." fi fi fi @@ -998,9 +998,9 @@ FW_BIN_BASE_DIR="/home/root" FW_ZIP_BASE_DIR="$(Get_Custom_Setting FW_New_Update_ZIP_Directory_Path)" FW_LOG_BASE_DIR="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" -readonly FW_LOG_SUBDIR="${ScriptFNameTag}.d/logs" -readonly FW_BIN_SUBDIR="${ScriptFNameTag}.d/$FW_FileName" -readonly FW_ZIP_SUBDIR="${ScriptFNameTag}.d/$FW_FileName" +readonly FW_LOG_SUBDIR="${ScriptDirNameD}/logs" +readonly FW_BIN_SUBDIR="${ScriptDirNameD}/$FW_FileName" +readonly FW_ZIP_SUBDIR="${ScriptDirNameD}/$FW_FileName" FW_BIN_DIR="${FW_BIN_BASE_DIR}/$FW_BIN_SUBDIR" FW_LOG_DIR="${FW_LOG_BASE_DIR}/$FW_LOG_SUBDIR" @@ -1047,24 +1047,26 @@ fi ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-24] ## ##---------------------------------------## -#This code is incase the user selected USB mount isn't available anymore. -#If the USB is selected as the log location and it goes offline, any "Say" command creates a mnt directory. -#In such a case were the USB is unmounted. We need to change the log directory back to a local directory. -#First if statement executes first, and updates it local jffs for logs if no USBs are found. -#if ANY DefaultUSBMountPoint found, then move the log files from their local jffs location to the default mount location. -#We don't know the user selected yet because it's local at this time and was changed by the else statement. -#Remove the old log directory location from jffs, and update the settings file again to the new default again. -#This creates a semi-perminant switch which can reset back to default if no the user selected mount points aren't valid anymore. +#------------------------------------------------------------------------------------------------------------ +# This code is in case the user selected USB mount isn't available anymore. +# If the USB drive is selected as the log location and it goes offline, any "Say" command creates a mnt directory. +# In such a case were the USB drive is unmounted. We need to change the log directory back to a local directory. +# First if statement executes first, and updates it local jffs for logs if no USB drives are found. +# If ANY DefaultUSBMountPoint found, then move the log files from their local jffs location to the default mount location. +# We don't know the user selected yet because it's local at this time and was changed by the else statement. +# Remove the old log directory location from jffs, and update the settings file again to the new default again. +# This creates a semi-permanent switch which can reset back to default if the user-selected mount points aren't valid anymore. +#------------------------------------------------------------------------------------------------------------ UserSelectedMntPnt="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" if [ ! -d "$UserSelectedMntPnt" ] || [ ! -r "$UserSelectedMntPnt" ]; then - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" fi if USBMountPoint="$(_GetDefaultUSBMountPoint_)" then - mv -f "${FW_LOG_DIR}"/*.log "$USBMountPoint/$FW_LOG_SUBDIR" 2>/dev/null - rm -fr "$FW_LOG_DIR" - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" + mv -f "${FW_LOG_DIR}"/*.log "${USBMountPoint}/$FW_LOG_SUBDIR" 2>/dev/null + rm -fr "$FW_LOG_DIR" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" fi ##------------------------------------------## @@ -1117,9 +1119,10 @@ _CreateEMailContent_() NEW_BM_BACKUP_FAILED) { echo - echo "Warning: Backup failed during firmware update process while Auto-Updating to: ${fwNewUpdateVersion} on ${MODEL_ID} router." - echo "Firmware update on ${MODEL_ID} router is now cancelled" - printf "\nPlease check backupmon.sh configuration and retry upgrade from:\n${fwInstalledVersion}\n\n" + echo "WARNING:" + echo "Backup failed during the F/W Update process to version ${fwNewUpdateVersion} on the ${MODEL_ID} router." + echo "Flashing the F/W Update on the ${MODEL_ID} router is now cancelled." + printf "\nPlease check backupmon.sh configuration and retry F/W Update from current version:\n${fwInstalledVersion}\n\n" } > "$tempEMailBodyMsg" ;; FAILED_FW_UPDATE_STATUS) @@ -1580,14 +1583,14 @@ _DoCleanUp_() # Move file temporarily to save it from deletion # "$keepZIPfile" && [ -f "$FW_ZIP_FPATH" ] && \ - mv -f "$FW_ZIP_FPATH" "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}.d" && moveZIPback=true + mv -f "$FW_ZIP_FPATH" "${FW_ZIP_BASE_DIR}/$ScriptDirNameD" && moveZIPback=true rm -f "${FW_ZIP_DIR}"/* "$delBINfiles" && rm -f "${FW_BIN_DIR}"/* # Move file back to original location # "$keepZIPfile" && "$moveZIPback" && \ - mv -f "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}.d/${FW_FileName}.zip" "$FW_ZIP_FPATH" + mv -f "${FW_ZIP_BASE_DIR}/${ScriptDirNameD}/${FW_FileName}.zip" "$FW_ZIP_FPATH" if "$doTrace" then @@ -1775,23 +1778,23 @@ change_build_type() { printf "Would you like to use the original ${REDct}ROG${NOct} themed user interface?${NOct}\n" while true; do - printf "\n[${theADExitStr}] Enter your choice (y/n): " - read -r choice - choice="${choice:-$previous_choice}" - choice="$(echo "$choice" | tr '[:upper:]' '[:lower:]')" + printf "\n[${theADExitStr}] Enter your choice (y/n): " + read -r choice + choice="${choice:-$previous_choice}" + choice="$(echo "$choice" | tr '[:upper:]' '[:lower:]')" - if [ "$choice" = "y" ] || [ "$choice" = "yes" ]; then + if [ "$choice" = "y" ] || [ "$choice" = "yes" ]; then Update_Custom_Settings "ROGBuild" "y" break - elif [ "$choice" = "n" ] || [ "$choice" = "no" ]; then + elif [ "$choice" = "n" ] || [ "$choice" = "no" ]; then Update_Custom_Settings "ROGBuild" "n" break - elif [ "$choice" = "exit" ] || [ "$choice" = "e" ]; then + elif [ "$choice" = "exit" ] || [ "$choice" = "e" ]; then echo "Exiting without changing the build type." break - else + else echo "Invalid input! Please enter 'y', 'yes', 'n', 'no', or 'exit'." - fi + fi done } @@ -2193,7 +2196,7 @@ _EntwareServicesHandler_() entwOPT_unslung="${entwOPT_init}/rc.unslung" if [ ! -x /opt/bin/opkg ] || [ ! -x "$entwOPT_unslung" ] - then return 1 ; fi ## Entware is not found ## + then return 0 ; fi ## Entware is not found ## fileCount="$(/usr/bin/find "$entwOPT_init" -name "S*" -exec ls -1 {} \; 2>/dev/null | /bin/grep -cE "${entwOPT_init}/S[0-9]+")" [ "$fileCount" -eq 0 ] && return 0 @@ -2257,7 +2260,7 @@ Please manually update to version $minimum_supported_version or higher to use th "$inMenuMode" && _WaitForEnterKey_ "$menuReturnPromptStr" return 1 fi - + # Double-check the directory exists before using it # [ ! -d "$FW_LOG_DIR" ] && mkdir -p -m 755 "$FW_LOG_DIR" @@ -2370,8 +2373,8 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi - freeRAM_kb=$(get_free_ram) - availableRAM_kb=$(_GetAvailableRAM_KB_) + freeRAM_kb="$(get_free_ram)" + availableRAM_kb="$(_GetAvailableRAM_KB_)" Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2397,8 +2400,8 @@ Please manually update to version $minimum_supported_version or higher to use th ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-22] ## ##------------------------------------------## - freeRAM_kb=$(get_free_ram) - availableRAM_kb=$(_GetAvailableRAM_KB_) + freeRAM_kb="$(get_free_ram)" + availableRAM_kb="$(_GetAvailableRAM_KB_)" Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2546,7 +2549,10 @@ Please manually update to version $minimum_supported_version or higher to use th return 1 fi fi - + +## BEGIN: THIS CODE HAS BEEN *DISABLED* FOR NOW ## +if false +then ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-26] ## ##---------------------------------------## @@ -2554,32 +2560,34 @@ Please manually update to version $minimum_supported_version or higher to use th availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" - + # Check for the presence of backupmon.sh script (Commented out until issues resolved) - #if [ -f "/jffs/scripts/backupmon.sh" ]; then - # # Execute the backup script if it exists - # Say "\nBackup Started (by BACKUPMON)" - # sh /jffs/scripts/backupmon.sh -backup >/dev/null - # BE=$? - # Say "Backup Finished\n" - # if [ $BE -eq 0 ]; then - # Say "Backup Completed Successfully\n" - # else - # Say "Backup Failed\n" - # _SendEMailNotification_ NEW_BM_BACKUP_FAILED - # _DoCleanUp_ 1 - # _DoExit_ 1 - # fi - #else - # # Print a message if the backup script is not installed - # Say "Backup script (BACKUPMON) is not installed. Skipping backup.\n" - #fi + if [ -f "/jffs/scripts/backupmon.sh" ]; then + # Execute the backup script if it exists # + Say "\nBackup Started (by BACKUPMON)" + sh /jffs/scripts/backupmon.sh -backup >/dev/null + BE=$? + Say "Backup Finished\n" + if [ $BE -eq 0 ]; then + Say "Backup Completed Successfully\n" + else + Say "Backup Failed\n" + _SendEMailNotification_ NEW_BM_BACKUP_FAILED + _DoCleanUp_ 1 + _DoExit_ 1 + fi + else + # Print a message if the backup script is not installed + Say "Backup script (BACKUPMON) is not installed. Skipping backup.\n" + fi +fi +## END: THIS CODE HAS BEEN *DISABLED* FOR NOW ## ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## ##----------------------------------------## - freeRAM_kb=$(get_free_ram) - availableRAM_kb=$(_GetAvailableRAM_KB_) + freeRAM_kb="$(get_free_ram)" + availableRAM_kb="$(_GetAvailableRAM_KB_)" Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" @@ -2600,19 +2608,20 @@ Please manually update to version $minimum_supported_version or higher to use th # so that the F/W Update can start without interruptions. #------------------------------------------------------------# "$isInteractive" && printf "\nRestarting web server... Please wait.\n" - /sbin/service restart_httpd && sleep 5 + /sbin/service restart_httpd & + sleep 5 - #Send last email notification before flash + # Send last email notification before flash # _SendEMailNotification_ START_FW_UPDATE_STATUS - - # Check if '/opt/bin/diversion' exists + + # Check if '/opt/bin/diversion' exists # if [ -f /opt/bin/diversion ]; then - #Stop Divsersion services before flash + # Stop Diversion services before flash # Say "Stopping Diversion service..." /opt/bin/diversion unmount fi - - #Stop entware services before flash + + # Stop entware services before flash # _EntwareServicesHandler_ stop curl_response="$(curl "${routerURLstr}/login.cgi" \ @@ -2824,9 +2833,9 @@ _DoUninstall_() _DelPostUpdateEmailNotifyScriptHook_ if rm -fr "$SETTINGS_DIR" && \ - rm -fr "${FW_BIN_BASE_DIR}/${ScriptFNameTag}.d" && \ - rm -fr "${FW_LOG_BASE_DIR}/${ScriptFNameTag}.d" && \ - rm -fr "${FW_ZIP_BASE_DIR}/${ScriptFNameTag}.d" && \ + rm -fr "${FW_BIN_BASE_DIR}/$ScriptDirNameD" && \ + rm -fr "${FW_LOG_BASE_DIR}/$ScriptDirNameD" && \ + rm -fr "${FW_ZIP_BASE_DIR}/$ScriptDirNameD" && \ rm -f "$ScriptFilePath" then Say "${GRNct}Successfully Uninstalled.${NOct}" @@ -3049,7 +3058,7 @@ A USB drive is required for F/W updates.\n" ## Added by ExtremeFiretop [2024-Jan-23] ## ##---------------------------------------## _advanced_options_menu_() { - theADExitStr="${GRNct}e${NOct}=Exit to advanced menu" + theADExitStr="${GRNct}e${NOct}=Exit to advanced menu" while true; do clear logo @@ -3063,16 +3072,16 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" - + printf "\n ${GRNct}4${NOct}. Toggle Change-log Check" - + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$checkChangeLogSetting" = "DISABLED" ] then printf "\n${padStr}[Currently: ${REDct}${checkChangeLogSetting}${NOct}]\n" else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" - fi - - # Retrieve the current build type setting + fi + + # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") # Convert the setting to a descriptive text @@ -3083,13 +3092,13 @@ _advanced_options_menu_() { else current_build_type_menu="NOT SET" fi - + if echo "$PRODUCT_ID" | grep -q "^GT-"; then printf "\n ${GRNct}5${NOct}. Change ROG F/W Build Type" if [ "$current_build_type_menu" = "NOT SET" ] then printf "\n${padStr}[Current Build Type: ${REDct}${current_build_type_menu}${NOct}]\n" else printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" - fi + fi fi printf "\n ${GRNct}e${NOct}. Return to Main Menu\n" From fc89f845bbedc17a00f2d5e61731cec011a6742b Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 22:05:22 -0500 Subject: [PATCH 42/63] Update MerlinAU.sh --- MerlinAU.sh | 116 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 24 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index aa7ad5ef..2bdea23a 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,7 +8,7 @@ ################################################################### set -u -readonly SCRIPT_VERSION=0.9.92 +readonly SCRIPT_VERSION=0.9.94 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -368,24 +368,39 @@ _ScriptVersionStrToNum_() } ##----------------------------------------------## -## Added/Modified by Martinski W. [2023-Nov-28] ## +## Added/Modified by ExtremeFiretop [2024-Jan-27] ## ##----------------------------------------------## -_FWVersionStrToNum_() -{ - if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] - then echo ; return 1 ; fi +_FWVersionStrToNum_() { + if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ]; then + echo + return 1 + fi + + USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - local verNum verStr="$1" + local verStr="$1" + local betaWeight=0 - if [ "$(echo "$1" | awk -F '.' '{print NF}')" -lt "$2" ] - then verStr="$(nvram get firmver | sed 's/\.//g').$1" ; fi + # Check for 'beta' in the version string and adjust weight if USE_BETA_WEIGHT is true + if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && echo "$verStr" | grep -q 'beta'; then + betaWeight=-1000 + verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers + else + verStr="$(nvram get firmver | sed 's/\.//g').$1" + fi - if [ "$2" -lt 4 ] - then verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%03d%03d\n", $1,$2,$3);}')" - else verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%d%03d%03d\n", $1,$2,$3,$4);}')" - fi + local verNum + if [ "$2" -lt 4 ]; then + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%03d\n", $1,$2,$3}') + else + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%03d%03d\n", $1,$2,$3,$4}') + fi - echo "$verNum" ; return 0 + # Subtract beta weight from the version number + verNum=$((verNum + betaWeight)) + + echo "$verNum" + return 0 } ##--------------------------------------------## @@ -584,7 +599,7 @@ else fi ##----------------------------------------## -## Modified by Martinski W. [2024-Jan-24] ## +## Modified by Martinski W. [2024-Jan-27] ## ##----------------------------------------## _Init_Custom_Settings_Config_() { @@ -601,6 +616,7 @@ _Init_Custom_Settings_Config_() echo "FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" echo "FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" echo "CheckChangeLog ENABLED" + echo "FW_Allow_Beta_Production_Up ENABLED" } > "$SETTINGSFILE" return 1 fi @@ -646,11 +662,16 @@ _Init_Custom_Settings_Config_() sed -i "8 i CheckChangeLog ENABLED" "$SETTINGSFILE" retCode=1 fi + if ! grep -q "^FW_Allow_Beta_Production_Up" "$SETTINGSFILE" + then + sed -i "5 i FW_Allow_Beta_Production_Up ENABLED" "$SETTINGSFILE" + retCode=1 + fi return "$retCode" } ##----------------------------------------## -## Modified by Martinski W. [2024-Jan-24] ## +## Modified by Martinski W. [2024-Jan-27] ## ##----------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() @@ -663,7 +684,7 @@ Get_Custom_Setting() if [ -f "$SETTINGSFILE" ]; then case "$setting_type" in - "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | "FW_Allow_Beta_Production_Up" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") setting_value="$(grep "^${setting_type} " "$SETTINGSFILE" | awk -F ' ' '{print $2}')" @@ -687,7 +708,7 @@ Get_Custom_Setting() } ##------------------------------------------## -## Modified by ExtremeFiretop [2023-Dec-05] ## +## Modified by ExtremeFiretop [2024-Jan-07] ## ##------------------------------------------## Update_Custom_Settings() { @@ -700,7 +721,7 @@ Update_Custom_Settings() [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" case "$setting_type" in - "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | "FW_Allow_Beta_Production_Up" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") if [ -f "$SETTINGSFILE" ]; then @@ -986,7 +1007,7 @@ _Set_FW_UpdateZIP_DirectoryPath_() _Init_Custom_Settings_Config_ ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-24] ## +## Modified by ExtremeFiretop [2024-Jan-27] ## ##------------------------------------------## # NOTE: # Depending on available RAM & storage capacity of the @@ -1750,6 +1771,43 @@ _toggle_change_log_check_() { fi } +##---------------------------------------## +## Added by ExtremeFiretop [2024-Jan-27] ## +##---------------------------------------## +_toggle_beta_updates_() { + local currentSetting="$(Get_Custom_Setting "FW_Allow_Beta_Production_Up")" + + if [ "$currentSetting" = "ENABLED" ]; then + printf "${REDct}*WARNING*:${NOct}\n" + printf "Disabling updates from beta F/Ws to release F/Ws may prevent access to the latest features and fixes.\n" + printf "Keep this enabled if you prefer to stay up-to-date with the latest releases.\n" + printf "\nProceed to disable? [y/N]: " + read -r response + case $response in + [Yy]* ) + Update_Custom_Settings "FW_Allow_Beta_Production_Up" "DISABLED" + printf "Updates from beta firmwares to production firmwares are now ${REDct}DISABLED.${NOct}\n" + ;; + *) + printf "Updates from beta firmwares to production firmwares remain ${GRNct}ENABLED.${NOct}\n" + ;; + esac + else + printf "Are you sure you want to enable updates from beta F/Ws to production F/Ws?" + printf "\nProceed to enable? [y/N]: " + read -r response + case $response in + [Yy]* ) + Update_Custom_Settings "FW_Allow_Beta_Production_Up" "ENABLED" + printf "Updates from beta firmwares to production firmwares are now ${GRNct}ENABLED.${NOct}\n" + ;; + *) + printf "Updates from beta firmwares to production firmwares remain ${REDct}DISABLED.${NOct}\n" + ;; + esac + fi +} + ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-07] ## ##------------------------------------------## @@ -3046,7 +3104,7 @@ A USB drive is required for F/W updates.\n" } ##---------------------------------------## -## Added by ExtremeFiretop [2024-Jan-23] ## +## Added by ExtremeFiretop [2024-Jan-27] ## ##---------------------------------------## _advanced_options_menu_() { theADExitStr="${GRNct}e${NOct}=Exit to advanced menu" @@ -3070,7 +3128,15 @@ _advanced_options_menu_() { if [ "$checkChangeLogSetting" = "DISABLED" ] then printf "\n${padStr}[Currently: ${REDct}${checkChangeLogSetting}${NOct}]\n" else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" - fi + fi + + printf "\n ${GRNct}5${NOct}. Toggle Beta-to-Release Upgrades" + + local BetaProductionSetting="$(Get_Custom_Setting "FW_Allow_Beta_Production_Up")" + if [ "$BetaProductionSetting" = "DISABLED" ] + then printf "\n${padStr}[Currently: ${REDct}${BetaProductionSetting}${NOct}]\n" + else printf "\n${padStr}[Currently: ${GRNct}${BetaProductionSetting}${NOct}]\n" + fi # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") @@ -3085,7 +3151,7 @@ _advanced_options_menu_() { fi if echo "$PRODUCT_ID" | grep -q "^GT-"; then - printf "\n ${GRNct}5${NOct}. Change ROG F/W Build Type" + printf "\n ${GRNct}6${NOct}. Change ROG F/W Build Type" if [ "$current_build_type_menu" = "NOT SET" ] then printf "\n${padStr}[Current Build Type: ${REDct}${current_build_type_menu}${NOct}]\n" else printf "\n${padStr}[Current Build Type: ${GRNct}${current_build_type_menu}${NOct}]\n" @@ -3107,7 +3173,9 @@ _advanced_options_menu_() { ;; 4) _toggle_change_log_check_ && _WaitForEnterKey_ ;; - 5) if echo "$PRODUCT_ID" | grep -q "^GT-"; then + 5) _toggle_beta_updates_ && _WaitForEnterKey_ + ;; + 6) if echo "$PRODUCT_ID" | grep -q "^GT-"; then change_build_type && _WaitForEnterKey_ fi ;; From d2c40215875dc824d217edc1eec5d68aa9d5dfc1 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 22:12:02 -0500 Subject: [PATCH 43/63] Update MerlinAU.sh --- MerlinAU.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 2bdea23a..edcd6033 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -3122,22 +3122,26 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" - printf "\n ${GRNct}4${NOct}. Toggle Change-log Check" - local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$checkChangeLogSetting" = "DISABLED" ] - then printf "\n${padStr}[Currently: ${REDct}${checkChangeLogSetting}${NOct}]\n" - else printf "\n${padStr}[Currently: ${GRNct}${checkChangeLogSetting}${NOct}]\n" + then + printf "\n ${GRNct}4${NOct}. Enable Change-log Check" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + else + printf "\n ${GRNct}4${NOct}. Disable Change-log Check" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" fi - printf "\n ${GRNct}5${NOct}. Toggle Beta-to-Release Upgrades" - local BetaProductionSetting="$(Get_Custom_Setting "FW_Allow_Beta_Production_Up")" if [ "$BetaProductionSetting" = "DISABLED" ] - then printf "\n${padStr}[Currently: ${REDct}${BetaProductionSetting}${NOct}]\n" - else printf "\n${padStr}[Currently: ${GRNct}${BetaProductionSetting}${NOct}]\n" + then + printf "\n ${GRNct}5${NOct}. Enable Beta-to-Release Upgrades" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + else + printf "\n ${GRNct}5${NOct}. Disable Beta-to-Release Upgrades" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" fi - + # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") From 1b557d2455b984ad53ec1951ce512276bfe98eda Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 22:13:03 -0500 Subject: [PATCH 44/63] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index edcd6033..3b67e122 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -599,7 +599,7 @@ else fi ##----------------------------------------## -## Modified by Martinski W. [2024-Jan-27] ## +## Modified by ExtremeFiretop [2024-Jan-27] ## ##----------------------------------------## _Init_Custom_Settings_Config_() { @@ -671,7 +671,7 @@ _Init_Custom_Settings_Config_() } ##----------------------------------------## -## Modified by Martinski W. [2024-Jan-27] ## +## Modified by ExtremeFiretop [2024-Jan-27] ## ##----------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() From 951c008b31e9ff3a27e276a170358f20050e7e8f Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sat, 27 Jan 2024 19:21:17 -0800 Subject: [PATCH 45/63] Update MerlinAU.sh Fixed bug that was changing the user-selected Log path every time the script was started when the location was within Entware directories. --- MerlinAU.sh | 86 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 20112543..b3fa5ef8 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -515,9 +515,9 @@ _SCRIPTUPDATE_() fi } -##-------------------------------------## -## Added by Martinski W. [2023-Dec-03] ## -##-------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-27] ## +##----------------------------------------## #-------------------------------------------------------------# # Since a list of current mount points can have a different # order after each reboot, or when USB drives are unmounted @@ -531,7 +531,7 @@ _ValidateUSBMountPoint_() if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi local mounPointPaths expectedPath - local symbPath realPath foundPathOK + local symblPath realPath1 realPath2 foundPathOK local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" mounPointPaths="$(grep "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" @@ -540,10 +540,12 @@ _ValidateUSBMountPoint_() expectedPath="$1" if echo "$1" | grep -qE "^(/opt/|/tmp/opt/)" then - symbPath="$(ls -l /tmp/opt | awk -F ' ' '{print $9}')" - realPath="$(ls -l /tmp/opt | awk -F ' ' '{print $11}')" - [ -L "$symbPath" ] && [ -n "$realPath" ] && \ - expectedPath="$(/usr/bin/dirname "$realPath")" + realPath1="$(readlink -f /tmp/opt)" + realPath2="$(ls -l /tmp/opt | awk -F ' ' '{print $11}')" + symblPath="$(ls -l /tmp/opt | awk -F ' ' '{print $9}')" + [ -L "$symblPath" ] && [ -n "$realPath1" ] && \ + [ -n "$realPath2" ] && [ "$realPath1" = "$realPath2" ] && \ + expectedPath="$(/usr/bin/dirname "$realPath1")" fi foundPathOK=false @@ -584,7 +586,7 @@ else fi ##----------------------------------------## -## Modified by Martinski W. [2024-Jan-24] ## +## Modified by Martinski W. [2024-Jan-27] ## ##----------------------------------------## _Init_Custom_Settings_Config_() { @@ -600,11 +602,12 @@ _Init_Custom_Settings_Config_() echo "FW_New_Update_Cron_Job_Schedule=\"${FW_Update_CRON_DefaultSchedule}\"" echo "FW_New_Update_ZIP_Directory_Path=\"${FW_Update_ZIP_DefaultSetupDIR}\"" echo "FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" + echo "FW_New_Update_LOG_Preferred_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" echo "CheckChangeLog ENABLED" } > "$SETTINGSFILE" return 1 fi - local retCode=0 + local retCode=0 prefPath if ! grep -q "^FW_New_Update_Notification_Date " "$SETTINGSFILE" then @@ -641,16 +644,22 @@ _Init_Custom_Settings_Config_() sed -i "7 i FW_New_Update_LOG_Directory_Path=\"${FW_Update_LOG_BASE_DefaultDIR}\"" "$SETTINGSFILE" retCode=1 fi + if ! grep -q "^FW_New_Update_LOG_Preferred_Path=" "$SETTINGSFILE" + then + preferredPath="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" + sed -i "8 i FW_New_Update_LOG_Preferred_Path=\"${preferredPath}\"" "$SETTINGSFILE" + retCode=1 + fi if ! grep -q "^CheckChangeLog" "$SETTINGSFILE" then - sed -i "8 i CheckChangeLog ENABLED" "$SETTINGSFILE" + sed -i "9 i CheckChangeLog ENABLED" "$SETTINGSFILE" retCode=1 fi return "$retCode" } ##----------------------------------------## -## Modified by Martinski W. [2024-Jan-24] ## +## Modified by Martinski W. [2024-Jan-27] ## ##----------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() @@ -672,6 +681,7 @@ Get_Custom_Setting() "FW_New_Update_Cron_Job_Schedule" | \ "FW_New_Update_ZIP_Directory_Path" | \ "FW_New_Update_LOG_Directory_Path" | \ + "FW_New_Update_LOG_Preferred_Path" | \ "FW_New_Update_EMail_Notification") grep -q "^${setting_type}=" "$SETTINGSFILE" && \ setting_value="$(grep "^${setting_type}=" "$SETTINGSFILE" | awk -F '=' '{print $2}' | sed "s/['\"]//g")" @@ -686,9 +696,9 @@ Get_Custom_Setting() fi } -##------------------------------------------## -## Modified by ExtremeFiretop [2023-Dec-05] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-27] ## +##----------------------------------------## Update_Custom_Settings() { if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] ; then return 1 ; fi @@ -719,6 +729,7 @@ Update_Custom_Settings() "FW_New_Update_Cron_Job_Schedule" | \ "FW_New_Update_ZIP_Directory_Path" | \ "FW_New_Update_LOG_Directory_Path" | \ + "FW_New_Update_LOG_Preferred_Path" | \ "FW_New_Update_EMail_Notification") if [ -f "$SETTINGSFILE" ] then @@ -903,6 +914,7 @@ _Set_FW_UpdateLOG_DirectoryPath_() rm -fr "$FW_LOG_DIR" # Update the log directory path after validation # Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$newLogBaseDirPath" + Update_Custom_Settings FW_New_Update_LOG_Preferred_Path "$newLogBaseDirPath" echo "The directory path for the log files was updated successfully." _WaitForEnterKey_ "$menuReturnPromptStr" fi @@ -1044,29 +1056,35 @@ then find "$FW_LOG_DIR" -name '*.log' -mtime +30 -exec rm {} \; fi -##---------------------------------------## -## Added by ExtremeFiretop [2024-Jan-24] ## -##---------------------------------------## -#------------------------------------------------------------------------------------------------------------ -# This code is in case the user selected USB mount isn't available anymore. -# If the USB drive is selected as the log location and it goes offline, any "Say" command creates a mnt directory. -# In such a case were the USB drive is unmounted. We need to change the log directory back to a local directory. -# First if statement executes first, and updates it local jffs for logs if no USB drives are found. -# If ANY DefaultUSBMountPoint found, then move the log files from their local jffs location to the default mount location. -# We don't know the user selected yet because it's local at this time and was changed by the else statement. -# Remove the old log directory location from jffs, and update the settings file again to the new default again. -# This creates a semi-permanent switch which can reset back to default if the user-selected mount points aren't valid anymore. -#------------------------------------------------------------------------------------------------------------ -UserSelectedMntPnt="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" -if [ ! -d "$UserSelectedMntPnt" ] || [ ! -r "$UserSelectedMntPnt" ]; then +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-27] ## +##----------------------------------------## +#------------------------------------------------------------------------------------------- +# This code is in case the user-selected USB mount point isn't available anymore. +# If the USB drive is selected as the log location but it goes offline for some reason, +# any call to the "Say" function creates a new '/tmp/mnt/XXXX' directory. +# In such a case where the USB drive is unmounted, we need to change the log directory +# back to a local directory. First if-statement executes first and updates to local 'jffs' +# directory if no USB drives are found. If ANY DefaultUSBMountPoint found, then move the +# log files from their local jffs location to the default mount location. +# We don't know the user selected yet because it's local at this time and was changed +# by the else statement. Remove the old log directory location from jffs, and update the +# settings file again to the new default again. This creates a semi-permanent switch which +# can reset back to default if the user-selected mount points aren't valid anymore. +#------------------------------------------------------------------------------------------- +UserSelectedLogPath="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)" +if [ ! -d "$UserSelectedLogPath" ] || [ ! -r "$UserSelectedLogPath" ]; then Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$ADDONS_PATH" fi -if USBMountPoint="$(_GetDefaultUSBMountPoint_)" +UserPreferredLogPath="$(Get_Custom_Setting FW_New_Update_LOG_Preferred_Path)" +if echo "$UserPreferredLogPath" | grep -qE "^(/tmp/mnt/|/tmp/opt/|/opt/)" && \ + _ValidateUSBMountPoint_ "$UserPreferredLogPath" && + [ "$UserPreferredLogPath" != "$FW_LOG_BASE_DIR" ] then - mv -f "${FW_LOG_DIR}"/*.log "${USBMountPoint}/$FW_LOG_SUBDIR" 2>/dev/null - rm -fr "$FW_LOG_DIR" - Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$USBMountPoint" + mv -f "${FW_LOG_DIR}"/*.log "${UserPreferredLogPath}/$FW_LOG_SUBDIR" 2>/dev/null + rm -fr "$FW_LOG_DIR" + Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$UserPreferredLogPath" fi ##------------------------------------------## From 7bf1016b1f0e81b92614d8b09b9596f662d77da6 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sat, 27 Jan 2024 22:37:04 -0500 Subject: [PATCH 46/63] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 3b67e122..91e3d794 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -376,7 +376,7 @@ _FWVersionStrToNum_() { return 1 fi - USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" + USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" local verStr="$1" local betaWeight=0 @@ -386,7 +386,7 @@ _FWVersionStrToNum_() { betaWeight=-1000 verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers else - verStr="$(nvram get firmver | sed 's/\.//g').$1" + verStr="$(nvram get firmver | sed 's/\.//g').$1" fi local verNum From 189efbb33fb8c5cd7c91ad676ef07d6c799a6de5 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 15:05:00 -0500 Subject: [PATCH 47/63] Update MerlinAU.sh --- MerlinAU.sh | 128 ++++++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 60 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index c7dddeba..ae3507e6 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8,8 +8,8 @@ ################################################################### set -u - -readonly SCRIPT_VERSION=0.9.94 +#For AMTM versioning: +readonly SCRIPT_VERSION=1.0 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -368,40 +368,48 @@ _ScriptVersionStrToNum_() echo "$verNum" ; return 0 } -##----------------------------------------------## +##------------------------------------------------## ## Added/Modified by ExtremeFiretop [2024-Jan-27] ## -##----------------------------------------------## -_FWVersionStrToNum_() { - if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ]; then - echo - return 1 - fi - - USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - - local verStr="$1" - local betaWeight=0 - - # Check for 'beta' in the version string and adjust weight if USE_BETA_WEIGHT is true - if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && echo "$verStr" | grep -q 'beta'; then - betaWeight=-1000 - verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers - else - verStr="$(nvram get firmver | sed 's/\.//g').$1" - fi +##------------------------------------------------## +_FWVersionStrToNum_() +{ + if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] + then echo ; return 1 ; fi - local verNum - if [ "$2" -lt 4 ]; then - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%03d\n", $1,$2,$3}') - else - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%03d%03d\n", $1,$2,$3,$4}') - fi + USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - # Subtract beta weight from the version number - verNum=$((verNum + betaWeight)) + local verNum + local verStr="$1" + local betaWeight=0 - echo "$verNum" - return 0 + if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && echo "$verStr" | grep -q 'beta'; then + betaWeight=-1000 + verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers + + if [ "$(echo "verStr" | awk -F '.' '{print NF}')" -lt "$2" ] + then verStr="$(nvram get firmver | sed 's/\.//g').$verStr" ; fi + + if [ "$2" -lt 4 ]; then + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%01d\n", $1,$2,$3}') + else + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%d%01d\n", $1,$2,$3,$4}') + fi + + verNum=$((verNum + betaWeight)) + + else + if [ "$(echo "$1" | awk -F '.' '{print NF}')" -lt "$2" ] + then verStr="$(nvram get firmver | sed 's/\.//g').$1" ; fi + + if [ "$2" -lt 4 ]; then + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%01d\n", $1,$2,$3}') + else + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%d%01d\n", $1,$2,$3,$4}') + fi + + fi + + echo "$verNum" ; return 0 } ##--------------------------------------------## @@ -601,9 +609,9 @@ else readonly FW_Update_LOG_BASE_DefaultDIR="$ADDONS_PATH" fi -##----------------------------------------## +##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-27] ## -##----------------------------------------## +##------------------------------------------## _Init_Custom_Settings_Config_() { [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" @@ -680,9 +688,9 @@ _Init_Custom_Settings_Config_() return "$retCode" } -##----------------------------------------## +##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-27] ## -##----------------------------------------## +##------------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() { @@ -1109,6 +1117,27 @@ then Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$UserPreferredLogPath" fi +##----------------------------------------------## +## Added/Modified by Martinski W. [2023-Nov-22] ## +##----------------------------------------------## +_GetLatestFWUpdateVersionFromRouter_() +{ + local retCode=0 webState newVersionStr + + webState="$(nvram get webs_state_flag)" + if [ -z "$webState" ] || [ "$webState" -eq 0 ] + then retCode=1 ; fi + + newVersionStr="$(nvram get webs_state_info | sed 's/_/./g')" + if [ $# -eq 0 ] || [ -z "$1" ] + then + newVersionStr="$(echo "$newVersionStr" | awk -F '-' '{print $1}')" + fi + + [ -z "$newVersionStr" ] && retCode=1 + echo "$newVersionStr" ; return "$retCode" +} + ##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-26] ## ##------------------------------------------## @@ -1707,27 +1736,6 @@ _GetLoginCredentials_() return 0 } -##----------------------------------------------## -## Added/Modified by Martinski W. [2023-Nov-22] ## -##----------------------------------------------## -_GetLatestFWUpdateVersionFromRouter_() -{ - local retCode=0 webState newVersionStr - - webState="$(nvram get webs_state_flag)" - if [ -z "$webState" ] || [ "$webState" -eq 0 ] - then retCode=1 ; fi - - newVersionStr="$(nvram get webs_state_info | sed 's/_/./g')" - if [ $# -eq 0 ] || [ -z "$1" ] - then - newVersionStr="$(echo "$newVersionStr" | awk -F '-' '{print $1}')" - fi - - [ -z "$newVersionStr" ] && retCode=1 - echo "$newVersionStr" ; return "$retCode" -} - ##----------------------------------------## ## Modified by Martinski W. [2023-Nov-20] ## ##----------------------------------------## @@ -2373,8 +2381,8 @@ Please manually update to version $minimum_supported_version or higher to use th ! _CreateDirectory_ "$FW_BIN_DIR" ; then return 1 ; fi # Get current firmware version # - current_version="$(_GetCurrentFWInstalledShortVersion_)" - ##FOR DEBUG ONLY##current_version="388.5.0" + ##FOR DEBUG ONLY##current_version="$(_GetCurrentFWInstalledShortVersion_)" + current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2628,7 +2636,7 @@ Please manually update to version $minimum_supported_version or higher to use th fi ## BEGIN: THIS CODE HAS BEEN *DISABLED* FOR NOW ## -if false +if true then ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-26] ## From 0dd41ed13084a335a0c9f2ce15fe1ebb4a7f347f Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 18:58:22 -0500 Subject: [PATCH 48/63] Update MerlinAU.sh --- MerlinAU.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index ae3507e6..0f966d0a 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2381,8 +2381,8 @@ Please manually update to version $minimum_supported_version or higher to use th ! _CreateDirectory_ "$FW_BIN_DIR" ; then return 1 ; fi # Get current firmware version # - ##FOR DEBUG ONLY##current_version="$(_GetCurrentFWInstalledShortVersion_)" - current_version="388.5.0" + current_version="$(_GetCurrentFWInstalledShortVersion_)" + ##FOR DEBUG ONLY##current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2635,9 +2635,6 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi -## BEGIN: THIS CODE HAS BEEN *DISABLED* FOR NOW ## -if true -then ##---------------------------------------## ## Added by ExtremeFiretop [2024-Jan-26] ## ##---------------------------------------## @@ -2659,14 +2656,17 @@ then Say "Backup Failed\n" _SendEMailNotification_ NEW_BM_BACKUP_FAILED _DoCleanUp_ 1 - _DoExit_ 1 + if "$isInteractive" + then + return 1 + else + _DoExit_ 1 + fi fi else # Print a message if the backup script is not installed Say "Backup script (BACKUPMON) is not installed. Skipping backup.\n" fi -fi -## END: THIS CODE HAS BEEN *DISABLED* FOR NOW ## ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-06] ## From 059ec3625b7d62e1c633f2fccb7ec718e5444b0d Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sun, 28 Jan 2024 16:10:38 -0800 Subject: [PATCH 49/63] Update MerlinAU.sh Fixed problem with getting correct F/W version number to compare with available update. Problem was related to "beta" checking. --- MerlinAU.sh | 97 +++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index c7dddeba..8f5a492c 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,12 +4,11 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2024-Jan-27 +# Last Modified: 2024-Jan-28 ################################################################### set -u - -readonly SCRIPT_VERSION=0.9.94 +readonly SCRIPT_VERSION=0.9.96 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------## @@ -368,40 +367,42 @@ _ScriptVersionStrToNum_() echo "$verNum" ; return 0 } -##----------------------------------------------## -## Added/Modified by ExtremeFiretop [2024-Jan-27] ## -##----------------------------------------------## -_FWVersionStrToNum_() { - if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ]; then - echo - return 1 - fi - +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-28] ## +##----------------------------------------## +_FWVersionStrToNum_() +{ + if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] + then echo ; return 1 ; fi + USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - local verStr="$1" - local betaWeight=0 + local verNum verStr="$1" nonProductionVersionWeight=0 - # Check for 'beta' in the version string and adjust weight if USE_BETA_WEIGHT is true - if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && echo "$verStr" | grep -q 'beta'; then - betaWeight=-1000 - verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers - else - verStr="$(nvram get firmver | sed 's/\.//g').$1" + # Check for 'alpha/beta' in the version string and + # adjust weight value if USE_BETA_WEIGHT is true + if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && \ + echo "$verStr" | grep -qiE 'alpha|beta' + then + nonProductionVersionWeight=-1000 + # Remove 'alpha/beta' and any following numbers # + verStr="$(echo "$verStr" | sed 's/[Aa]lpha[0-9]*// ; s/[Bb]eta[0-9]*//')" fi - local verNum - if [ "$2" -lt 4 ]; then - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%03d\n", $1,$2,$3}') - else - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%03d%03d\n", $1,$2,$3,$4}') + if [ "$(echo "$verStr" | awk -F '.' '{print NF}')" -lt "$2" ] + then verStr="$(nvram get firmver | sed 's/\.//g').$verStr" ; fi + + if [ "$2" -lt 4 ] + then + verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')" + else + verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%d%02d%02d\n", $1,$2,$3,$4);}')" fi - # Subtract beta weight from the version number - verNum=$((verNum + betaWeight)) + # Subtract non-production weight from the version number # + verNum="$((verNum + nonProductionVersionWeight))" - echo "$verNum" - return 0 + echo "$verNum" ; return 0 } ##--------------------------------------------## @@ -601,9 +602,9 @@ else readonly FW_Update_LOG_BASE_DefaultDIR="$ADDONS_PATH" fi -##----------------------------------------## +##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-27] ## -##----------------------------------------## +##------------------------------------------## _Init_Custom_Settings_Config_() { [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" @@ -680,9 +681,9 @@ _Init_Custom_Settings_Config_() return "$retCode" } -##----------------------------------------## +##------------------------------------------## ## Modified by ExtremeFiretop [2024-Jan-27] ## -##----------------------------------------## +##------------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() { @@ -694,7 +695,8 @@ Get_Custom_Setting() if [ -f "$SETTINGSFILE" ]; then case "$setting_type" in - "ROGBuild" | "credentials_base64" | "CheckChangeLog" | "FW_Allow_Beta_Production_Up" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ + "FW_Allow_Beta_Production_Up" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") setting_value="$(grep "^${setting_type} " "$SETTINGSFILE" | awk -F ' ' '{print $2}')" @@ -719,7 +721,7 @@ Get_Custom_Setting() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-07] ## +## Modified by ExtremeFiretop [2024-Jan-27] ## ##------------------------------------------## Update_Custom_Settings() { @@ -732,7 +734,8 @@ Update_Custom_Settings() [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" case "$setting_type" in - "ROGBuild" | "credentials_base64" | "CheckChangeLog" | "FW_Allow_Beta_Production_Up" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ + "FW_Allow_Beta_Production_Up" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") if [ -f "$SETTINGSFILE" ]; then @@ -3149,27 +3152,27 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" - + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$checkChangeLogSetting" = "DISABLED" ] then - printf "\n ${GRNct}4${NOct}. Enable Change-log Check" - printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + printf "\n ${GRNct}4${NOct}. Enable Change-log Check" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" else - printf "\n ${GRNct}4${NOct}. Disable Change-log Check" - printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" + printf "\n ${GRNct}4${NOct}. Disable Change-log Check" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" fi - + local BetaProductionSetting="$(Get_Custom_Setting "FW_Allow_Beta_Production_Up")" if [ "$BetaProductionSetting" = "DISABLED" ] then - printf "\n ${GRNct}5${NOct}. Enable Beta-to-Release Upgrades" - printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + printf "\n ${GRNct}5${NOct}. Enable Beta-to-Release Upgrades" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" else - printf "\n ${GRNct}5${NOct}. Disable Beta-to-Release Upgrades" - printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" + printf "\n ${GRNct}5${NOct}. Disable Beta-to-Release Upgrades" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" fi - + # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") From 5a4f8fe4f5bd2bed780f0e8b70c0ff57a9ed501b Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 19:22:08 -0500 Subject: [PATCH 50/63] Update MerlinAU.sh --- MerlinAU.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MerlinAU.sh b/MerlinAU.sh index 0f966d0a..dacb3a01 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2658,6 +2658,11 @@ Please manually update to version $minimum_supported_version or higher to use th _DoCleanUp_ 1 if "$isInteractive" then + printf "${REDct}**IMPORTANT NOTICE**:${NOct}\n" + printf "The firmware flash has been ${REDct}CANCELLED${NOct} due to a failed backup from BACKUPMON.\n" + printf "Please fix the BACKUPMON configuration, or consider uninstalling it to proceed flash.\n" + printf "Resolving the BACKUPMON configuration is HIGHLY recommended for safety of the upgrade.\n" + _WaitForEnterKey_ "$menuReturnPromptStr" return 1 else _DoExit_ 1 From 22c19c83be6f40f35c812838af9f39567e9c1bd8 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 19:32:56 -0500 Subject: [PATCH 51/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index dacb3a01..fb31bc25 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -386,7 +386,7 @@ _FWVersionStrToNum_() betaWeight=-1000 verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers - if [ "$(echo "verStr" | awk -F '.' '{print NF}')" -lt "$2" ] + if [ "$(echo "$verStr" | awk -F '.' '{print NF}')" -lt "$2" ] then verStr="$(nvram get firmver | sed 's/\.//g').$verStr" ; fi if [ "$2" -lt 4 ]; then From 9196ab7083faa8f98a12e8c5baf1d5529739abce Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 21:21:47 -0500 Subject: [PATCH 52/63] Update MerlinAU.sh --- MerlinAU.sh | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index fb31bc25..45c49f32 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-Jan-27 +# Last Modified: 2024-Jan-28 ################################################################### set -u @@ -369,7 +369,7 @@ _ScriptVersionStrToNum_() } ##------------------------------------------------## -## Added/Modified by ExtremeFiretop [2024-Jan-27] ## +## Added/Modified by ExtremeFiretop [2024-Jan-28] ## ##------------------------------------------------## _FWVersionStrToNum_() { @@ -689,7 +689,7 @@ _Init_Custom_Settings_Config_() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-27] ## +## Modified by ExtremeFiretop [2024-Jan-28] ## ##------------------------------------------## # Function to get custom setting value from the settings file Get_Custom_Setting() @@ -702,7 +702,8 @@ Get_Custom_Setting() if [ -f "$SETTINGSFILE" ]; then case "$setting_type" in - "ROGBuild" | "credentials_base64" | "CheckChangeLog" | "FW_Allow_Beta_Production_Up" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ + "FW_Allow_Beta_Production_Up" | \ "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") setting_value="$(grep "^${setting_type} " "$SETTINGSFILE" | awk -F ' ' '{print $2}')" @@ -727,7 +728,7 @@ Get_Custom_Setting() } ##------------------------------------------## -## Modified by ExtremeFiretop [2024-Jan-07] ## +## Modified by ExtremeFiretop [2024-Jan-28] ## ##------------------------------------------## Update_Custom_Settings() { @@ -740,8 +741,8 @@ Update_Custom_Settings() [ ! -d "$SETTINGS_DIR" ] && mkdir -m 755 -p "$SETTINGS_DIR" case "$setting_type" in - "ROGBuild" | "credentials_base64" | "CheckChangeLog" | "FW_Allow_Beta_Production_Up" | \ - "FW_New_Update_Notification_Date" | \ + "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ + "FW_Allow_Beta_Production_Up" | \ "FW_New_Update_Notification_Vers") if [ -f "$SETTINGSFILE" ]; then if [ "$(grep -c "$setting_type" "$SETTINGSFILE")" -gt 0 ]; then @@ -3162,27 +3163,27 @@ _advanced_options_menu_() { printf "\n ${GRNct}3${NOct}. Set Directory for F/W Update Log Files" printf "\n${padStr}[Current Path: ${GRNct}${FW_LOG_DIR}${NOct}]\n" - + local checkChangeLogSetting="$(Get_Custom_Setting "CheckChangeLog")" if [ "$checkChangeLogSetting" = "DISABLED" ] then - printf "\n ${GRNct}4${NOct}. Enable Change-log Check" - printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + printf "\n ${GRNct}4${NOct}. Enable Change-log Check" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" else - printf "\n ${GRNct}4${NOct}. Disable Change-log Check" - printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" + printf "\n ${GRNct}4${NOct}. Disable Change-log Check" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" fi - + local BetaProductionSetting="$(Get_Custom_Setting "FW_Allow_Beta_Production_Up")" if [ "$BetaProductionSetting" = "DISABLED" ] then - printf "\n ${GRNct}5${NOct}. Enable Beta-to-Release Upgrades" - printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" + printf "\n ${GRNct}5${NOct}. Enable Beta-to-Release Upgrades" + printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" else - printf "\n ${GRNct}5${NOct}. Disable Beta-to-Release Upgrades" - printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" + printf "\n ${GRNct}5${NOct}. Disable Beta-to-Release Upgrades" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" fi - + # Retrieve the current build type setting local current_build_type=$(Get_Custom_Setting "ROGBuild") From f639e0a21eb2f4c29a891936fd8e9cfdfb787236 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 22:07:38 -0500 Subject: [PATCH 53/63] Update MerlinAU.sh --- MerlinAU.sh | 59 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 45c49f32..741b6a0f 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -743,6 +743,7 @@ Update_Custom_Settings() case "$setting_type" in "ROGBuild" | "credentials_base64" | "CheckChangeLog" | \ "FW_Allow_Beta_Production_Up" | \ + "FW_New_Update_Notification_Date" | \ "FW_New_Update_Notification_Vers") if [ -f "$SETTINGSFILE" ]; then if [ "$(grep -c "$setting_type" "$SETTINGSFILE")" -gt 0 ]; then @@ -2645,29 +2646,45 @@ Please manually update to version $minimum_supported_version or higher to use th check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" # Check for the presence of backupmon.sh script (Commented out until issues resolved) - if [ -f "/jffs/scripts/backupmon.sh" ]; then - # Execute the backup script if it exists # - Say "\nBackup Started (by BACKUPMON)" - sh /jffs/scripts/backupmon.sh -backup >/dev/null - BE=$? - Say "Backup Finished\n" - if [ $BE -eq 0 ]; then - Say "Backup Completed Successfully\n" - else - Say "Backup Failed\n" - _SendEMailNotification_ NEW_BM_BACKUP_FAILED - _DoCleanUp_ 1 - if "$isInteractive" - then - printf "${REDct}**IMPORTANT NOTICE**:${NOct}\n" - printf "The firmware flash has been ${REDct}CANCELLED${NOct} due to a failed backup from BACKUPMON.\n" - printf "Please fix the BACKUPMON configuration, or consider uninstalling it to proceed flash.\n" - printf "Resolving the BACKUPMON configuration is HIGHLY recommended for safety of the upgrade.\n" - _WaitForEnterKey_ "$menuReturnPromptStr" - return 1 + if [ -f "/jffs/scripts/backupmon.sh" ] && [ -f "/jffs/addons/backupmon.d/version.txt" ]; then + + # Read version number from version.txt + BM_VERSION=$(cat /jffs/addons/backupmon.d/version.txt) + + # Convert both current and required versions to numeric format + current_version=$(_ScriptVersionStrToNum_ "$BM_VERSION") + required_version=$(_ScriptVersionStrToNum_ "1.44") + + # Check if BACKUPMON version is greater than or equal to 1.44 + if [ "$current_version" -ge "$required_version" ]; then + # Execute the backup script if it exists # + Say "\nBackup Started (by BACKUPMON)" + sh /jffs/scripts/backupmon.sh -backup >/dev/null + BE=$? + Say "Backup Finished\n" + if [ $BE -eq 0 ]; then + Say "Backup Completed Successfully\n" else - _DoExit_ 1 + Say "Backup Failed\n" + _SendEMailNotification_ NEW_BM_BACKUP_FAILED + _DoCleanUp_ 1 + if "$isInteractive" + then + printf "\n${REDct}**IMPORTANT NOTICE**:${NOct}" + printf "The firmware flash has been ${REDct}CANCELLED${NOct} due to a failed backup from BACKUPMON.\n" + printf "Please fix the BACKUPMON configuration, or consider uninstalling it to proceed flash.\n" + printf "Resolving the BACKUPMON configuration is HIGHLY recommended for safety of the upgrade.\n" + _WaitForEnterKey_ "$menuReturnPromptStr" + return 1 + else + _DoExit_ 1 + fi fi + else + # BACKUPMON version is not sufficient + Say "${REDct}**IMPORTANT NOTICE**:${NOct}\n" + Say "Backup script (BACKUPMON) is installed; but version $BM_VERSION does not meet the minimum required version of 1.44.\n" + Say "Skipping backup. Please update your version of BACKUPMON.\n" fi else # Print a message if the backup script is not installed From f957ac35f5cfff5aa53867a866ffc950587fdd05 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 22:21:40 -0500 Subject: [PATCH 54/63] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 741b6a0f..f70ea889 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2670,7 +2670,7 @@ Please manually update to version $minimum_supported_version or higher to use th _DoCleanUp_ 1 if "$isInteractive" then - printf "\n${REDct}**IMPORTANT NOTICE**:${NOct}" + printf "\n${REDct}**IMPORTANT NOTICE**:${NOct}\n" printf "The firmware flash has been ${REDct}CANCELLED${NOct} due to a failed backup from BACKUPMON.\n" printf "Please fix the BACKUPMON configuration, or consider uninstalling it to proceed flash.\n" printf "Resolving the BACKUPMON configuration is HIGHLY recommended for safety of the upgrade.\n" @@ -2682,7 +2682,7 @@ Please manually update to version $minimum_supported_version or higher to use th fi else # BACKUPMON version is not sufficient - Say "${REDct}**IMPORTANT NOTICE**:${NOct}\n" + Say "\n${REDct}**IMPORTANT NOTICE**:${NOct}\n" Say "Backup script (BACKUPMON) is installed; but version $BM_VERSION does not meet the minimum required version of 1.44.\n" Say "Skipping backup. Please update your version of BACKUPMON.\n" fi From c9314e884214fb6d8e9961d3716a2a932fbd8ebb Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 22:24:06 -0500 Subject: [PATCH 55/63] Update MerlinAU.sh --- MerlinAU.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index f70ea889..b47b3579 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -2637,9 +2637,9 @@ Please manually update to version $minimum_supported_version or higher to use th fi fi - ##---------------------------------------## - ## Added by ExtremeFiretop [2024-Jan-26] ## - ##---------------------------------------## + ##------------------------------------------## + ## Modified by ExtremeFiretop [2024-Jan-28] ## + ##------------------------------------------## freeRAM_kb=$(get_free_ram) availableRAM_kb=$(_GetAvailableRAM_KB_) Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" From c86b887b54e2aac19dbc001a38e42e6722acd9c8 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 28 Jan 2024 22:33:57 -0500 Subject: [PATCH 56/63] Update MerlinAU.sh --- MerlinAU.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b47b3579..d451bdb3 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1811,7 +1811,7 @@ _toggle_beta_updates_() { if [ "$currentSetting" = "ENABLED" ]; then printf "${REDct}*WARNING*:${NOct}\n" - printf "Disabling updates from beta F/Ws to release F/Ws may prevent access to the latest features and fixes.\n" + printf Disabling updates from beta to release firmware may limit access to new features and fixes.\n" printf "Keep this enabled if you prefer to stay up-to-date with the latest releases.\n" printf "\nProceed to disable? [y/N]: " read -r response @@ -2384,7 +2384,7 @@ Please manually update to version $minimum_supported_version or higher to use th # Get current firmware version # current_version="$(_GetCurrentFWInstalledShortVersion_)" - ##FOR DEBUG ONLY##current_version="388.5.0" + ##FOR DEBUG ONLY##current_version="388.6.beta1" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled From 9eb9301fb8d640795b49678f55ac3ac851b9193b Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sun, 28 Jan 2024 21:35:49 -0800 Subject: [PATCH 57/63] Update MerlinAU.sh New code to unmount USB-attached drives just before flashing the F/W image. Also a fix for getting the numeric version string correct when doing arithmetic operations. --- MerlinAU.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 8f5a492c..424e54f3 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -227,7 +227,7 @@ FW_UpdateCheckScript="/usr/sbin/webs_update.sh" _GetDefaultUSBMountPoint_() { local mounPointPath retCode=0 - local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" + local mountPointRegExp="^/dev/sd.* /tmp/mnt/.*" mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" [ -z "$mounPointPath" ] && retCode=1 @@ -378,30 +378,41 @@ _FWVersionStrToNum_() USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" local verNum verStr="$1" nonProductionVersionWeight=0 + local fwBranchVers="" numFields # Check for 'alpha/beta' in the version string and # adjust weight value if USE_BETA_WEIGHT is true if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && \ echo "$verStr" | grep -qiE 'alpha|beta' then - nonProductionVersionWeight=-1000 + nonProductionVersionWeight=-100 # Remove 'alpha/beta' and any following numbers # verStr="$(echo "$verStr" | sed 's/[Aa]lpha[0-9]*// ; s/[Bb]eta[0-9]*//')" fi - if [ "$(echo "$verStr" | awk -F '.' '{print NF}')" -lt "$2" ] - then verStr="$(nvram get firmver | sed 's/\.//g').$verStr" ; fi + numFields="$(echo "$verStr" | awk -F '.' '{print NF}')" - if [ "$2" -lt 4 ] + if [ "$numFields" -lt "$2" ] + then fwBranchVers="$(nvram get firmver | sed 's/\.//g')" ; fi + + #----------------------------------------------------------- + # Temporarily remove Branch version to avoid issues with + # integers greater than the maximum 32-bit signed integer + # when doing arithmetic computations with shell cmds. + #----------------------------------------------------------- + if [ "$numFields" -gt 3 ] then - verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%02d\n", $1,$2,$3);}')" - else - verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%d%02d%02d\n", $1,$2,$3,$4);}')" + fwBranchVers="$(echo "$verStr" | cut -d'.' -f1)" + verStr="$(echo "$verStr" | cut -d'.' -f2-)" fi + verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%01d\n", $1,$2,$3);}')" # Subtract non-production weight from the version number # verNum="$((verNum + nonProductionVersionWeight))" + # Now add the F/W Branch version # + [ -n "$fwBranchVers" ] && verNum="${fwBranchVers}$verNum" + echo "$verNum" ; return 0 } @@ -549,7 +560,7 @@ _ValidateUSBMountPoint_() local mounPointPaths expectedPath local symblPath realPath1 realPath2 foundPathOK - local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" + local mountPointRegExp="^/dev/sd.* /tmp/mnt/.*" mounPointPaths="$(grep "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" [ -z "$mounPointPaths" ] && return 1 @@ -2259,7 +2270,11 @@ _Toggle_FW_UpdateCheckSetting_() printf "Router's built-in Firmware Update Check is now ${fwUpdateCheckNewStateStr}.\n" nvram commit - "$runfwUpdateCheck" && sh $FW_UpdateCheckScript 2>&1 & + if "$runfwUpdateCheck" + then + printf "\nChecking for new F/W Updates... Please wait.\n" + sh $FW_UpdateCheckScript 2>&1 + fi _WaitForEnterKey_ "$menuReturnPromptStr" } @@ -2291,9 +2306,29 @@ _EntwareServicesHandler_() then printf "\n${actionStr} Entware services... Please wait.\n" $entwOPT_unslung $1 ; sleep 5 + printf "\nDone.\n" fi } +##-------------------------------------## +## Added by Martinski W. [2024-Jan-28] ## +##-------------------------------------## +_UnmountUSBDrives_() +{ + local theDevice mountPointRegExp="^/dev/sd[a-z][0-9]+.* /tmp/mnt/.*" + + mountedDevices="$(grep -E "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $1}')" + [ -z "$mountedDevices" ] && return 1 + + "$isInteractive" && \ + printf "\nUnmounting USB-attached drives. Please wait...\n" + + for theDevice in $mountedDevices + do umount -f "$theDevice" 2>/dev/null; sleep 2 ; done + + printf "\nDone.\n" +} + ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-25] ## ##----------------------------------------## @@ -2725,6 +2760,9 @@ fi Say "Flashing ${GRNct}${firmware_file}${NOct}... ${REDct}Please wait for reboot in about 4 minutes or less.${NOct}" echo + # *WARNING*: No more logging at this point & beyond # + _UnmountUSBDrives_ + nohup curl "${routerURLstr}/upgrade.cgi" \ --referer ${routerURLstr}/Advanced_FirmwareUpgrade_Content.asp \ --user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ From 940041047badc95bd48fd6ed5b515cfbf3d11335 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 29 Jan 2024 01:28:10 -0500 Subject: [PATCH 58/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index d451bdb3..b14c7578 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1811,7 +1811,7 @@ _toggle_beta_updates_() { if [ "$currentSetting" = "ENABLED" ]; then printf "${REDct}*WARNING*:${NOct}\n" - printf Disabling updates from beta to release firmware may limit access to new features and fixes.\n" + printf "Disabling updates from beta to release firmware may limit access to new features and fixes.\n" printf "Keep this enabled if you prefer to stay up-to-date with the latest releases.\n" printf "\nProceed to disable? [y/N]: " read -r response From 65318e326b83d53eba489b375d53a99f60ce0be8 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 29 Jan 2024 01:50:38 -0500 Subject: [PATCH 59/63] Update MerlinAU.sh --- MerlinAU.sh | 113 +++++++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 73 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 4f28cf1c..2d13f9d4 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -228,7 +228,7 @@ FW_UpdateCheckScript="/usr/sbin/webs_update.sh" _GetDefaultUSBMountPoint_() { local mounPointPath retCode=0 - local mountPointRegExp="^/dev/sd.* /tmp/mnt/.*" + local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" [ -z "$mounPointPath" ] && retCode=1 @@ -368,53 +368,48 @@ _ScriptVersionStrToNum_() echo "$verNum" ; return 0 } -##----------------------------------------## -## Modified by Martinski W. [2024-Jan-28] ## -##----------------------------------------## +##------------------------------------------------## +## Added/Modified by ExtremeFiretop [2024-Jan-28] ## +##------------------------------------------------## _FWVersionStrToNum_() { - if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] - then echo ; return 1 ; fi + if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] + then echo ; return 1 ; fi - USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" + USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - local verNum verStr="$1" nonProductionVersionWeight=0 - local fwBranchVers="" numFields + local verNum + local verStr="$1" + local betaWeight=0 - # Check for 'alpha/beta' in the version string and - # adjust weight value if USE_BETA_WEIGHT is true - if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && \ - echo "$verStr" | grep -qiE 'alpha|beta' - then - nonProductionVersionWeight=-100 - # Remove 'alpha/beta' and any following numbers # - verStr="$(echo "$verStr" | sed 's/[Aa]lpha[0-9]*// ; s/[Bb]eta[0-9]*//')" - fi + if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && echo "$verStr" | grep -q 'beta'; then + betaWeight=-1000 + verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers + + if [ "$(echo "$verStr" | awk -F '.' '{print NF}')" -lt "$2" ] + then verStr="$(nvram get firmver | sed 's/\.//g').$verStr" ; fi - numFields="$(echo "$verStr" | awk -F '.' '{print NF}')" + if [ "$2" -lt 4 ]; then + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%01d\n", $1,$2,$3}') + else + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%d%01d\n", $1,$2,$3,$4}') + fi - if [ "$numFields" -lt "$2" ] - then fwBranchVers="$(nvram get firmver | sed 's/\.//g')" ; fi + verNum=$((verNum + betaWeight)) - #----------------------------------------------------------- - # Temporarily remove Branch version to avoid issues with - # integers greater than the maximum 32-bit signed integer - # when doing arithmetic computations with shell cmds. - #----------------------------------------------------------- - if [ "$numFields" -gt 3 ] - then - fwBranchVers="$(echo "$verStr" | cut -d'.' -f1)" - verStr="$(echo "$verStr" | cut -d'.' -f2-)" - fi - verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%01d\n", $1,$2,$3);}')" + else + if [ "$(echo "$1" | awk -F '.' '{print NF}')" -lt "$2" ] + then verStr="$(nvram get firmver | sed 's/\.//g').$1" ; fi - # Subtract non-production weight from the version number # - verNum="$((verNum + nonProductionVersionWeight))" + if [ "$2" -lt 4 ]; then + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%01d\n", $1,$2,$3}') + else + verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%d%01d\n", $1,$2,$3,$4}') + fi - # Now add the F/W Branch version # - [ -n "$fwBranchVers" ] && verNum="${fwBranchVers}$verNum" + fi - echo "$verNum" ; return 0 + echo "$verNum" ; return 0 } ##--------------------------------------------## @@ -561,7 +556,7 @@ _ValidateUSBMountPoint_() local mounPointPaths expectedPath local symblPath realPath1 realPath2 foundPathOK - local mountPointRegExp="^/dev/sd.* /tmp/mnt/.*" + local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" mounPointPaths="$(grep "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" [ -z "$mounPointPaths" ] && return 1 @@ -2271,11 +2266,7 @@ _Toggle_FW_UpdateCheckSetting_() printf "Router's built-in Firmware Update Check is now ${fwUpdateCheckNewStateStr}.\n" nvram commit - if "$runfwUpdateCheck" - then - printf "\nChecking for new F/W Updates... Please wait.\n" - sh $FW_UpdateCheckScript 2>&1 - fi + "$runfwUpdateCheck" && sh $FW_UpdateCheckScript 2>&1 & _WaitForEnterKey_ "$menuReturnPromptStr" } @@ -2307,29 +2298,9 @@ _EntwareServicesHandler_() then printf "\n${actionStr} Entware services... Please wait.\n" $entwOPT_unslung $1 ; sleep 5 - printf "\nDone.\n" fi } -##-------------------------------------## -## Added by Martinski W. [2024-Jan-28] ## -##-------------------------------------## -_UnmountUSBDrives_() -{ - local theDevice mountPointRegExp="^/dev/sd[a-z][0-9]+.* /tmp/mnt/.*" - - mountedDevices="$(grep -E "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $1}')" - [ -z "$mountedDevices" ] && return 1 - - "$isInteractive" && \ - printf "\nUnmounting USB-attached drives. Please wait...\n" - - for theDevice in $mountedDevices - do umount -f "$theDevice" 2>/dev/null; sleep 2 ; done - - printf "\nDone.\n" -} - ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-25] ## ##----------------------------------------## @@ -2413,7 +2384,7 @@ Please manually update to version $minimum_supported_version or higher to use th # Get current firmware version # current_version="$(_GetCurrentFWInstalledShortVersion_)" - ##FOR DEBUG ONLY##current_version="388.6.beta1" + ##FOR DEBUG ONLY##current_version="388.5.0" #---------------------------------------------------------# # If the "F/W Update Check" in the WebGUI is disabled @@ -2674,13 +2645,12 @@ Please manually update to version $minimum_supported_version or higher to use th Say "Required RAM: ${required_space_kb} KB - RAM Free: ${freeRAM_kb} KB - RAM Available: ${availableRAM_kb} KB" check_memory_and_prompt_reboot "$required_space_kb" "$availableRAM_kb" - # Check for the presence of backupmon.sh script (Commented out until issues resolved) - if [ -f "/jffs/scripts/backupmon.sh" ] && [ -f "/jffs/addons/backupmon.d/version.txt" ]; then - - # Read version number from version.txt - BM_VERSION=$(cat /jffs/addons/backupmon.d/version.txt) + # Check for the presence of backupmon.sh script + if [ -f "/jffs/scripts/backupmon.sh" ]; then + # Extract version number from backupmon.sh + BM_VERSION=$(grep "^Version=" /jffs/scripts/backupmon.sh | awk -F'"' '{print $2}') - # Convert both current and required versions to numeric format + # Compare current version with the required version current_version=$(_ScriptVersionStrToNum_ "$BM_VERSION") required_version=$(_ScriptVersionStrToNum_ "1.44") @@ -2782,9 +2752,6 @@ Please manually update to version $minimum_supported_version or higher to use th Say "Flashing ${GRNct}${firmware_file}${NOct}... ${REDct}Please wait for reboot in about 4 minutes or less.${NOct}" echo - # *WARNING*: No more logging at this point & beyond # - _UnmountUSBDrives_ - nohup curl "${routerURLstr}/upgrade.cgi" \ --referer ${routerURLstr}/Advanced_FirmwareUpgrade_Content.asp \ --user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ From 871c78193b55d866c0acf18e74ef32344996c407 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 29 Jan 2024 02:05:07 -0500 Subject: [PATCH 60/63] Update MerlinAU.sh --- MerlinAU.sh | 100 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 34 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 2d13f9d4..60835174 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -228,7 +228,7 @@ FW_UpdateCheckScript="/usr/sbin/webs_update.sh" _GetDefaultUSBMountPoint_() { local mounPointPath retCode=0 - local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" + local mountPointRegExp="^/dev/sd.* /tmp/mnt/.*" mounPointPath="$(grep -m1 "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" [ -z "$mounPointPath" ] && retCode=1 @@ -368,48 +368,53 @@ _ScriptVersionStrToNum_() echo "$verNum" ; return 0 } -##------------------------------------------------## -## Added/Modified by ExtremeFiretop [2024-Jan-28] ## -##------------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Jan-28] ## +##----------------------------------------## _FWVersionStrToNum_() { - if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] - then echo ; return 1 ; fi - - USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" + if [ $# -eq 0 ] || [ -z "$1" ] || [ -z "$2" ] + then echo ; return 1 ; fi - local verNum - local verStr="$1" - local betaWeight=0 + USE_BETA_WEIGHT="$(Get_Custom_Setting FW_Allow_Beta_Production_Up)" - if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && echo "$verStr" | grep -q 'beta'; then - betaWeight=-1000 - verStr=$(echo "$verStr" | sed 's/beta[0-9]*//') # Remove 'beta' and any following numbers + local verNum verStr="$1" nonProductionVersionWeight=0 + local fwBranchVers="" numFields - if [ "$(echo "$verStr" | awk -F '.' '{print NF}')" -lt "$2" ] - then verStr="$(nvram get firmver | sed 's/\.//g').$verStr" ; fi + # Check for 'alpha/beta' in the version string and + # adjust weight value if USE_BETA_WEIGHT is true + if [ "$USE_BETA_WEIGHT" = "ENABLED" ] && \ + echo "$verStr" | grep -qiE 'alpha|beta' + then + nonProductionVersionWeight=-100 + # Remove 'alpha/beta' and any following numbers # + verStr="$(echo "$verStr" | sed 's/[Aa]lpha[0-9]*// ; s/[Bb]eta[0-9]*//')" + fi - if [ "$2" -lt 4 ]; then - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%01d\n", $1,$2,$3}') - else - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%d%01d\n", $1,$2,$3,$4}') - fi + numFields="$(echo "$verStr" | awk -F '.' '{print NF}')" - verNum=$((verNum + betaWeight)) + if [ "$numFields" -lt "$2" ] + then fwBranchVers="$(nvram get firmver | sed 's/\.//g')" ; fi - else - if [ "$(echo "$1" | awk -F '.' '{print NF}')" -lt "$2" ] - then verStr="$(nvram get firmver | sed 's/\.//g').$1" ; fi + #----------------------------------------------------------- + # Temporarily remove Branch version to avoid issues with + # integers greater than the maximum 32-bit signed integer + # when doing arithmetic computations with shell cmds. + #----------------------------------------------------------- + if [ "$numFields" -gt 3 ] + then + fwBranchVers="$(echo "$verStr" | cut -d'.' -f1)" + verStr="$(echo "$verStr" | cut -d'.' -f2-)" + fi + verNum="$(echo "$verStr" | awk -F '.' '{printf ("%d%02d%01d\n", $1,$2,$3);}')" - if [ "$2" -lt 4 ]; then - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%03d%01d\n", $1,$2,$3}') - else - verNum=$(echo "$verStr" | awk -F '.' '{printf "%d%d%d%01d\n", $1,$2,$3,$4}') - fi + # Subtract non-production weight from the version number # + verNum="$((verNum + nonProductionVersionWeight))" - fi + # Now add the F/W Branch version # + [ -n "$fwBranchVers" ] && verNum="${fwBranchVers}$verNum" - echo "$verNum" ; return 0 + echo "$verNum" ; return 0 } ##--------------------------------------------## @@ -556,7 +561,7 @@ _ValidateUSBMountPoint_() local mounPointPaths expectedPath local symblPath realPath1 realPath2 foundPathOK - local mountPointRegExp="/dev/sd.* /tmp/mnt/.*" + local mountPointRegExp="^/dev/sd.* /tmp/mnt/.*" mounPointPaths="$(grep "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $2}')" [ -z "$mounPointPaths" ] && return 1 @@ -2266,7 +2271,11 @@ _Toggle_FW_UpdateCheckSetting_() printf "Router's built-in Firmware Update Check is now ${fwUpdateCheckNewStateStr}.\n" nvram commit - "$runfwUpdateCheck" && sh $FW_UpdateCheckScript 2>&1 & + if "$runfwUpdateCheck" + then + printf "\nChecking for new F/W Updates... Please wait.\n" + sh $FW_UpdateCheckScript 2>&1 + fi _WaitForEnterKey_ "$menuReturnPromptStr" } @@ -2298,9 +2307,29 @@ _EntwareServicesHandler_() then printf "\n${actionStr} Entware services... Please wait.\n" $entwOPT_unslung $1 ; sleep 5 + printf "\nDone.\n" fi } +##-------------------------------------## +## Added by Martinski W. [2024-Jan-28] ## +##-------------------------------------## +_UnmountUSBDrives_() +{ + local theDevice mountPointRegExp="^/dev/sd[a-z][0-9]+.* /tmp/mnt/.*" + + mountedDevices="$(grep -E "$mountPointRegExp" /proc/mounts | awk -F ' ' '{print $1}')" + [ -z "$mountedDevices" ] && return 1 + + "$isInteractive" && \ + printf "\nUnmounting USB-attached drives. Please wait...\n" + + for theDevice in $mountedDevices + do umount -f "$theDevice" 2>/dev/null; sleep 2 ; done + + printf "\nDone.\n" +} + ##----------------------------------------## ## Modified by Martinski W. [2024-Jan-25] ## ##----------------------------------------## @@ -2752,6 +2781,9 @@ Please manually update to version $minimum_supported_version or higher to use th Say "Flashing ${GRNct}${firmware_file}${NOct}... ${REDct}Please wait for reboot in about 4 minutes or less.${NOct}" echo + # *WARNING*: No more logging at this point & beyond # + _UnmountUSBDrives_ + nohup curl "${routerURLstr}/upgrade.cgi" \ --referer ${routerURLstr}/Advanced_FirmwareUpgrade_Content.asp \ --user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ From 286f24a742301a9b35845d8e31fbb3f74a98de84 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 29 Jan 2024 02:48:51 -0500 Subject: [PATCH 61/63] Update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 71ff411c..d3827e75 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.2.54 +1.0 From cb846929f88fa61aafed262954a478e1c90da737 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 29 Jan 2024 03:14:12 -0500 Subject: [PATCH 62/63] Update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index d3827e75..3eefcb9d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0 +1.0.0 From a1f9a45203f7d7fb71250778233258a9f89b319b Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 29 Jan 2024 03:14:36 -0500 Subject: [PATCH 63/63] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 60835174..3649c3b5 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -9,7 +9,7 @@ set -u #For AMTM versioning: -readonly SCRIPT_VERSION=1.0 +readonly SCRIPT_VERSION=1.0.0 readonly SCRIPT_NAME="MerlinAU" ##-------------------------------------##