diff --git a/.github/workflows/Create-NewReleases.yml b/.github/workflows/Create-NewReleases.yml index 0ce29af0..0cd286d9 100644 --- a/.github/workflows/Create-NewReleases.yml +++ b/.github/workflows/Create-NewReleases.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source code - uses: actions/checkout@v5.0.0 + uses: actions/checkout@v6.0.0 with: fetch-depth: 0 ref: 'main' # Ensure we're tagging the main branch after the merge @@ -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.4.1 + uses: softprops/action-gh-release@v2.4.2 with: token: ${{ secrets.GITHUB_TOKEN }} tag_name: ${{ steps.nextver.outputs.tag }} diff --git a/MerlinAU.sh b/MerlinAU.sh index 86910d4e..c21b41f6 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -4,16 +4,16 @@ # # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 -# Last Modified: 2025-Nov-05 +# Last Modified: 2025-Nov-16 ################################################################### set -u ## Set version for each Production Release ## -readonly SCRIPT_VERSION=1.5.6 -readonly SCRIPT_VERSTAG="25110520" +readonly SCRIPT_VERSION=1.5.7 +readonly SCRIPT_VERSTAG="25111620" readonly SCRIPT_NAME="MerlinAU" ## Set to "master" for Production Releases ## -SCRIPT_BRANCH="master" +SCRIPT_BRANCH="dev" ##----------------------------------------## ## Modified by Martinski W. [2024-Jul-03] ## @@ -2544,9 +2544,9 @@ _WebUI_SetEmailConfigFileFromAMTM_() _WriteVarDefToHelperJSFile_ "isEMailConfigEnabledInAMTM" "$isEMailConfigEnabledInAMTM" true } -##------------------------------------------## -## Modified by ExtremeFiretop [2025-May-21] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2025-Nov-16] ## +##----------------------------------------## _ActionsAfterNewConfigSettings_() { if [ ! -s "${CONFIG_FILE}.bak" ] || \ @@ -2555,7 +2555,7 @@ _ActionsAfterNewConfigSettings_() _ConfigOptionChanged_() { - if diff "$CONFIG_FILE" "${CONFIG_FILE}.bak" | grep -q "$1" + if diff -U0 "$CONFIG_FILE" "${CONFIG_FILE}.bak" | grep -q "$1" then return 0 else return 1 fi @@ -3000,9 +3000,9 @@ _GetLatestFWUpdateVersionFromRouter_() echo "$newVersionStr" ; return "$retCode" } -##------------------------------------------## -## Modified by ExtremeFiretop [2025-Jun-17] ## -##------------------------------------------## +##----------------------------------------## +## Modified by Martinski W. [2025-Nov-10] ## +##----------------------------------------## _CreateEMailContent_() { if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi @@ -3080,6 +3080,13 @@ _CreateEMailContent_() printf "\nThe F/W version that is currently installed:\n${fwInstalledVersion}\n" } > "$tempEMailBodyMsg" ;; + FAILED_USB_DRIVE_UNMOUNT) + emailBodyTitle="USB Drive Unmount Failed" + { + echo "Unable to unmount the USB-attached drive before the F/W Update flash was started on the ${MODEL_ID} router." + printf "\nThe USB drive was likely in a busy state.\n" + } > "$tempEMailBodyMsg" + ;; SUCCESS_SCRIPT_UPDATE_STATUS) if [ -s "$SCRIPT_VERPATH" ] then @@ -8772,8 +8779,85 @@ _RunOfflineUpdateNow_() fi } +##-------------------------------------## +## Added by Martinski W. [2025-Nov-09] ## +##-------------------------------------## +_Unmount_Eject_USB_Drives_() +{ + local maxWaitDelaySecs=240 #4 mins# + local theWaitDelaySecs=5 curWaitDelaySecs=0 + local ejectUSB_OK=false ejectUSB_PID="" usbMountPoint="" + local logMsg="Unmount/Eject USB Drive" + + _MsgToSysLog_() { logger -st "${SCRIPT_NAME}_[$$]" -p 4 "$1" ; } + + _MsgToSysLog_ "START of ${logMsg}..." + + /sbin/ejusb -1 0 -u 1 2>/dev/null & ejectUSB_PID=$! + + while [ "$curWaitDelaySecs" -lt "$maxWaitDelaySecs" ] + do + ## If unmount succeeded, then exit loop ## + if [ -n "$ejectUSB_PID" ] && \ + ! kill -EXIT "$ejectUSB_PID" 2>/dev/null && \ + ! usbMountPoint="$(_GetDefaultUSBMountPoint_)" + then + ejectUSB_OK=true ; break + fi + + ## If USB drive is no longer mounted, exit loop ## + if ! usbMountPoint="$(_GetDefaultUSBMountPoint_)" + then + _MsgToSysLog_ "${logMsg}: No USB drives are mounted." + ejectUSB_OK=true ; break + fi + + ## If timeout was reached, check again and exit loop ## + if [ -n "$ejectUSB_PID" ] && \ + [ "$curWaitDelaySecs" -ge "$maxWaitDelaySecs" ] + then + if ! kill -EXIT "$ejectUSB_PID" 2>/dev/null && \ + ! usbMountPoint="$(_GetDefaultUSBMountPoint_)" + then + ejectUSB_OK=true ; break + fi + kill -KILL "$ejectUSB_PID" 2>/dev/null + wait $ejectUSB_PID ; break + fi + + ## If USB drive is still mounted, try again ## + if [ -n "$ejectUSB_PID" ] && \ + ! kill -EXIT "$ejectUSB_PID" 2>/dev/null && \ + usbMountPoint="$(_GetDefaultUSBMountPoint_)" + then + /sbin/ejusb -1 0 -u 1 2>/dev/null & ejectUSB_PID=$! + fi + + if [ "$curWaitDelaySecs" -gt 0 ] && \ + [ "$((curWaitDelaySecs % 10))" -eq 0 ] + then _MsgToSysLog_ "$logMsg Wait Timeout [$curWaitDelaySecs secs]..." + fi + + sleep "$theWaitDelaySecs" + curWaitDelaySecs="$((curWaitDelaySecs + theWaitDelaySecs))" + done + + if "$ejectUSB_OK" || \ + [ "$curWaitDelaySecs" -lt "$maxWaitDelaySecs" ] + then + _MsgToSysLog_ "$logMsg succeeded [$curWaitDelaySecs secs]" + else + _MsgToSysLog_ "$logMsg Wait Timeout [$maxWaitDelaySecs secs] expired." + _MsgToSysLog_ "Unable to unmount USB drive. Device is likely busy." + _SendEMailNotification_ FAILED_USB_DRIVE_UNMOUNT + fi + _MsgToSysLog_ "END of ${logMsg}." + + "$ejectUSB_OK" && return 0 || return 1 +} + ##----------------------------------------## -## Modified by Martinski W. [2025-Nov-05] ## +## Modified by Martinski W. [2025-Nov-09] ## ##----------------------------------------## _RunFirmwareUpdateNow_() { @@ -9339,7 +9423,13 @@ Please manually update to version ${GRNct}${MinSupportedFirmwareVers}${NOct} or # *WARNING*: NO MORE logging at this point & beyond # sync ; sleep 2 ; echo 3 > /proc/sys/vm/drop_caches ; sleep 3 - /sbin/ejusb -1 0 -u 1 2>/dev/null + + ##-------------------------------------## + ## Added by Martinski W. [2025-Nov-09] ## + ##-------------------------------------## + # Unmount the USB drives. If "busy" let's wait until "idle" state. # + #------------------------------------------------------------------# + _Unmount_Eject_USB_Drives_ #----------------------------------------------------------------------------------# # **IMPORTANT NOTE**: @@ -9450,7 +9540,7 @@ _PostUpdateEmailNotification_() then break ; fi if [ "$curWaitDelaySecs" -gt 0 ] && \ - [ "$((curWaitDelaySecs % 60))" -eq 0 ] + [ "$((curWaitDelaySecs % 30))" -eq 0 ] then Say "$logMsg [$curWaitDelaySecs secs.]..." ; fi sleep $theWaitDelaySecs @@ -9462,7 +9552,7 @@ _PostUpdateEmailNotification_() else Say "$logMsg [$maxWaitDelaySecs sec.] expired." fi - Say "END of $logMsg [$$curWaitDelaySecs sec.]" + Say "END of $logMsg [$curWaitDelaySecs sec.]" sleep 20 ## Let's wait a bit & proceed ## _SendEMailNotification_ POST_REBOOT_FW_UPDATE_STATUS } @@ -9494,7 +9584,7 @@ _PostRebootRunNow_() then break ; fi if [ "$curWaitDelaySecs" -gt 0 ] && \ - [ "$((curWaitDelaySecs % 60))" -eq 0 ] + [ "$((curWaitDelaySecs % 30))" -eq 0 ] then Say "$logMsg [$curWaitDelaySecs secs.]..." ; fi sleep $theWaitDelaySecs @@ -9506,7 +9596,7 @@ _PostRebootRunNow_() else Say "$logMsg [$maxWaitDelaySecs sec.] expired." fi - Say "END of $logMsg [$$curWaitDelaySecs sec.]" + Say "END of $logMsg [$curWaitDelaySecs sec.]" sleep 30 ## Let's wait a bit & proceed ## if _AcquireLock_ cliFileLock then @@ -11243,7 +11333,7 @@ _Gnuton_Check_Webs_Update_Script_() # (Re)bind/mount only if remote is newer version OR files differ # if [ "$remoteVersTag" -gt "$localVersTag" ] || \ - ! diff "$FW_UpdateCheckScript" "$dwnldGnutonWebsUpdateFilePath" >/dev/null 2>&1 + ! diff -q "$FW_UpdateCheckScript" "$dwnldGnutonWebsUpdateFilePath" >/dev/null 2>&1 then umount "$FW_UpdateCheckScript" 2>/dev/null mv -f "$dwnldGnutonWebsUpdateFilePath" "$fixedGnutonWebsUpdateFilePath" diff --git a/README.md b/README.md index c1e3ab26..5236d0e9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # MerlinAU - AsusWRT-Merlin Firmware Auto Updater -## v1.5.6 -## 2025-Nov-08 +## v1.5.7 +## 2025-Nov-25 ## WebUI: ![image](https://github.com/user-attachments/assets/9c1dff99-9c13-491b-a7fa-aff924d5f02e) @@ -18,6 +18,7 @@ ## SUPPORTED MERLIN MODELS (Multi-image models) - i.e. Any model that uses a .w or a .pkgtb file + - GT-BE19000AI - GT-BE98_PRO - GT-AX6000 - GT-AXE16000 @@ -29,7 +30,7 @@ - RT-BE96U - RT-BE88U - RT-BE86U - - RT-BE58 Go​ + - RT-BE58_GO​ - RT-AX88U_PRO - RT-AX88U - RT-AC86U diff --git a/version.txt b/version.txt index eac1e0ad..f01291b8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.5.6 +1.5.7