Skip to content

Commit c2fd330

Browse files
Merge pull request #264 from ExtremeFiretop/dev
Dev 1.2.6 as Next Stable Release
2 parents 400cdc6 + f53e87f commit c2fd330

File tree

3 files changed

+174
-73
lines changed

3 files changed

+174
-73
lines changed

MerlinAU.sh

Lines changed: 167 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
#
55
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7-
# Last Modified: 2024-Jun-30
7+
# Last Modified: 2024-Jul-03
88
###################################################################
99
set -u
1010

11-
readonly SCRIPT_VERSION=1.2.5
11+
readonly SCRIPT_VERSION=1.2.6
1212
readonly SCRIPT_NAME="MerlinAU"
1313

14-
##-------------------------------------##
15-
## Added by Martinski W. [2023-Dec-01] ##
16-
##-------------------------------------##
14+
##----------------------------------------##
15+
## Modified by Martinski W. [2024-Jul-03] ##
16+
##----------------------------------------##
1717
# Script URL Info #
18-
readonly SCRIPT_BRANCH="master"
19-
readonly SCRIPT_URL_BASE="https://raw.githubusercontent.com/ExtremeFiretop/MerlinAutoUpdate-Router/$SCRIPT_BRANCH"
18+
19+
## Set to "master" for Production Releases ##
20+
SCRIPT_BRANCH="dev"
21+
readonly SCRIPT_URL_BASE="https://raw.githubusercontent.com/ExtremeFiretop/MerlinAutoUpdate-Router"
22+
SCRIPT_URL_REPO="${SCRIPT_URL_BASE}/$SCRIPT_BRANCH"
2023

2124
# Firmware URL Info #
2225
readonly FW_URL_BASE="https://sourceforge.net/projects/asuswrt-merlin/files"
@@ -233,6 +236,66 @@ _DoExit_()
233236
_ReleaseLock_ ; exit "$exitCode"
234237
}
235238

239+
##------------------------------------------##
240+
## Modified by ExtremeFiretop [2024-May-21] ##
241+
##------------------------------------------##
242+
logo() {
243+
echo -e "${YLWct}"
244+
echo -e " __ __ _ _ _ _ "
245+
echo -e " | \/ | | (_) /\ | | | |"
246+
echo -e " | \ / | ___ _ __| |_ _ __ / \ | | | |"
247+
echo -e " | |\/| |/ _ | '__| | | '_ \ / /\ \| | | |"
248+
echo -e " | | | | __| | | | | | | |/ ____ | |__| |"
249+
echo -e " |_| |_|\___|_| |_|_|_| |_/_/ \_\____/ ${GRNct}v${SCRIPT_VERSION}"
250+
echo -e "${NOct}"
251+
}
252+
253+
##---------------------------------------##
254+
## Added by ExtremeFiretop [2024-Jul-03] ##
255+
##---------------------------------------##
256+
_ShowAbout_()
257+
{
258+
logo
259+
cat <<EOF
260+
About
261+
$SCRIPT_NAME is a tool for automating firmware updates on AsusWRT Merlin,
262+
ensuring your router stays up-to-date with the latest features and security
263+
patches. It simplifies the update process by automatically checking for,
264+
downloading, and applying new firmware versions.
265+
Developed by ExtremeFiretop and Martinski W.
266+
License
267+
$SCRIPT_NAME is free to use under the GNU General Public License
268+
version 3 (GPL-3.0) https://opensource.org/licenses/GPL-3.0
269+
Help & Support
270+
https://www.snbforums.com/threads/merlinau-the-ultimate-firmware-auto-updater-addon.88577/
271+
Source code
272+
https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router
273+
EOF
274+
printf "\n"
275+
_DoExit_ 0
276+
}
277+
278+
##---------------------------------------##
279+
## Added by ExtremeFiretop [2024-Jul-03] ##
280+
##---------------------------------------##
281+
_ShowHelp_()
282+
{
283+
logo
284+
cat <<EOF
285+
Available commands:
286+
$SCRIPT_NAME about explains functionality
287+
$SCRIPT_NAME help display available commands
288+
$SCRIPT_NAME forceupdate updates to latest version (force update)
289+
$SCRIPT_NAME run_now run update process on router
290+
$SCRIPT_NAME processNodes run update check on nodes
291+
$SCRIPT_NAME develop switch to development branch
292+
$SCRIPT_NAME stable switch to stable branch
293+
$SCRIPT_NAME uninstall uninstalls script
294+
EOF
295+
printf "\n"
296+
_DoExit_ 0
297+
}
298+
236299
##----------------------------------------##
237300
## Modified by Martinski W. [2024-May-31] ##
238301
##----------------------------------------##
@@ -509,20 +572,6 @@ readonly PRODUCT_ID="$(_GetRouterProductID_)"
509572
readonly FW_FileName="${PRODUCT_ID}_firmware"
510573
readonly FW_URL_RELEASE="${FW_URL_BASE}/${PRODUCT_ID}/${FW_URL_RELEASE_SUFFIX}/"
511574

