Skip to content

Commit 03d61e7

Browse files
Merge pull request #108 from ExtremeFiretop/ExtremeFiretop-Changelog-Fix
Update MerlinAU.sh Changelog Fix to the Regex
2 parents cfc32d4 + ebfc1aa commit 03d61e7

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

MerlinAU.sh

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -815,9 +815,9 @@ Update_Custom_Settings()
815815
}
816816

817817
##------------------------------------------##
818-
## Modified by ExtremeFiretop [2024-Jan-26] ##
818+
## Modified by ExtremeFiretop [2024-Jan-30] ##
819819
##------------------------------------------##
820-
_migrate_settings_() {
820+
_migrate_settings_move() {
821821
local USBMountPoint="$(Get_Custom_Setting FW_New_Update_LOG_Directory_Path)"
822822
local old_settings_dir="${ADDONS_PATH}/$ScriptFNameTag"
823823
local new_settings_dir="${ADDONS_PATH}/$ScriptDirNameD"
@@ -830,7 +830,13 @@ _migrate_settings_() {
830830
if [ -d "$old_settings_dir" ]; then
831831
# Check if the new SETTINGS directory already exists
832832
if [ -d "$new_settings_dir" ]; then
833-
echo "The new SETTINGS directory already exists. Migration is not required."
833+
# Remove the old SETTINGS directory since the new one exists
834+
rm -rf "$old_settings_dir"
835+
if [ $? -eq 0 ]; then
836+
echo "The new SETTINGS directory already exists. Removed the old SETTINGS directory."
837+
else
838+
echo "Error occurred while removing the old SETTINGS directory."
839+
fi
834840
else
835841
# Move the old SETTINGS directory to the new location
836842
mv "$old_settings_dir" "$new_settings_dir"
@@ -846,7 +852,13 @@ _migrate_settings_() {
846852
if [ -d "$old_bin_dir" ]; then
847853
# Check if the new BIN directory already exists
848854
if [ -d "$new_bin_dir" ]; then
849-
echo "The new BIN directory already exists. Migration is not required."
855+
# Remove the old BIN directory since the new one exists
856+
rm -rf "$old_bin_dir"
857+
if [ $? -eq 0 ]; then
858+
echo "The new BIN directory already exists. Removed the old BIN directory."
859+
else
860+
echo "Error occurred while removing the old BIN directory."
861+
fi
850862
else
851863
# Move the old BIN directory to the new location
852864
mv "$old_bin_dir" "$new_bin_dir"
@@ -862,7 +874,13 @@ _migrate_settings_() {
862874
if [ -d "$old_log_dir" ]; then
863875
# Check if the new LOG directory already exists
864876
if [ -d "$new_log_dir" ]; then
865-
echo "The new LOG directory already exists. Migration is not required."
877+
# Remove the old LOG directory since the new one exists
878+
rm -rf "$old_log_dir"
879+
if [ $? -eq 0 ]; then
880+
echo "The new LOG directory already exists. Removed the old LOG directory."
881+
else
882+
echo "Error occurred while removing the old LOG directory."
883+
fi
866884
else
867885
# Move the old LOG directory to the new location
868886
mv "$old_log_dir" "$new_log_dir"
@@ -875,7 +893,7 @@ _migrate_settings_() {
875893
fi
876894
}
877895

878-
_migrate_settings_
896+
_migrate_settings_move
879897

880898
##------------------------------------------##
881899
## Modified by ExtremeFiretop [2024-Jan-24] ##
@@ -1519,13 +1537,20 @@ _GetCurrentFWInstalledLongVersion_()
15191537
##----------------------------------------##
15201538
_GetCurrentFWInstalledShortVersion_()
15211539
{
1540+
##FOR DEBUG ONLY##
1541+
if true
1542+
then
15221543
local theVersionStr extVersNum
15231544

15241545
extVersNum="$(nvram get extendno | awk -F '-' '{print $1}')"
15251546
[ -z "$extVersNum" ] && extVersNum=0
15261547

15271548
theVersionStr="$(nvram get buildno).$extVersNum"
15281549
echo "$theVersionStr"
1550+
else
1551+
##FOR DEBUG ONLY##
1552+
echo "388.5.0"
1553+
fi
15291554
}
15301555

15311556
##-------------------------------------##
@@ -2418,7 +2443,6 @@ Please manually update to version $minimum_supported_version or higher to use th
24182443

24192444
# Get current firmware version #
24202445
current_version="$(_GetCurrentFWInstalledShortVersion_)"
2421-
##FOR DEBUG ONLY##current_version="388.5.0"
24222446

24232447
#---------------------------------------------------------#
24242448
# If the "F/W Update Check" in the WebGUI is disabled
@@ -2599,13 +2623,17 @@ Please manually update to version $minimum_supported_version or higher to use th
25992623
# Format release_version by removing the prefix '3004.' and the last '.0'
26002624
formatted_release_version=$(echo $release_version | awk -F. '{print $2"."$3}')
26012625

2626+
# Define regex patterns for both versions
2627+
release_version_regex="$formatted_release_version \([0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\)"
2628+
current_version_regex="$formatted_current_version \([0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\)"
2629+
2630+
26022631
# Check if the current version is present in the changelog
2603-
if ! grep -qE "^${formatted_current_version} \([0-9]+[-]" "$changelog_file"; then
2632+
if ! grep -Eq "$current_version_regex" "$changelog_file"; then
26042633
Say "Current version not found in change-log. Bypassing change-log verification for this run."
26052634
else
26062635
# Extract log contents between two firmware versions
2607-
changelog_contents=$(awk "/^$formatted_release_version \([0-9]+[-]/,/$formatted_current_version \([0-9]+[-]/" "$changelog_file")
2608-
2636+
changelog_contents=$(awk "/$release_version_regex/,/$current_version_regex/" "$changelog_file")
26092637
# Define high-risk terms as a single string separated by '|'
26102638
high_risk_terms="factory default reset|features are disabled|break backward compatibility|must be manually|strongly recommended"
26112639

@@ -2634,6 +2662,7 @@ Please manually update to version $minimum_supported_version or higher to use th
26342662
Say "Change-logs check disabled."
26352663
fi
26362664

2665+
rog_file=""
26372666
# Detect ROG and pure firmware files
26382667
rog_file="$(ls | grep -i '_rog_')"
26392668
pure_file="$(ls -1 | grep -iE '.*[.](w|pkgtb)$' | grep -iv 'rog')"
@@ -3084,9 +3113,9 @@ then
30843113
printf "Automatic firmware update checks will be DISABLED.\n"
30853114
printf "You can enable this feature later through the menu.\n"
30863115
FW_UpdateCheckState=0
3116+
runfwUpdateCheck=false
30873117
nvram set firmware_check_enable="$FW_UpdateCheckState"
30883118
nvram commit
3089-
runfwUpdateCheck=false
30903119
fi
30913120
else
30923121
printf "Cron job '${GRNct}${CRON_JOB_TAG}${NOct}' already exists.\n"
@@ -3098,8 +3127,6 @@ then
30983127
_WaitForEnterKey_
30993128
fi
31003129

3101-
rog_file=""
3102-
31033130
FW_RouterProductID="${GRNct}${PRODUCT_ID}${NOct}"
31043131
if [ "$PRODUCT_ID" = "$MODEL_ID" ]
31053132
then FW_RouterModelID="${FW_RouterProductID}"
@@ -3311,14 +3338,11 @@ theExitStr="${GRNct}e${NOct}=Exit to main menu"
33113338

33123339
while true
33133340
do
3314-
local_choice_set="$(Get_Custom_Setting "ROGBuild")"
33153341
show_menu
33163342

33173343
# Check if the directory exists again before attempting to navigate to it
33183344
if [ -d "$FW_BIN_DIR" ]; then
33193345
cd "$FW_BIN_DIR"
3320-
# Check for the presence of "rog" in filenames in the directory again
3321-
rog_file="$(ls | grep -i '_rog_')"
33223346
fi
33233347

33243348
printf "Enter selection: " ; read -r userChoice

0 commit comments

Comments
 (0)