Skip to content

Commit d0c182e

Browse files
New Checkmarks on WebGUI
Modified WebGUI page with checkmarks to give users the option to "Keep configuration file" when uninstalling, and to "Bypass postponed days" when doing a F/W update check.
1 parent 748de43 commit d0c182e

File tree

2 files changed

+118
-61
lines changed

2 files changed

+118
-61
lines changed

MerlinAU.asp

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<script language="JavaScript" type="text/javascript">
3030
3131
/**----------------------------**/
32-
/** Last Modified: 2025-Jan-21 **/
32+
/** Last Modified: 2025-Jan-22 **/
3333
/** Intended for 1.4.0 Release **/
3434
/**----------------------------**/
3535
@@ -447,7 +447,7 @@ function handleROGFWBuildTypeVisibility()
447447
}
448448
449449
/**----------------------------------------**/
450-
/** Modified by Martinski W. [2025-Jan-13] **/
450+
/** Modified by Martinski W. [2025-Jan-22] **/
451451
/**----------------------------------------**/
452452
function InitializeFields()
453453
{
@@ -471,7 +471,9 @@ function InitializeFields()
471471
let storedFwUpdateEnabled = custom_settings.FW_Update_Check || 'DISABLED';
472472
// fallback to 'DISABLED' if custom_settings.FW_Update_Check is missing //
473473
474-
// Get the checkbox and status elements
474+
$('#KeepConfigFile').prop('checked',false);
475+
$('#BypassPostponedDays').prop('checked',false);
476+
475477
let FW_AutoUpdate_Check = document.getElementById('FW_AutoUpdate_Check');
476478
let fwUpdateCheckStatus = document.getElementById('fwUpdateCheckStatus');
477479
@@ -1127,16 +1129,25 @@ function SaveAdvancedConfig()
11271129
console.log("Advanced Config Form submitted with settings:", updatedSettings);
11281130
}
11291131
1132+
/**----------------------------------------**/
1133+
/** Modified by Martinski W. [2025-Jan-22] **/
1134+
/**----------------------------------------**/
11301135
function Uninstall()
11311136
{
11321137
console.log("Uninstalling MerlinAU...");
11331138
11341139
if (!confirm("Are you sure you want to completely uninstall MerlinAU?"))
11351140
{ return; }
11361141
1137-
document.form.action_script.value = 'start_MerlinAUuninstall';
1138-
document.form.action_wait.value = 10;
1142+
let actionScriptVal;
1143+
let keepConfigFile = document.getElementById('KeepConfigFile');
1144+
if (!keepConfigFile.checked)
1145+
{ actionScriptVal = 'start_MerlinAUuninstall'; }
1146+
else
1147+
{ actionScriptVal = 'start_MerlinAUuninstall_keepConfig'; }
11391148
1149+
document.form.action_script.value = actionScriptVal;
1150+
document.form.action_wait.value = 10;
11401151
showLoading();
11411152
document.form.submit();
11421153
}
@@ -1150,23 +1161,36 @@ function changelogApproval()
11501161
11511162
document.form.action_script.value = 'start_MerlinAUapprovechangelog';
11521163
document.form.action_wait.value = 10;
1153-
11541164
showLoading();
11551165
document.form.submit();
11561166
}
11571167
1158-
function checkFirmwareUpdate()
1168+
/**----------------------------------------**/
1169+
/** Modified by Martinski W. [2025-Jan-22] **/
1170+
/**----------------------------------------**/
1171+
function CheckFirmwareUpdate()
11591172
{
1160-
console.log("Initiating F/W Update Check...");
1161-
1162-
if (!confirm("NOTE:\nIf you have no postponement days set or remaining, the firmware could flash NOW!\nThis means logging you out of the WebUI and rebooting the router.\nContinue to check for firmware updates now?"))
1163-
{ return; }
1173+
console.log("Initiating F/W Update Check...");
11641174
1165-
document.form.action_script.value = 'start_MerlinAUcheckupdate';
1166-
document.form.action_wait.value = 60;
1175+
let actionScriptVal;
1176+
let bypassPostponedDays = document.getElementById('BypassPostponedDays');
1177+
if (!bypassPostponedDays.checked)
1178+
{
1179+
actionScriptVal = 'start_MerlinAUcheckupdate';
1180+
if (!confirm("NOTE:\nIf you have no postponement days set or remaining, the firmware may flash NOW!\nThis means logging you out of the WebUI and rebooting the router.\nContinue to check for firmware updates now?"))
1181+
{ return; }
1182+
}
1183+
else
1184+
{
1185+
actionScriptVal = 'start_MerlinAUcheckupdate_bypassDays';
1186+
if (!confirm("NOTE:\nThe firmware may flash NOW!\nThis means logging you out of the WebUI and rebooting the router.\nContinue to check for firmware updates now?"))
1187+
{ return; }
1188+
}
11671189
1168-
showLoading();
1169-
document.form.submit();
1190+
document.form.action_script.value = actionScriptVal;
1191+
document.form.action_wait.value = 60;
1192+
showLoading();
1193+
document.form.submit();
11701194
}
11711195
11721196
// Function to get the first non-empty value from a list of element IDs
@@ -1439,7 +1463,7 @@ function initializeCollapsibleSections()
14391463
<tr><td colspan="2">Actions (click to expand/collapse)</td></tr>
14401464
</thead>
14411465
<tbody><tr><td colspan="2">
1442-
<div style="text-align: center; margin-top: 10px;">
1466+
<div style="text-align: center; margin-top: 3px;">
14431467
<table width="100%" border="0" cellpadding="10" cellspacing="0" style="table-layout: fixed; border-collapse: collapse; background-color: transparent;">
14441468
<colgroup>
14451469
<col style="width: 33%;" />
@@ -1448,13 +1472,27 @@ function initializeCollapsibleSections()
14481472
</colgroup>
14491473
<tr>
14501474
<td style="text-align: right; border: none;">
1451-
<input type="submit" onclick="checkFirmwareUpdate(); return false;" value="F/W Update Check" class="button_gen savebutton" name="button">
1475+
<input type="submit" id="FWUpdateCheckButton" onclick="CheckFirmwareUpdate();
1476+
return false;" value="F/W Update Check" class="button_gen savebutton" name="button">
1477+
<br>
1478+
<label style="color:#FFCC00; margin-top: 5px; margin-bottom:8x">
1479+
<input type="checkbox" checked="" id="BypassPostponedDays" name="BypassPostponedDays"
1480+
style="padding:0; vertical-align:middle; position:relative; margin-left:-5px; margin-top:5px; margin-bottom:8px"/>Bypass postponed days</label>
1481+
</br>
14521482
</td>
14531483
<td style="text-align: center; border: none;" id="approveChangelogCell">
1454-
<input type="submit" id="approveChangelogButton" onclick="changelogApproval(); return false;" value="Approve Changelog" class="button_gen savebutton" name="button">
1484+
<input type="submit" id="approveChangelogButton" onclick="changelogApproval();
1485+
return false;" value="Approve Changelog" class="button_gen savebutton" name="button">
1486+
<br><label style="margin-top: 5px; margin-bottom:8x"></br>
14551487
</td>
14561488
<td style="text-align: left; border: none;">
1457-
<input type="submit" onclick="Uninstall(); return false;" value="Uninstall" class="button_gen savebutton" name="button">
1489+
<input type="submit" id="UninstallButton" onclick="Uninstall(); return false;"
1490+
value="Uninstall" class="button_gen savebutton" name="button">
1491+
<br>
1492+
<label style="color:#FFCC00; margin-top: 5px; margin-bottom:8x">
1493+
<input type="checkbox" checked="" id="KeepConfigFile" name="KeepConfigFile"
1494+
style="padding:0; vertical-align:middle; position:relative; margin-left:-3px; margin-top:5px; margin-bottom:8px"/>Keep configuration file</label>
1495+
</br>
14581496
</td>
14591497
</tr>
14601498
</table>

