Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8ecda77
Improved Code to Unmount USB Drives
Martinski4GitHub Nov 10, 2025
39a81d7
Code Improvement.
Martinski4GitHub Nov 10, 2025
2c238ea
Merge branch 'dev' into dev
Martinski4GitHub Nov 10, 2025
f0fcc2c
Improved Code to Unmount USB Drive
Martinski4GitHub Nov 10, 2025
05aeaa4
Bump softprops/action-gh-release in the all-actions group
dependabot[bot] Nov 10, 2025
b76cfa9
Merge pull request #530 from ExtremeFiretop/dependabot/github_actions…
ExtremeFiretop Nov 11, 2025
0ba5af2
Merge pull request #529 from Martinski4GitHub/dev
ExtremeFiretop Nov 11, 2025
76a1152
Email Notification when USB Drive Unmount Fails
Martinski4GitHub Nov 11, 2025
3083c53
Merge pull request #531 from Martinski4GitHub/dev
ExtremeFiretop Nov 11, 2025
4154fee
Add GT-BE19000AI to supported models list
ExtremeFiretop Nov 12, 2025
6e4df38
Fix formatting of RT-BE58 model in README
ExtremeFiretop Nov 12, 2025
a11bfa2
Code Improvements
Martinski4GitHub Nov 17, 2025
3f8aa29
Merge pull request #532 from Martinski4GitHub/dev
ExtremeFiretop Nov 17, 2025
dd1c3c9
Bump actions/checkout from 5.0.0 to 5.0.1 in the all-actions group
dependabot[bot] Nov 17, 2025
183e440
Merge pull request #533 from ExtremeFiretop/dependabot/github_actions…
ExtremeFiretop Nov 18, 2025
a111d0a
Bump actions/checkout from 5.0.1 to 6.0.0 in the all-actions group
dependabot[bot] Nov 24, 2025
0beb44e
Merge pull request #534 from ExtremeFiretop/dependabot/github_actions…
ExtremeFiretop Nov 25, 2025
05887b6
Update release date in README.md
ExtremeFiretop Nov 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/Create-NewReleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
126 changes: 108 additions & 18 deletions MerlinAU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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] ##
Expand Down Expand Up @@ -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" ] || \
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -3080,6 +3080,13 @@ _CreateEMailContent_()
printf "\nThe F/W version that is currently installed:\n<b>${fwInstalledVersion}</b>\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 <b>${MODEL_ID}</b> router."
printf "\nThe USB drive was likely in a busy state.\n"
} > "$tempEMailBodyMsg"
;;
SUCCESS_SCRIPT_UPDATE_STATUS)
if [ -s "$SCRIPT_VERPATH" ]
then
Expand Down Expand Up @@ -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_()
{
Expand Down Expand Up @@ -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**:
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -29,7 +30,7 @@
- RT-BE96U
- RT-BE88U
- RT-BE86U
- RT-BE58 Go
- RT-BE58_GO
- RT-AX88U_PRO
- RT-AX88U
- RT-AC86U
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.6
1.5.7