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] 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"