MerlinAU.sh

Lines changed: 61 additions & 42 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: 2025-Jan-20
7+
# Last Modified: 2025-Jan-22
88
###################################################################
99
set -u
1010

@@ -159,13 +159,15 @@ else cronListCmd="crontab -l"
159159
fi
160160

161161
##----------------------------------------##
162-
## Modified by Martinski W. [2024-Nov-27] ##
162+
## Modified by Martinski W. [2025-Jan-22] ##
163163
##----------------------------------------##
164164
inMenuMode=true
165165
isInteractive=false
166166
FlashStarted=false
167167
MerlinChangeLogURL=""
168168
GnutonChangeLogURL=""
169+
keepConfigFile=false
170+
bypassPostponedDays=false
169171

170172
# Main LAN Network Info #
171173
readonly myLAN_HostName="$(nvram get lan_hostname)"
@@ -7130,7 +7132,7 @@ _CheckNodeFWUpdateNotification_()
71307132
}
71317133

71327134
##----------------------------------------##
7133-
## Modified by Martinski W. [2024-May-18] ##
7135+
## Modified by Martinski W. [2025-Jan-22] ##
71347136
##----------------------------------------##
71357137
_CheckTimeToUpdateFirmware_()
71367138
{
@@ -7169,13 +7171,13 @@ _CheckTimeToUpdateFirmware_()
71697171
upfwDateTimeStrn="$(date -d @$upfwDateTimeSecs +"%A, %Y-%b-%d %I:%M %p")"
71707172
Say "The firmware update is expected to occur on or after ${GRNct}${upfwDateTimeStrn}${NOct}, depending on when your cron job is scheduled to check again."
71717173
return 1
7174+
else
7175+
Say "The firmware update is expected to occur on ${GRNct}${nextCronTimeSecs}${NOct}."
71727176
fi
71737177

7174-
Say "The firmware update is expected to occur on ${GRNct}${nextCronTimeSecs}${NOct}."
7175-
echo ""
7176-
7177-
# Check if running in a menu environment #
7178-
if "$isInteractive" && _WaitForYESorNO_ "Would you like to proceed with the update now?"
7178+
"$isInteractive" && \
7179+
printf "\n${BOLDct}Would you like to proceed with the update now${NOct}"
7180+
if _WaitForYESorNO_ "$("$bypassPostponedDays" && echo YES || echo NO)"
71797181
then return 0
71807182
else return 1
71817183
fi
@@ -8818,22 +8820,22 @@ _DoInstallation_()
88188820
}
88198821

