Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow script to continue flashing F/W if connection is terminated. #273

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
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
32 changes: 21 additions & 11 deletions MerlinAU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
# Last Modified: 2024-Jul-23
# Last Modified: 2024-Jul-24
###################################################################
set -u

Expand Down Expand Up @@ -2080,7 +2080,7 @@ check_memory_and_prompt_reboot()
# Attempt to clear clears pagecache, dentries, and inodes after shutting down services
Say "Attempting to free up memory once more even more aggressively..."

# Stop Entware services before F/W flash #
# Stop Entware services to free some memory #
_EntwareServicesHandler_ stop

_ShutDownNonCriticalServices_
Expand Down Expand Up @@ -4198,7 +4198,7 @@ _Toggle_FW_UpdateCheckSetting_()
}

##----------------------------------------##
## Modified by Martinski W. [2024-Jun-28] ##
## Modified by Martinski W. [2024-Jul-24] ##
##----------------------------------------##
_EntwareServicesHandler_()
{
Expand All @@ -4221,6 +4221,9 @@ _EntwareServicesHandler_()
*) return 1 ;;
esac

# Check if *NOT* skipping any services #
[ $# -gt 1 ] && [ "$2" = "-noskip" ] && skipServiceList=""

_RenameSkippedService_()
{
[ -z "$skippedServiceList" ] && return 1
Expand All @@ -4239,8 +4242,8 @@ _EntwareServicesHandler_()

[ -n "$serviceStr" ] && Say "Looking for Entware services..."

# Filter out services to skip and add a skip message #
if [ "$AllowVPN" = "ENABLED" ]
# Filter out services to skip and add a "skip message" #
if [ "$AllowVPN" = "ENABLED" ] && [ -n "$skipServiceList" ]
then
for skipService in $skipServiceList
do
Expand Down Expand Up @@ -4801,9 +4804,6 @@ Please manually update to version $minimum_supported_version or higher to use th
# Send last email notification before F/W flash #
_SendEMailNotification_ START_FW_UPDATE_STATUS

# Stop Entware services before F/W flash #
_EntwareServicesHandler_ stop

##------------------------------------------##
## Modified by ExtremeFiretop [2024-Jun-30] ##
##------------------------------------------##
Expand Down Expand Up @@ -4869,15 +4869,24 @@ 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 #
/sbin/ejusb -1 0 -u 1

#-------------------------------------------------------
# Stop toggling LEDs during the F/W flash to avoid
# modifying NVRAM during the actual flash process.
#-------------------------------------------------------
_Reset_LEDs_

##----------------------------------------##
## Modified by Martinski W. [2024-Jul-24] ##
##----------------------------------------##
# Remove SIGHUP to allow script to continue #
trap '' HUP

# Stop Entware services WITHOUT exceptions BEFORE the F/W flash #
_EntwareServicesHandler_ stop -noskip

# *WARNING*: NO MORE logging at this point & beyond #
/sbin/ejusb -1 0 -u 1

nohup curl -k "${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' \
Expand Down Expand Up @@ -4917,6 +4926,7 @@ Please manually update to version $minimum_supported_version or higher to use th
# reboot by itself after the process returns, do it now.
#----------------------------------------------------------#
sleep 180
_ReleaseLock_
/sbin/service reboot
else
Say "${REDct}**ERROR**${NOct}: Login failed. Please try the following:
Expand Down