512-
##------------------------------------------##
513-
## Modified by ExtremeFiretop [2024-May-21] ##
514-
##------------------------------------------##
515-
logo() {
516-
echo -e "${YLWct}"
517-
echo -e " __ __ _ _ _ _ "
518-
echo -e " | \/ | | (_) /\ | | | |"
519-
echo -e " | \ / | ___ _ __| |_ _ __ / \ | | | |"
520-
echo -e " | |\/| |/ _ | '__| | | '_ \ / /\ \| | | |"
521-
echo -e " | | | | __| | | | | | | |/ ____ | |__| |"
522-
echo -e " |_| |_|\___|_| |_|_|_| |_/_/ \_\____/ ${GRNct}v${SCRIPT_VERSION}"
523-
echo -e "${NOct}"
524-
}
525-
526575
##----------------------------------------##
527576
## Modified by Martinski W. [2024-Jun-05] ##
528577
##----------------------------------------##
@@ -535,7 +584,7 @@ _CheckForNewScriptUpdates_()
535584
rm -f "$SCRIPTVERPATH"
536585

537586
# Download the latest version file from the source repository
538-
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_BASE}/version.txt" -o "$SCRIPTVERPATH"
587+
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt" -o "$SCRIPTVERPATH"
539588

540589
if [ $? -ne 0 ] || [ ! -s "$SCRIPTVERPATH" ]
541590
then scriptUpdateNotify=0 ; return 1 ; fi
@@ -555,60 +604,84 @@ _CheckForNewScriptUpdates_()
555604
if [ "$DLRepoVersionNum" -gt "$ScriptVersionNum" ]
556605
then
557606
scriptUpdateNotify="New script update available.
558-
${REDct}v$SCRIPT_VERSION${NOct} --> ${GRNct}v$DLRepoVersion${NOct}"
607+
${REDct}v${SCRIPT_VERSION}${NOct} --> ${GRNct}v${DLRepoVersion}${NOct}"
559608
Say "$(date +'%b %d %Y %X') $(nvram get lan_hostname) ${ScriptFNameTag}_[$$] - INFO: A new script update (v$DLRepoVersion) is available to download."
560609
else
561610
scriptUpdateNotify=0
562611
fi
563612
}
564613

565614
##----------------------------------------##
566-
## Modified by Martinski W. [2024-Jun-05] ##
615+
## Modified by Martinski W. [2024-Jul-03] ##
567616
##----------------------------------------##
568-
#a function that provides a UI to check for script updates and allows you to install the latest version...
569617
_SCRIPTUPDATE_()
570618
{
571-
local ScriptFileDL="${ScriptFilePath}.DL"
619+
local scriptVers ScriptFileDL="${ScriptFilePath}.DL"
572620

573621
_CheckForNewScriptUpdates_
622+
623+
_DownloadScriptFiles_()
624+
{
625+
local retCode
626+
627+
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt" -o "$SCRIPTVERPATH"
628+
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/${SCRIPT_NAME}.sh" -o "$ScriptFileDL"
629+
630+
if [ $? -eq 0 ] && [ -s "$ScriptFileDL" ]
631+
then
632+
mv -f "$ScriptFileDL" "$ScriptFilePath"
633+
chmod 755 "$ScriptFilePath"
634+
retCode=0
635+
else
636+
rm -f "$ScriptFileDL"
637+
printf "\n${REDct}Download failed.${NOct}\n"
638+
retCode=1
639+
fi
640+
return "$retCode"
641+
}
642+
643+
if [ $# -gt 0 ] && [ "$1" = "force" ]
644+
then
645+
echo -e "${CYANct}Force downloading latest version...${NOct}"
646+
scriptVers="$(/usr/sbin/curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_REPO}/version.txt")"
647+
echo -e "${CYANct}Downloading latest version ($scriptVers) of ${SCRIPT_NAME}${NOct}"
648+
649+
if _DownloadScriptFiles_
650+
then
651+
echo -e "${CYANct}$SCRIPT_NAME successfully updated.${NOct}"
652+
_ReleaseLock_
653+
exec "$ScriptFilePath"
654+
fi
655+
return
656+
fi
657+
574658
clear
575659
logo
576-
echo
577-
echo -e "${YLWct}Update Utility${NOct}"
578-
echo
579-
echo -e "${CYANct}Current Version: ${YLWct}${SCRIPT_VERSION}${NOct}"
580-
echo -e "${CYANct}Updated Version: ${YLWct}${DLRepoVersion}${NOct}"
581-
echo
660+
printf "\n${YLWct}Script Update Utility${NOct}\n\n"
661+
printf "${CYANct}Version Currently Installed: ${YLWct}${SCRIPT_VERSION}${NOct}\n"
662+
printf "${CYANct}Update Version Available Now: ${YLWct}${DLRepoVersion}${NOct}\n\n"
582663

583664
if [ "$SCRIPT_VERSION" = "$DLRepoVersion" ]
584665
then
585666
echo -e "${CYANct}You are on the latest version! Would you like to download anyways?${NOct}"
586667
echo -e "${CYANct}This will overwrite your currently installed version.${NOct}"
587668
if _WaitForYESorNO_
588669
then
589-
echo ; echo
590-
echo -e "${CYANct}Downloading $SCRIPT_NAME ${CYANct}v$DLRepoVersion${NOct}"
591-
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_BASE}/version.txt" -o "$SCRIPTVERPATH"
592-
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_BASE}/${SCRIPT_NAME}.sh" -o "$ScriptFileDL"
670+
printf "\n\n"
671+
echo -e "${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}"
593672