88208822
##----------------------------------------##
8821-
## Modified by Martinski W. [2025-Jan-20] ##
8823+
## Modified by Martinski W. [2025-Jan-22] ##
88228824
##----------------------------------------##
88238825
_DoUnInstallation_()
88248826
{
8827+
"$isInteractive" && \
88258828
printf "\n${BOLDct}Are you sure you want to uninstall $ScriptFileName script now${NOct}"
88268829
! _WaitForYESorNO_ && return 0
88278830

88288831
if ! _AcquireLock_ cliFileLock ; then return 1 ; fi
88298832

8830-
local doSaveConfig=false
88318833
local savedCFGPath="${SCRIPTS_PATH}/${SCRIPT_NAME}_CFG.SAVED.TXT"
88328834

88338835
printf "\n${BOLDct}Do you want to keep/save the $SCRIPT_NAME configuration file${NOct}"
8834-
if _WaitForYESorNO_ NO
8836+
if _WaitForYESorNO_ "$("$keepConfigFile" && echo YES || echo NO)"
88358837
then
8836-
doSaveConfig=true
8838+
keepConfigFile=true
88378839
mv -f "$CONFIG_FILE" "$savedCFGPath"
88388840
fi
88398841

@@ -8864,7 +8866,7 @@ _DoUnInstallation_()
88648866
Say "${CRITct}**ERROR**: Uninstallation failed.${NOct}"
88658867
fi
88668868

8867-
if "$doSaveConfig"
8869+
if "$keepConfigFile"
88688870
then
88698871
if mkdir -p "$SETTINGS_DIR"
88708872
then
@@ -10291,7 +10293,7 @@ then
1029110293
fi
1029210294

1029310295
##----------------------------------------##
10294-
## Modified by Martinski W. [2024-Jan-15] ##
10296+
## Modified by Martinski W. [2024-Jan-22] ##
1029510297
##----------------------------------------##
1029610298
if [ $# -gt 0 ]
1029710299
then
@@ -10349,35 +10351,52 @@ then
1034910351
uninstall) _DoUnInstallation_
1035010352
;;
1035110353
service_event)
10352-
if [ "$2" = "start" ] && [ "$3" = "${SCRIPT_NAME}uninstall" ]
10353-
then
10354-
_DoUnInstallation_
10355-
sleep 1
10356-
elif [ "$2" = "start" ] && [ "$3" = "${SCRIPT_NAME}approvechangelog" ]
10357-
then
10358-
local currApprovalStatus="$(Get_Custom_Setting "FW_New_Update_Changelog_Approval")"
10359-
if [ "$currApprovalStatus" = "BLOCKED" ]
10360-
then
10361-
Update_Custom_Settings "FW_New_Update_Changelog_Approval" "APPROVED"
10362-
elif [ "$currApprovalStatus" = "APPROVED" ]
10363-
then
10364-
Update_Custom_Settings "FW_New_Update_Changelog_Approval" "BLOCKED"
10365-
fi
10366-
elif [ "$2" = "start" ] && [ "$3" = "${SCRIPT_NAME}checkupdate" ]
10367-
then
10368-
if _AcquireLock_ cliFileLock
10369-
then
10370-
_RunFirmwareUpdateNow_
10371-
_ReleaseLock_ cliFileLock
10372-
fi
10373-
elif [ "$2" = "start" ] && [ "$3" = "${SCRIPT_NAME}config" ]
10354+
if [ "$2" = "start" ]
1037410355
then
10375-
if _AcquireLock_ cliFileLock
10376-
then
10377-
_UpdateConfigFromWebUISettings_
10378-
_ConfirmCronJobForFWAutoUpdates_
10379-
_ReleaseLock_ cliFileLock
10380-
fi
10356+
case "$3" in
10357+
"${SCRIPT_NAME}uninstall" | \
10358+
"${SCRIPT_NAME}uninstall_keepConfig")
10359+
if [ "$3" = "${SCRIPT_NAME}uninstall_keepConfig" ]
10360+
then keepConfigFile=true
10361+
else keepConfigFile=false
10362+
fi
10363+
_DoUnInstallation_
10364+
sleep 1
10365+
;;
10366+
"${SCRIPT_NAME}approvechangelog")
10367+
local currApprovalStatus="$(Get_Custom_Setting "FW_New_Update_Changelog_Approval")"
10368+
if [ "$currApprovalStatus" = "BLOCKED" ]
10369+
then
10370+
Update_Custom_Settings "FW_New_Update_Changelog_Approval" "APPROVED"
10371+
elif [ "$currApprovalStatus" = "APPROVED" ]
10372+
then
10373+
Update_Custom_Settings "FW_New_Update_Changelog_Approval" "BLOCKED"
10374+
fi
10375+
;;
10376+
"${SCRIPT_NAME}checkupdate" | \
10377+
"${SCRIPT_NAME}checkupdate_bypassDays")
10378+
if _AcquireLock_ cliFileLock
10379+
then
10380+
if [ "$3" = "${SCRIPT_NAME}checkupdate_bypassDays" ]
10381+
then bypassPostponedDays=true
10382+
else bypassPostponedDays=false
10383+
fi
10384+
_RunFirmwareUpdateNow_
10385+
_ReleaseLock_ cliFileLock
10386+
fi
10387+
;;
10388+
"${SCRIPT_NAME}config")
10389+
if _AcquireLock_ cliFileLock
10390+
then
10391+
_UpdateConfigFromWebUISettings_
10392+
_ConfirmCronJobForFWAutoUpdates_
10393+
_ReleaseLock_ cliFileLock
10394+
fi
10395+
;;
10396+
*)
10397+
printf "${REDct}INVALID Parameters [$*].${NOct}\n"
10398+
;;
10399+
esac
1038110400
fi
1038210401
;;
1038310402
*) printf "${REDct}INVALID Parameter [$*].${NOct}\n"

0 commit comments

Comments
 (0)