From d5d92e048ec5c9ee81f750f537ed15e161a2d5fc Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 1 Dec 2024 18:44:20 -0500 Subject: [PATCH 01/10] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b1841aa7..14f362ed 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -12,7 +12,7 @@ set -u readonly SCRIPT_VERSION=1.3.8 readonly SCRIPT_NAME="MerlinAU" ## Set to "master" for Production Releases ## -SCRIPT_BRANCH="master" +SCRIPT_BRANCH="dev" ##----------------------------------------## ## Modified by Martinski W. [2024-Jul-03] ## From 4d30be2373d5e3cd6463329a1dc714ac6e6348ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 23:55:20 +0000 Subject: [PATCH 02/10] Bump softprops/action-gh-release in the all-actions group Bumps the all-actions group with 1 update: [softprops/action-gh-release](https://github.com/softprops/action-gh-release). Updates `softprops/action-gh-release` from 2.1.0 to 2.2.0 - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v2.1.0...v2.2.0) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/Create-NewReleases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Create-NewReleases.yml b/.github/workflows/Create-NewReleases.yml index dd052435..47af0d2b 100644 --- a/.github/workflows/Create-NewReleases.yml +++ b/.github/workflows/Create-NewReleases.yml @@ -85,7 +85,7 @@ jobs: git push origin ${{ steps.nextver.outputs.tag }} - name: Create Release with Automated Release Notes - uses: softprops/action-gh-release@v2.1.0 + uses: softprops/action-gh-release@v2.2.0 with: token: ${{ secrets.GITHUB_TOKEN }} tag_name: ${{ steps.nextver.outputs.tag }} From e548e7823a08b13da26c14078612afbfb8059bb3 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sun, 22 Dec 2024 00:41:29 -0800 Subject: [PATCH 03/10] Minor UI Improvement Added a user-friendly/human-readable schedule line below the "F/W Update Cron Schedule" menu option. --- MerlinAU.sh | 68 +++++++++++++++++++++++++++++++++++++---------------- README.md | 4 ++-- version.txt | 2 +- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 14f362ed..1c18eec3 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,12 +4,12 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2024-Dec-01 +# Last Modified: 2024-Dec-21 ################################################################### set -u ## Set version for each Production Release ## -readonly SCRIPT_VERSION=1.3.8 +readonly SCRIPT_VERSION=1.3.9 readonly SCRIPT_NAME="MerlinAU" ## Set to "master" for Production Releases ## SCRIPT_BRANCH="dev" @@ -4704,9 +4704,9 @@ _TranslateCronSchedHR_() infoStrDAYS="every $freqNumDAYW days of the week, in every month" elif echo "$theCronDAYW" | grep -qE "[,-]" then - infoStrDAYS="days $theCronDAYW of the week, in every month" + infoStrDAYS="days ${theCronDAYW}, in every month" else - infoStrDAYS="day $theCronDAYW of the week, in every month" + infoStrDAYS="day ${theCronDAYW}, in every month" fi elif [ "$theCronDAYM" != "*" ] then @@ -4736,7 +4736,7 @@ _TranslateCronSchedHR_() else hasFreqMINS=false ; freqNumMINS="" fi - if [ "$theCronHOUR" = "*" ] && [ "$theCronMINS" -eq 0 ] + if [ "$theCronHOUR" = "*" ] && [ "$theCronMINS" = "0" ] then schedInfoStr="Every hour" elif [ "$theCronHOUR" = "*" ] && [ "$theCronMINS" = "*" ] @@ -4745,7 +4745,7 @@ _TranslateCronSchedHR_() elif [ "$theCronHOUR" = "*" ] && _IsValidNumber_ "$theCronMINS" then schedInfoStr="Every hour at minute $theCronMINS" - elif "$hasFreqHOUR" && [ "$theCronMINS" -eq 0 ] + elif "$hasFreqHOUR" && [ "$theCronMINS" = "0" ] then schedInfoStr="Every $freqNumHOUR hours" elif "$hasFreqHOUR" && [ "$theCronMINS" = "*" ] @@ -4774,12 +4774,12 @@ _TranslateCronSchedHR_() schedInfoStr="$theCronHOUR, every $freqNumMINS minutes" elif [ "$theCronHOUR" = "*" ] then - schedInfoStr="Every hour, Minutes: $theCronMINS" + schedInfoStr="Every hour, Minutes: $theCronMINS" elif [ "$theCronMINS" = "*" ] then schedInfoStr="$theCronHOUR, every minute" else - schedInfoStr="$theCronHOUR, Minutes: $theCronMINS" + schedInfoStr="$theCronHOUR, Minutes: $theCronMINS" fi echo "${schedInfoStr}, $infoStrDAYS" } @@ -5116,15 +5116,25 @@ _ShowCronMenuHeader_() printf "${SEPstr}\n" } -##-------------------------------------## -## Added by Martinski W. [2024-Nov-24] ## -##-------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Dec-20] ## +##----------------------------------------## _GetCronScheduleInputDAYofMONTH_() { if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi - local oldSchedDAYM="$1" newSchedDAYM + local oldSchedDAYM newSchedDAYM oldSchedDAYHR + + _GetSchedDaysHR_() + { + local cruDAYS="$1" + [ "$1" = "*" ] && cruDAYS="Every day" + echo "$cruDAYS" + } newSchedDAYM="" + oldSchedDAYM="$1" + oldSchedDAYHR="$(_GetSchedDaysHR_ "$1")" + while true do _ShowCronMenuHeader_ @@ -5136,7 +5146,7 @@ _GetCronScheduleInputDAYofMONTH_() printf " ${GRNct}*/7${NOct}=Every 7 days ${GRNct}*/10${NOct}=Every 10 days ${GRNct}*/15${NOct}=Every 15 days\n" printf "\n[${menuCancelAndExitStr}]\n" - printf "\nEnter ${GRNct}DAYS of the MONTH${NOct} [1-31] ${GRNct}${oldSchedDAYM}${NOct}?: " + printf "\nEnter ${GRNct}DAYS of the MONTH${NOct} [1-31] ${GRNct}${oldSchedDAYHR}${NOct}?: " read -r newSchedDAYM if [ -z "$newSchedDAYM" ] then @@ -5154,15 +5164,32 @@ _GetCronScheduleInputDAYofMONTH_() return 0 } -##-------------------------------------## -## Added by Martinski W. [2024-Nov-24] ## -##-------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Dec-20] ## +##----------------------------------------## _GetCronScheduleInputDAYofWEEK_() { if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi - local oldSchedDAYW="$1" newSchedDAYW + local oldSchedDAYW newSchedDAYW oldSchedDAYHR + + _DayOfWeekNumToDayName_() + { echo "$1" | sed 's/0/Sun/;s/1/Mon/;s/2/Tue/;s/3/Wed/;s/4/Thu/;s/5/Fri/;s/6/Sat/;' ; } + + _GetSchedDaysHR_() + { + local cruDAYS="$1" + if [ "$1" = "*" ] + then cruDAYS="Every day" + elif ! echo "$1" | grep -qE "^[*]/.*" + then cruDAYS="$(_DayOfWeekNumToDayName_ "$1")" + fi + echo "$cruDAYS" + } newSchedDAYW="" + oldSchedDAYW="$1" + oldSchedDAYHR="$(_GetSchedDaysHR_ "$1")" + while true do _ShowCronMenuHeader_ @@ -5176,7 +5203,7 @@ _GetCronScheduleInputDAYofWEEK_() printf " ${GRNct}6,0${NOct}=Sat,Sun ${GRNct}1,3,5${NOct}=Mon,Wed,Fri ${GRNct}2,4${NOct}=Tue,Thu\n" printf "\n[${menuCancelAndExitStr}] [${menuSavedThenExitStr}] [${menuReturnToBeginStr}]\n" - printf "\nEnter ${GRNct}DAYS of the WEEK${NOct} [0-6] ${GRNct}${oldSchedDAYW}${NOct}?: " + printf "\nEnter ${GRNct}DAYS of the WEEK${NOct} [0-6] ${GRNct}${oldSchedDAYHR}${NOct}?: " read -r newSchedDAYW if [ -z "$newSchedDAYW" ] then @@ -8529,7 +8556,7 @@ _ShowMainMenu_() } ##----------------------------------------## -## Modified by Martinski W. [2024-Nov-25] ## +## Modified by Martinski W. [2024-Dec-20] ## ##----------------------------------------## _ShowAdvancedOptionsMenu_() { @@ -8545,7 +8572,8 @@ _ShowAdvancedOptionsMenu_() printf "\n${padStr}[Current Path: ${GRNct}${FW_ZIP_DIR}${NOct}]\n" printf "\n ${GRNct}2${NOct}. Set F/W Update Cron Schedule" - printf "\n${padStr}[Current Schedule: ${GRNct}${FW_UpdateCronJobSchedule}${NOct}]\n" + printf "\n${padStr}[Current Schedule: ${GRNct}${FW_UpdateCronJobSchedule}${NOct}]" + printf "\n${padStr}[${GRNct}%s${NOct}]\n" "$(_TranslateCronSchedHR_ "$FW_UpdateCronJobSchedule")" BetaProductionSetting="$(Get_Custom_Setting "FW_Allow_Beta_Production_Up")" printf "\n ${GRNct}3${NOct}. Toggle Beta-to-Release F/W Updates" diff --git a/README.md b/README.md index 26ce4fb9..8e4e1f10 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater -## v1.3.8 -## 2024-Dec-01 +## v1.3.9 +## 2024-Dec-21 ![image](https://github.com/user-attachments/assets/185f9fe4-acdb-419a-8154-ab6fa6e0fd46) ![image](https://github.com/user-attachments/assets/8f22818d-2118-4c47-a54a-e54fb147fd6b) diff --git a/version.txt b/version.txt index e05cb332..d4c4950a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.3.8 +1.3.9 From f9c9ac9161c6b86dd091af2606ef6ebd3865c418 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Sun, 22 Dec 2024 12:59:15 -0500 Subject: [PATCH 04/10] Update MerlinAU.sh --- MerlinAU.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index 1c18eec3..c9238422 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8613,7 +8613,8 @@ _ShowAdvancedOptionsMenu_() else printf "\n${padStr}[Currently ${MAGENTAct}ENABLED${NOct}]\n" scriptUpdateCronSched="$(_GetScriptAutoUpdateCronSchedule_)" - printf "${padStr}[Current Schedule: ${GRNct}${scriptUpdateCronSched}${NOct}]\n" + printf "${padStr}[Current Schedule: ${GRNct}${scriptUpdateCronSched}${NOct}]" + printf "\n${padStr}[${GRNct}%s${NOct}]\n" "$(_TranslateCronSchedHR_ "$scriptUpdateCronSched")" fi if "$isGNUtonFW" From 64a2b81dda28c74505f0c542a3438adce9778eb5 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sun, 22 Dec 2024 10:56:39 -0800 Subject: [PATCH 05/10] Minor UI Improvement Just a minor improvement in the "'Toggle Auto-Updates for MerlinAU Script" option to make simpler and less crowded when ENABLED. --- MerlinAU.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index c9238422..bd581074 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-Dec-21 +# Last Modified: 2024-Dec-22 ################################################################### set -u @@ -8556,7 +8556,7 @@ _ShowMainMenu_() } ##----------------------------------------## -## Modified by Martinski W. [2024-Dec-20] ## +## Modified by Martinski W. [2024-Dec-22] ## ##----------------------------------------## _ShowAdvancedOptionsMenu_() { @@ -8611,9 +8611,8 @@ _ShowAdvancedOptionsMenu_() then printf "\n${padStr}[Currently ${GRNct}DISABLED${NOct}]\n" else - printf "\n${padStr}[Currently ${MAGENTAct}ENABLED${NOct}]\n" scriptUpdateCronSched="$(_GetScriptAutoUpdateCronSchedule_)" - printf "${padStr}[Current Schedule: ${GRNct}${scriptUpdateCronSched}${NOct}]" + printf "\n${padStr}[Current Schedule: ${GRNct}${scriptUpdateCronSched}${NOct}]" printf "\n${padStr}[${GRNct}%s${NOct}]\n" "$(_TranslateCronSchedHR_ "$scriptUpdateCronSched")" fi From 2f2f0e7d437ccb96d03dd58c0d0081c510e519ce Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Mon, 30 Dec 2024 09:25:58 -0500 Subject: [PATCH 06/10] Update MerlinAU.sh Small Improvements --- MerlinAU.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index bd581074..a3c87065 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1686,8 +1686,8 @@ _CreateEMailContent_() fwNewUpdateVersion="$(Get_Custom_Setting "FW_New_Update_Notification_Vers")" fi - #Remove any suffix starting with "-" or "_" to avoid version comparison failures# - fwInstalledVersion="$(echo "$fwInstalledVersion" | sed -E 's/[-_].*$//')" + # Remove "_rog" or "_tuf" or -gHASHVALUES or -Gnuton* suffix to avoid version comparison failure, can't remove all for proper beta and alpha comparison # + fwInstalledVersion="$(echo "$fwInstalledVersion" | sed -E 's/(_(rog|tuf)|-g[0-9a-f]{10}|-gnuton[0-9]+)$//')" case "$1" in FW_UPDATE_TEST_EMAIL) @@ -8722,7 +8722,7 @@ _ShowAdvancedOptionsMenu_() fi if "$sendEMailNotificationsFlag" then - printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}, Format: ${GRNct}${sendEMailFormaType}${NOct}]\n" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}\n" else printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" fi From 9c5f9c92af097fec6632d4fbd51f773b038196d6 Mon Sep 17 00:00:00 2001 From: Joel Samson Date: Tue, 31 Dec 2024 00:50:58 -0500 Subject: [PATCH 07/10] Update MerlinAU.sh --- MerlinAU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index a3c87065..de90eb6e 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -8722,7 +8722,7 @@ _ShowAdvancedOptionsMenu_() fi if "$sendEMailNotificationsFlag" then - printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}\n" + printf "\n${padStr}[Currently ${GRNct}ENABLED${NOct}]\n" else printf "\n${padStr}[Currently ${REDct}DISABLED${NOct}]\n" fi From f8f713cd4ab2760d5aa06e3fa46f64bf68d56b45 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Tue, 31 Dec 2024 07:56:17 -0800 Subject: [PATCH 08/10] Code Improvements for Script Updates Code improvements when checking for available script updates and performing automatic script updates. --- MerlinAU.sh | 112 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index de90eb6e..b0705792 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-Dec-22 +# Last Modified: 2024-Dec-31 ################################################################### set -u @@ -36,8 +36,13 @@ readonly CL_URL_3006="${FW_SFURL_BASE}/Documentation/Changelog-3006.txt/download readonly high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended" +##----------------------------------------## +## Modified by Martinski W. [2024-Dec-31] ## +##----------------------------------------## # For new script version updates from source repository # DLRepoVersion="" +DLRepoVersionNum="" +ScriptVersionNum="" scriptUpdateNotify=0 ##------------------------------------------## @@ -1492,16 +1497,32 @@ then Update_Custom_Settings FW_New_Update_LOG_Directory_Path "$UserPreferredLogPath" fi -##------------------------------------------## -## Modified by ExtremeFiretop [2024-Nov-18] ## -##------------------------------------------## +##-------------------------------------## +## Added by Martinski W. [2024-Dec-31] ## +##-------------------------------------## +# Temporary function used to migrate to future new script version # +_CheckForNewGUIVersionUpdate_() +{ + local newGUIversionNum retCode + newGUIversionNum="$(_ScriptVersionStrToNum_ '1.4.0')" + if [ "$ScriptVersionNum" -lt "$newGUIversionNum" ] && \ + [ "$DLRepoVersionNum" -ge "$newGUIversionNum" ] + then retCode=0 + else retCode=1 + fi + return "$retCode" +} + +##----------------------------------------## +## Modified by Martinski W. [2024-Dec-31] ## +##----------------------------------------## _SCRIPTUPDATE_() { - local scriptVers ScriptFileDL="${ScriptFilePath}.DL" + local urlScriptVers preScriptVers extraParam="" _DownloadScriptFiles_() { - local retCode + local retCode ScriptFileDL="${ScriptFilePath}.DL" curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt" -o "$SCRIPTVERPATH" curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/${SCRIPT_NAME}.sh" -o "$ScriptFileDL" @@ -1521,21 +1542,26 @@ _SCRIPTUPDATE_() if [ $# -gt 0 ] && [ "$1" = "force" ] then - echo -e "${CYANct}Force downloading latest version...${NOct}" - scriptVers="$(/usr/sbin/curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt")" - echo -e "${CYANct}Downloading latest version ($scriptVers) of ${SCRIPT_NAME}${NOct}" + printf "\n${CYANct}Force downloading latest script version...${NOct}\n" + preScriptVers="$SCRIPT_VERSION" + [ -s "$SCRIPTVERPATH" ] && preScriptVers="$(cat "$SCRIPTVERPATH")" + urlScriptVers="$(/usr/sbin/curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt")" + printf "${CYANct}Downloading latest version ($urlScriptVers) of ${SCRIPT_NAME}${NOct}\n" if _DownloadScriptFiles_ then - echo -e "${CYANct}$SCRIPT_NAME successfully updated.${NOct}" + printf "${CYANct}$SCRIPT_NAME successfully updated.${NOct}\n\n" + sleep 1 + if [ $# -gt 1 ] && [ "$2" = "newgui" ] && [ "$urlScriptVers" != "$preScriptVers" ] + then extraParam="forceupdate" ; fi _ReleaseLock_ - chmod 755 "$ScriptFilePath" - exec "$ScriptFilePath" + exec "$ScriptFilePath" $extraParam + exit 0 fi - return + return 0 fi - _CheckForNewScriptUpdates_ + ! _CheckForNewScriptUpdates_ && return 1 clear logo @@ -1549,21 +1575,17 @@ _SCRIPTUPDATE_() echo -e "${CYANct}This will overwrite your currently installed version.${NOct}" if _WaitForYESorNO_ then - printf "\n\n" - echo -e "${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}" + printf "\n\n${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}\n" if _DownloadScriptFiles_ then - echo - echo -e "${CYANct}Download successful!${NOct}" - echo -e "$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v$DLRepoVersion" - echo + printf "\n${CYANct}Download successful!${NOct}\n" + printf "$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n" fi _WaitForEnterKey_ return else - printf "\n\n" - echo -e "${GRNct}Exiting Script Update Utility...${NOct}" + printf "\n\n${GRNct}Exiting Script Update Utility...${NOct}\n" sleep 1 return fi @@ -1572,39 +1594,36 @@ _SCRIPTUPDATE_() echo -e "${CYANct}Bingo! New version available! Would you like to update now?${NOct}" if _WaitForYESorNO_ then - printf "\n\n" - echo -e "${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}" + printf "\n\n${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}\n" if _DownloadScriptFiles_ then - echo - echo -e "$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v$DLRepoVersion" - echo -e "${CYANct}Update successful! Restarting script...${NOct}" + printf "\n$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n" + printf "${CYANct}Update successful! Restarting script...${NOct}\n" + _CheckForNewGUIVersionUpdate_ && extraParam="forceupdate" _ReleaseLock_ - chmod 755 "$ScriptFilePath" - exec "$ScriptFilePath" # Re-execute the updated script # - exit 0 # This line will not be executed due to above exec # + exec "$ScriptFilePath" $extraParam + exit 0 else _WaitForEnterKey_ return fi else - printf "\n\n" - echo -e "${GRNct}Exiting Script Update Utility...${NOct}" + printf "\n\n${GRNct}Exiting Script Update Utility...${NOct}\n" sleep 1 return fi fi } -##------------------------------------------## -## Modified by ExtremeFiretop [2024-Nov-18] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2024-Dec-31] ## +##----------------------------------------## _CheckForNewScriptUpdates_() { - local DLRepoVersionNum ScriptVersionNum + local extraParam="" - echo "" + echo [ -s "$SCRIPTVERPATH" ] && DLRepoVersion="$(cat "$SCRIPTVERPATH")" rm -f "$SCRIPTVERPATH" @@ -1626,19 +1645,20 @@ _CheckForNewScriptUpdates_() DLRepoVersionNum="$(_ScriptVersionStrToNum_ "$DLRepoVersion")" ScriptVersionNum="$(_ScriptVersionStrToNum_ "$SCRIPT_VERSION")" - # Version comparison if [ "$DLRepoVersionNum" -gt "$ScriptVersionNum" ] then scriptUpdateNotify="New script update available. ${REDct}v${SCRIPT_VERSION}${NOct} --> ${GRNct}v${DLRepoVersion}${NOct}" - Say "$(date +'%b %d %Y %X') $myLAN_HostName ${ScriptFNameTag}_[$$] - INFO: A new script update (v$DLRepoVersion) is available to download." + Say "$myLAN_HostName - A new script version update (v$DLRepoVersion) is available to download." if [ "$ScriptAutoUpdateSetting" = "ENABLED" ] then - _SCRIPTUPDATE_ force + _CheckForNewGUIVersionUpdate_ && extraParam="newgui" + _SCRIPTUPDATE_ force $extraParam fi else scriptUpdateNotify=0 fi + return 0 } ##----------------------------------------------## @@ -8002,13 +8022,13 @@ check_version_support ##-------------------------------------## _CheckEMailConfigFileFromAMTM_ 0 -##------------------------------------------## -## Modified by ExtremeFiretop [2024-Nov-18] ## -##------------------------------------------## -if [ $# -gt 0 ] +##----------------------------------------## +## Modified by Martinski W. [2024-Dec-31] ## +##----------------------------------------## +if [ $# -gt 0 ] && [ -n "$1" ] then inMenuMode=false - case $1 in + case "$1" in run_now) _RunFirmwareUpdateNow_ ;; processNodes) _ProcessMeshNodes_ 0 @@ -8027,7 +8047,7 @@ then ;; checkupdates) _CheckForNewScriptUpdates_ ;; - forceupdate) _SCRIPTUPDATE_ force + forceupdate) _SCRIPTUPDATE_ force "$([ $# -gt 1 ] && echo "$2" || echo)" ;; develop) _ChangeToDev_ ;; From 145740c52a27cdfac0d4e981f7baabbe244a5f47 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:57:52 -0800 Subject: [PATCH 09/10] Code Improvements for Script Updates Further code improvements. --- MerlinAU.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index b0705792..ad360ba4 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1500,13 +1500,21 @@ fi ##-------------------------------------## ## Added by Martinski W. [2024-Dec-31] ## ##-------------------------------------## -# Temporary function used to migrate to future new script version # +newGUIversionNum="$(_ScriptVersionStrToNum_ '1.4.0')" +# Temporary code used to migrate to future new script version # _CheckForNewGUIVersionUpdate_() { - local newGUIversionNum retCode - newGUIversionNum="$(_ScriptVersionStrToNum_ '1.4.0')" - if [ "$ScriptVersionNum" -lt "$newGUIversionNum" ] && \ - [ "$DLRepoVersionNum" -ge "$newGUIversionNum" ] + local retCode theScriptVerNum urlScriptVerNum + if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] + then + theScriptVerNum="$ScriptVersionNum" + urlScriptVerNum="$DLRepoVersionNum" + else + theScriptVerNum="$(_ScriptVersionStrToNum_ "$1")" + urlScriptVerNum="$(_ScriptVersionStrToNum_ "$2")" + fi + if [ "$theScriptVerNum" -lt "$newGUIversionNum" ] && \ + [ "$urlScriptVerNum" -ge "$newGUIversionNum" ] then retCode=0 else retCode=1 fi @@ -1518,7 +1526,7 @@ _CheckForNewGUIVersionUpdate_() ##----------------------------------------## _SCRIPTUPDATE_() { - local urlScriptVers preScriptVers extraParam="" + local urlScriptVers theScriptVers extraParam="" _DownloadScriptFiles_() { @@ -1543,8 +1551,8 @@ _SCRIPTUPDATE_() if [ $# -gt 0 ] && [ "$1" = "force" ] then printf "\n${CYANct}Force downloading latest script version...${NOct}\n" - preScriptVers="$SCRIPT_VERSION" - [ -s "$SCRIPTVERPATH" ] && preScriptVers="$(cat "$SCRIPTVERPATH")" + theScriptVers="$SCRIPT_VERSION" + [ -s "$SCRIPTVERPATH" ] && theScriptVers="$(cat "$SCRIPTVERPATH")" urlScriptVers="$(/usr/sbin/curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt")" printf "${CYANct}Downloading latest version ($urlScriptVers) of ${SCRIPT_NAME}${NOct}\n" @@ -1552,7 +1560,8 @@ _SCRIPTUPDATE_() then printf "${CYANct}$SCRIPT_NAME successfully updated.${NOct}\n\n" sleep 1 - if [ $# -gt 1 ] && [ "$2" = "newgui" ] && [ "$urlScriptVers" != "$preScriptVers" ] + if [ $# -gt 1 ] && [ "$2" = "newgui" ] && \ + _CheckForNewGUIVersionUpdate_ "$theScriptVers" "$urlScriptVers" then extraParam="forceupdate" ; fi _ReleaseLock_ exec "$ScriptFilePath" $extraParam From 7692a2a51c86ab2f505e1be93e5d63fdf7322292 Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 1 Jan 2025 21:31:20 -0800 Subject: [PATCH 10/10] Code Improvements for Script Downloads Some code improvements when downloading script files. --- MerlinAU.sh | 102 +++++++++++++++++++++++++++++++--------------------- README.md | 2 +- 2 files changed, 63 insertions(+), 41 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index ad360ba4..b323a97d 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-Dec-31 +# Last Modified: 2025-Jan-01 ################################################################### set -u @@ -475,9 +475,9 @@ Toggle_LEDs_PID="" FW_UpdateCheckState="TBD" FW_UpdateCheckScript="/usr/sbin/webs_update.sh" -##--------------------------------------## -## Added by Martinski W. [22023-Nov-24] ## -##--------------------------------------## +##-------------------------------------## +## Added by Martinski W. [2023-Nov-24] ## +##-------------------------------------## #---------------------------------------------------------# # The USB-attached drives can have multiple partitions # with different file systems (NTFS, ext3, ext4, etc.), @@ -1521,8 +1521,27 @@ _CheckForNewGUIVersionUpdate_() return "$retCode" } +##-------------------------------------## +## Added by Martinski W. [2025-Jan-01] ## +##-------------------------------------## +_CurlFileDownload_() +{ + if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] + then return 1 ; fi + local retCode tempFilePathDL="${2}.DL.TMP" + + curl -LSs --retry 4 --retry-delay 5 --retry-connrefused \ + "$1" -o "$tempFilePathDL" + if [ $? -ne 0 ] && [ ! -s "$tempFilePathDL" ] || \ + grep -iq "^404: Not Found" "$tempFilePathDL" + then rm -f "$tempFilePathDL" ; retCode=1 + else mv -f "$tempFilePathDL" "$2" ; retCode=0 + fi + return "$retCode" +} + ##----------------------------------------## -## Modified by Martinski W. [2024-Dec-31] ## +## Modified by Martinski W. [2025-Jan-01] ## ##----------------------------------------## _SCRIPTUPDATE_() { @@ -1530,20 +1549,20 @@ _SCRIPTUPDATE_() _DownloadScriptFiles_() { - local retCode ScriptFileDL="${ScriptFilePath}.DL" - - curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt" -o "$SCRIPTVERPATH" - curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/${SCRIPT_NAME}.sh" -o "$ScriptFileDL" - - if [ $? -eq 0 ] && [ -s "$ScriptFileDL" ] + local retCode + if _CurlFileDownload_ "${SCRIPT_URL_REPO}/version.txt" "$SCRIPTVERPATH" then - mv -f "$ScriptFileDL" "$ScriptFilePath" - chmod 755 "$ScriptFilePath" - retCode=0 + retCode=0 ; chmod 664 "$SCRIPTVERPATH" else - rm -f "$ScriptFileDL" - printf "\n${REDct}Download failed.${NOct}\n" retCode=1 + Say "${REDct}**ERROR**${NOct}: Unable to download latest version file for $SCRIPT_NAME." + fi + if _CurlFileDownload_ "${SCRIPT_URL_REPO}/${SCRIPT_NAME}.sh" "$ScriptFilePath" + then + retCode=0 ; chmod 755 "$ScriptFilePath" + else + retCode=1 + Say "${REDct}**ERROR**${NOct}: Unable to download latest script file for $SCRIPT_NAME." fi return "$retCode" } @@ -1558,8 +1577,9 @@ _SCRIPTUPDATE_() if _DownloadScriptFiles_ then - printf "${CYANct}$SCRIPT_NAME successfully updated.${NOct}\n\n" + printf "${CYANct}$SCRIPT_NAME was successfully updated.${NOct}\n\n" sleep 1 + [ -s "$SCRIPTVERPATH" ] && urlScriptVers="$(cat "$SCRIPTVERPATH")" if [ $# -gt 1 ] && [ "$2" = "newgui" ] && \ _CheckForNewGUIVersionUpdate_ "$theScriptVers" "$urlScriptVers" then extraParam="forceupdate" ; fi @@ -1584,7 +1604,7 @@ _SCRIPTUPDATE_() echo -e "${CYANct}This will overwrite your currently installed version.${NOct}" if _WaitForYESorNO_ then - printf "\n\n${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}\n" + printf "\n\n${CYANct}Downloading $SCRIPT_NAME $DLRepoVersion version.${NOct}\n" if _DownloadScriptFiles_ then @@ -1603,12 +1623,13 @@ _SCRIPTUPDATE_() echo -e "${CYANct}Bingo! New version available! Would you like to update now?${NOct}" if _WaitForYESorNO_ then - printf "\n\n${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}\n" + printf "\n\n${CYANct}Downloading $SCRIPT_NAME $DLRepoVersion version.${NOct}\n" if _DownloadScriptFiles_ then printf "\n$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v${DLRepoVersion}\n" printf "${CYANct}Update successful! Restarting script...${NOct}\n" + sleep 1 _CheckForNewGUIVersionUpdate_ && extraParam="forceupdate" _ReleaseLock_ exec "$ScriptFilePath" $extraParam @@ -1626,27 +1647,28 @@ _SCRIPTUPDATE_() } ##----------------------------------------## -## Modified by Martinski W. [2024-Dec-31] ## +## Modified by Martinski W. [2025-Jan-01] ## ##----------------------------------------## _CheckForNewScriptUpdates_() { local extraParam="" echo + DLRepoVersion="$SCRIPT_VERSION" [ -s "$SCRIPTVERPATH" ] && DLRepoVersion="$(cat "$SCRIPTVERPATH")" rm -f "$SCRIPTVERPATH" - # Download the latest version file from the source repository - curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt" -o "$SCRIPTVERPATH" - - if [ $? -ne 0 ] || [ ! -s "$SCRIPTVERPATH" ] - then scriptUpdateNotify=0 ; return 1 ; fi + if ! _CurlFileDownload_ "${SCRIPT_URL_REPO}/version.txt" "$SCRIPTVERPATH" + then + Say "${REDct}**ERROR**${NOct}: Unable to download latest version file for $SCRIPT_NAME." + scriptUpdateNotify=0 + return 1 + fi - # Read in its contents for the current version file DLRepoVersion="$(cat "$SCRIPTVERPATH")" if [ -z "$DLRepoVersion" ] then - echo "Variable for downloaded version is empty." + Say "${REDct}**ERROR**${NOct}: Variable for downloaded version is empty." scriptUpdateNotify=0 return 1 fi @@ -1656,16 +1678,16 @@ _CheckForNewScriptUpdates_() if [ "$DLRepoVersionNum" -gt "$ScriptVersionNum" ] then - scriptUpdateNotify="New script update available. + scriptUpdateNotify="New script update available. ${REDct}v${SCRIPT_VERSION}${NOct} --> ${GRNct}v${DLRepoVersion}${NOct}" - Say "$myLAN_HostName - A new script version update (v$DLRepoVersion) is available to download." - if [ "$ScriptAutoUpdateSetting" = "ENABLED" ] - then - _CheckForNewGUIVersionUpdate_ && extraParam="newgui" - _SCRIPTUPDATE_ force $extraParam - fi + Say "$myLAN_HostName - A new script version update (v$DLRepoVersion) is available to download." + if [ "$ScriptAutoUpdateSetting" = "ENABLED" ] + then + _CheckForNewGUIVersionUpdate_ && extraParam="newgui" + _SCRIPTUPDATE_ force $extraParam + fi else - scriptUpdateNotify=0 + scriptUpdateNotify=0 fi return 0 } @@ -3124,7 +3146,7 @@ _GetNodeInfo_() return 1 fi - # Perform login request + # Perform login request # curl -s -k "${NodeURLstr}/login.cgi" \ --referer "${NodeURLstr}/Main_Login.asp" \ --user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ @@ -3142,7 +3164,7 @@ _GetNodeInfo_() return 1 fi - # Run the curl command to retrieve the HTML content + # Retrieve the HTML content # htmlContent="$(curl -s -k "${NodeURLstr}/appGet.cgi?hook=nvram_get(productid)%3bnvram_get(asus_device_list)%3bnvram_get(cfg_device_list)%3bnvram_get(firmver)%3bnvram_get(buildno)%3bnvram_get(extendno)%3bnvram_get(webs_state_flag)%3bnvram_get(odmpid)%3bnvram_get(wps_modelnum)%3bnvram_get(model)%3bnvram_get(build_name)%3bnvram_get(lan_hostname)%3bnvram_get(webs_state_info)%3bnvram_get(label_mac)" \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \ @@ -3182,7 +3204,7 @@ _GetNodeInfo_() # Combine extracted information into one string # Node_combinedVer="${node_firmver}.${node_buildno}.$node_extendno" - # Perform logout request + # Perform logout request # curl -s -k "${NodeURLstr}/Logout.asp" \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \ @@ -7088,9 +7110,9 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or fi fi - # Extracting the F/W Update codebase number to use in the curl # + # Extracting the F/W Update codebase number # fwUpdateBaseNum="$(echo "$release_version" | cut -d'.' -f1)" - # Inserting dots between each number + # Inserting dots between each number # dottedVersion="$(echo "$fwUpdateBaseNum" | sed 's/./&./g' | sed 's/.$//')" ## Check for Login Credentials ## diff --git a/README.md b/README.md index 8e4e1f10..2009f5f8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater ## v1.3.9 -## 2024-Dec-21 +## 2025-Jan-02 ![image](https://github.com/user-attachments/assets/185f9fe4-acdb-419a-8154-ab6fa6e0fd46) ![image](https://github.com/user-attachments/assets/8f22818d-2118-4c47-a54a-e54fb147fd6b)