594-
if [ $? -eq 0 ] && [ -s "$ScriptFileDL" ]
673+
if _DownloadScriptFiles_
595674
then
596-
mv -f "$ScriptFileDL" "$ScriptFilePath"
597-
chmod 755 "$ScriptFilePath"
598675
echo
599676
echo -e "${CYANct}Download successful!${NOct}"
600677
echo -e "$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v$DLRepoVersion"
601678
echo
602-
else
603-
rm -f "$ScriptFileDL"
604-
echo
605-
echo -e "${REDct}Download failed.${NOct}"
606679
fi
607680
_WaitForEnterKey_
608681
return
609682
else
610-
echo ; echo
611-
echo -e "${GRNct}Exiting Update Utility...${NOct}"
683+
printf "\n\n"
684+
echo -e "${GRNct}Exiting Script Update Utility...${NOct}"
612685
sleep 1
613686
return
614687
fi
@@ -617,37 +690,52 @@ _SCRIPTUPDATE_()
617690
echo -e "${CYANct}Bingo! New version available! Would you like to update now?${NOct}"
618691
if _WaitForYESorNO_
619692
then
620-
echo ; echo
621-
echo -e "${CYANct}Downloading $SCRIPT_NAME ${CYANct}v$DLRepoVersion${NOct}"
622-
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_BASE}/version.txt" -o "$SCRIPTVERPATH"
623-
curl -LSs --retry 4 --retry-delay 5 "${SCRIPT_URL_BASE}/${SCRIPT_NAME}.sh" -o "$ScriptFileDL"
693+
printf "\n\n"
694+
echo -e "${CYANct}Downloading $SCRIPT_NAME ${CYANct}v${DLRepoVersion}${NOct}"
624695

625-
if [ $? -eq 0 ] && [ -s "$ScriptFileDL" ]
696+
if _DownloadScriptFiles_
626697
then
627-
mv -f "$ScriptFileDL" "$ScriptFilePath"
628-
chmod 755 "$ScriptFilePath"
629698
echo
630699
echo -e "$(date) - $SCRIPT_NAME - Successfully downloaded $SCRIPT_NAME v$DLRepoVersion"
631700
echo -e "${CYANct}Update successful! Restarting script...${NOct}"
632701
_ReleaseLock_
633702
exec "$ScriptFilePath" # Re-execute the updated script #
634703
exit 0 # This line will not be executed due to above exec #
635704
else
636-
rm -f "$ScriptFileDL"
637-
echo
638-
echo -e "${REDct}Download failed.${NOct}"
639705
_WaitForEnterKey_
640706
return
641707
fi
642708
else
643-
echo ; echo
644-
echo -e "${GRNct}Exiting Update Utility...${NOct}"
709+
printf "\n\n"
710+
echo -e "${GRNct}Exiting Script Update Utility...${NOct}"
645711
sleep 1
646712
return
647713
fi
648714
fi
649715
}
650716

717+
##----------------------------------------##
718+
## Modified by Martinski W. [2024-Jul-03] ##
719+
##----------------------------------------##
720+
_ChangeToDev_()
721+
{
722+
SCRIPT_BRANCH="dev"
723+
SCRIPT_URL_REPO="${SCRIPT_URL_BASE}/$SCRIPT_BRANCH"
724+
_SCRIPTUPDATE_ force
725+
_DoExit_ 0
726+
}
727+
728+
##----------------------------------------##
729+
## Modified by Martinski W. [2024-Jul-03] ##
730+
##----------------------------------------##
731+
_ChangeToStable_()
732+
{
733+
SCRIPT_BRANCH="master"
734+
SCRIPT_URL_REPO="${SCRIPT_URL_BASE}/$SCRIPT_BRANCH"
735+
_SCRIPTUPDATE_ force
736+
_DoExit_ 0
737+
}
738+
651739
##----------------------------------------##
652740
## Modified by Martinski W. [2024-Mar-14] ##
653741
##----------------------------------------##
@@ -5189,9 +5277,9 @@ _SetSecondaryEMailAddress_()
51895277
}
51905278

