Skip to content

Commit 0f4444e

Browse files
Merge pull request #342 from ExtremeFiretop/ExtremeFiretop-OfflineTweak
Offline Version Regex
2 parents 2d9d21e + b27afd0 commit 0f4444e

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

MerlinAU.sh

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

@@ -5268,23 +5268,23 @@ _EntwareServicesHandler_()
52685268
"$isInteractive" && printf "\nDone.\n"
52695269
}
52705270

5271-
##----------------------------------------##
5272-
## Modified by Martinski W. [2024-Jul-29] ##
5273-
##----------------------------------------##
5271+
##------------------------------------------##
5272+
## Modified by ExtremeFiretop [2024-Oct-13] ##
5273+
##------------------------------------------##
52745274
_GetOfflineFirmwareVersion_()
52755275
{
52765276
local zip_file="$1"
52775277
local extract_version_regex='[0-9]+_[0-9]+\.[0-9]+_[0-9a-zA-Z]+'
5278-
local validate_version_regex='[0-9]+\.[0-9]+\.[0-9]+\.[0-9a-zA-Z]+'
5278+
local validate_version_regex='[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(_[0-9a-zA-Z]+)?'
52795279
local fwVersionFormat
52805280

52815281
# Extract the version number using regex #
52825282
firmware_version="$(echo "$zip_file" | grep -oE "$extract_version_regex")"
52835283

52845284
if [ -n "$firmware_version" ]
52855285
then
5286-
# Replace underscores with dots #
5287-
formatted_version="$(echo "$firmware_version" | sed 's/_/./g')"
5286+
# Replace underscores with dots and insert .0 before the suffix #
5287+
formatted_version="$(echo "$firmware_version" | sed -E 's/^([0-9]+)_([0-9]+\.[0-9]+)_([0-9a-zA-Z]+)/\1.\2.0_\3/')"
52885288
printf "\nIdentified firmware version: ${GRNct}$formatted_version${NOct}\n"
52895289
printf "\n---------------------------------------------------\n"
52905290
else
@@ -5298,15 +5298,15 @@ _GetOfflineFirmwareVersion_()
52985298
printf "\nFailed to identify firmware version from the ZIP file name."
52995299
fi
53005300
printf "\nPlease enter the firmware version number in the format ${fwVersionFormat}\n"
5301-
printf "\n(Examples: 3004.388.8.0 or 3004.388.8.beta1): "
5301+
printf "\n(Examples: 3004.388.8.0 or 3004.388.8.0_beta1): "
53025302
read -r formatted_version
53035303

53045304
# Validate user input #
53055305
while ! echo "$formatted_version" | grep -qE "^${validate_version_regex}$"
53065306
do
53075307
printf "\n${REDct}**WARNING**${NOct} Invalid format detected!\n"
53085308
printf "\nPlease enter the firmware version number in the format ${fwVersionFormat}\n"
5309-
printf "\n(i.e 3004.388.8.0 or 3004.388.8.beta1): "
5309+
printf "\n(i.e 3004.388.8.0 or 3004.388.8.0_beta1): "
53105310
read -r formatted_version
53115311
done
53125312
printf "\nThe user-provided firmware version: ${GRNct}$formatted_version${NOct}\n"
@@ -5590,9 +5590,9 @@ _RunBackupmon_()
55905590
return 0
55915591
}
55925592

5593-
##----------------------------------------##
5594-
## Modified by Martinski W. [2024-Jul-31] ##
5595-
##----------------------------------------##
5593+
##------------------------------------------##
5594+
## Modified by ExtremeFiretop [2024-Oct-13] ##
5595+
##------------------------------------------##
55965596
_RunOfflineUpdateNow_()
55975597
{
55985598
local retCode
@@ -5631,7 +5631,8 @@ _RunOfflineUpdateNow_()
56315631
printf "\n2. No support will be offered when flashing firmware offline."
56325632
printf "\n3. This offline feature is excluded from documentation on purpose.\n"
56335633
printf "\nDo you acknowledge the risk and wish to proceed?"
5634-
printf "\nYou must type '${REDct}YES${NOct}' to continue.\n"
5634+
printf "\nYou must type '${REDct}YES${NOct}' to continue."
5635+
printf "\n---------------------------------------------------\n"
56355636

56365637
read -r response
56375638
if [ "$response" = "YES" ]

0 commit comments

Comments
 (0)