51915279
# RegExp for IPv4 address #
5192-
readonly IPv4octet_RegEx="([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5])"
5193-
readonly IPv4addrs_RegEx="((${IPv4octet_RegEx}\.){3}${IPv4octet_RegEx})"
5194-
readonly IPv4privt_RegEx="((^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.))"
5280+
readonly IPv4octet_RegEx="([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
5281+
readonly IPv4addrs_RegEx="(${IPv4octet_RegEx}\.){3}${IPv4octet_RegEx}"
5282+
readonly IPv4privt_RegEx="(^10\.|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168\.)"
51955283

51965284
##----------------------------------------##
51975285
## Modified by Martinski W. [2024-Apr-06] ##
@@ -5280,9 +5368,9 @@ check_version_support
52805368
##-------------------------------------##
52815369
_CheckEMailConfigFileFromAMTM_ 0
52825370

5283-
##----------------------------------------##
5284-
## Modified by Martinski W. [2024-Jan-24] ##
5285-
##----------------------------------------##
5371+
##------------------------------------------##
5372+
## Modified by ExtremeFiretop [2024-Jul-03] ##
5373+
##------------------------------------------##
52865374
if [ $# -gt 0 ]
52875375
then
52885376
inMenuMode=false
@@ -5297,6 +5385,16 @@ then
52975385
;;
52985386
postUpdateEmail) _PostUpdateEmailNotification_
52995387
;;
5388+
about) _ShowAbout_
5389+
;;
5390+
help) _ShowHelp_
5391+
;;
5392+
forceupdate) _SCRIPTUPDATE_ force
5393+
;;
5394+
develop) _ChangeToDev_
5395+
;;
5396+
stable) _ChangeToStable_
5397+
;;
53005398
uninstall) _DoUninstall_
53015399
;;
53025400
*) printf "${REDct}INVALID Parameter.${NOct}\n"
@@ -5666,7 +5764,7 @@ _InvalidMenuSelection_()
56665764
}
56675765

56685766
##----------------------------------------##
5669-
## Modified by Martinski W. [2024-May-31] ##
5767+
## Modified by Martinski W. [2024-Jul-03] ##
56705768
##----------------------------------------##
56715769
_ShowMainMenu_()
56725770
{
@@ -5774,8 +5872,11 @@ _ShowMainMenu_()
57745872
# Check for new script updates #
57755873
if [ "$scriptUpdateNotify" != "0" ]
57765874
then
5777-
printf "\n ${GRNct}up${NOct}. Update $SCRIPT_NAME Script Now"
5778-
printf "\n${padStr}[Version: ${GRNct}${DLRepoVersion}${NOct} Available for Download]\n"
5875+
printf "\n ${GRNct}up${NOct}. Update $SCRIPT_NAME Script"
5876+
printf "\n${padStr}[Version ${GRNct}${DLRepoVersion}${NOct} Available for Download]\n"
5877+
else
5878+
printf "\n ${GRNct}up${NOct}. Force Update $SCRIPT_NAME Script"
5879+
printf "\n${padStr}[No Update Available]\n"
57795880
fi
57805881

57815882
# Add selection for "Advanced Options" sub-menu #

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater
2-
## v1.2.5
3-
## 2024-06-30
2+
## v1.2.6
3+
## 2024-07-06
44

5-
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/08801e45-8d18-499b-add7-2f6295ca5f8b)
6-
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/58de944f-669c-4109-991d-611e69f50f16)
7-
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/99b11bf5-20bb-43b3-adae-061a6181f329)
8-
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/060a707f-5820-4ee4-b93d-c68199fee8e4)
5+
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/a5b443a5-914d-496a-8b0e-7fd22c3ed87d)
6+
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/8a516fd9-444b-4c6b-9bc3-c2989e8e78a7)
7+
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/722a7b0c-96a9-48ee-ac66-9e0a5702f3d2)
8+
![image](https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router/assets/1971404/23ce21d9-fcdc-46e8-9365-1262271471ec)
99

1010
## SUPPORTED MERLIN MODELS (Multi-image models) - i.e. Any model that uses a .w or a .pkgtb file
1111

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.5
1+
1.2.6

0 commit comments

Comments
 (0)