Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions MerlinAU.asp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<script language="JavaScript" type="text/javascript">

/**----------------------------**/
/** Last Modified: 2025-Mar-29 **/
/** Last Modified: 2025-Mar-30 **/
/** Intended for 1.4.x Release **/
/**----------------------------**/

Expand Down Expand Up @@ -154,6 +154,7 @@ function FormatNumericSetting (formInput)
/** Added by Martinski W. [2025-Jan-24] **/
/**-------------------------------------**/
const numberRegExp = '^[0-9]+$';
const daysOfWeekNumbr = ['0', '1', '2', '3', '4', '5', '6'];
const daysOfWeekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const daysOfWeekRexpN = '([S|s]un|[M|m]on|[T|t]ue|[W|w]ed|[T|t]hu|[F|f]ri|[S|s]at)';
const daysOfWeekRexp1 = `${daysOfWeekRexpN}|[0-6]`;
Expand Down Expand Up @@ -357,15 +358,24 @@ function ValidateScheduleDAYofWEEK (cronDAYofWEEK)
{ return false; }
}

/**-------------------------------------**/
/** Added by Martinski W. [2025-Jan-25] **/
/**-------------------------------------**/
/**----------------------------------------**/
/** Modified by Martinski W. [2025-Mar-30] **/
/**----------------------------------------**/
function GetListFromRangeDAYofWEEK (cronRangeDAYofWEEK)
{
let theDaysArray = [];
let indexMin = 0, indexMax = 0, theDaysArray = [];
let theDaysRange = cronRangeDAYofWEEK.split ('-');
let indexMin = daysOfWeekNames.indexOf (theDaysRange[0]);
let indexMax = daysOfWeekNames.indexOf (theDaysRange[1]);

if (theDaysRange[0].match ('[0-6]'))
{ indexMin = daysOfWeekNumbr.indexOf (theDaysRange[0]); }
else
{ indexMin = daysOfWeekNames.indexOf (theDaysRange[0]); }

if (theDaysRange[1].match ('[0-6]'))
{ indexMax = daysOfWeekNumbr.indexOf (theDaysRange[1]); }
else
{ indexMax = daysOfWeekNames.indexOf (theDaysRange[1]); }

for (var indx = indexMin; indx <= indexMax; indx++)
{ theDaysArray.push (daysOfWeekNames[indx]) ; }
return (theDaysArray.toString());
Expand Down Expand Up @@ -397,9 +407,9 @@ function GetCronDAYofWEEK (daysOfWeekIndex, daysOfWeekArray)
return (theDaysOfWeek);
}

/**-------------------------------------**/
/** Added by Martinski W. [2025-Jan-25] **/
/**-------------------------------------**/
/**----------------------------------------**/
/** Modified by Martinski W. [2025-Mar-30] **/
/**----------------------------------------**/
function SetScheduleDAYofWEEK (cronDAYofWEEK)
{
let fwScheduleDAYS1, fwSchedBoxDAYSX, fwScheduleXDAYS;
Expand Down Expand Up @@ -430,47 +440,47 @@ function SetScheduleDAYofWEEK (cronDAYofWEEK)
ToggleDaysOfWeek (false, 'X');
let theDAYofWEEK = cronDAYofWEEK;

if (cronDAYofWEEK.match (`${daysOfWeekRexpN}[-]${daysOfWeekRexpN}`) !== null)
if (cronDAYofWEEK.match (`${daysOfWeekRexp2}`) !== null)
{
theDAYofWEEK = GetListFromRangeDAYofWEEK (cronDAYofWEEK);
}
if (theDAYofWEEK.match ('[,]?[M|m]on[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(1|[M|m]on)[,]?') !== null)
{
fwScheduleMON = document.getElementById('fwSched_MON');
fwScheduleMON.checked = true;
fwScheduleMON.disabled = false;
}
if (theDAYofWEEK.match ('[,]?[T|t]ue[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(2|[T|t]ue)[,]?') !== null)
{
fwScheduleTUE = document.getElementById('fwSched_TUE');
fwScheduleTUE.checked = true;
fwScheduleTUE.disabled = false;
}
if (theDAYofWEEK.match ('[,]?[W|w]ed[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(3|[W|w]ed)[,]?') !== null)
{
fwScheduleWED = document.getElementById('fwSched_WED');
fwScheduleWED.checked = true;
fwScheduleWED.disabled = false;
}
if (theDAYofWEEK.match ('[,]?[T|t]hu[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(4|[T|t]hu)[,]?') !== null)
{
fwScheduleTHU = document.getElementById('fwSched_THU');
fwScheduleTHU.checked = true;
fwScheduleTHU.disabled = false;
}
if (theDAYofWEEK.match ('[,]?[F|f]ri[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(5|[F|f]ri)[,]?') !== null)
{
fwScheduleFRI = document.getElementById('fwSched_FRI');
fwScheduleFRI.checked = true;
fwScheduleFRI.disabled = false;
}
if (theDAYofWEEK.match ('[,]?[S|s]at[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(6|[S|s]at)[,]?') !== null)
{
fwScheduleSAT = document.getElementById('fwSched_SAT');
fwScheduleSAT.checked = true;
fwScheduleSAT.disabled = false;
}
if (theDAYofWEEK.match ('[,]?[S|s]un[,]?') !== null)
if (theDAYofWEEK.match ('[,]?(0|[S|s]un)[,]?') !== null)
{
fwScheduleSUN = document.getElementById('fwSched_SUN');
fwScheduleSUN.checked = true;
Expand Down
92 changes: 62 additions & 30 deletions MerlinAU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
# Last Modified: 2025-Mar-28
# Last Modified: 2025-Mar-30
###################################################################
set -u

Expand Down Expand Up @@ -6060,7 +6060,7 @@ _Set_FW_UpdatePostponementDays_()
}

##----------------------------------------##
## Modified by Martinski W. [2025-Jan-22] ##
## Modified by Martinski W. [2025-Mar-29] ##
##----------------------------------------##
_TranslateCronSchedHR_()
{
Expand Down Expand Up @@ -6105,6 +6105,7 @@ _TranslateCronSchedHR_()
theCronHOUR="$(echo "$1" | awk -F ' ' '{print $2}')"
theCronDAYM="$(echo "$1" | awk -F ' ' '{print $3}')"
theCronDAYW="$(echo "$1" | awk -F ' ' '{print $5}')"
theCronDAYW="$(_ConvertDayOfWeekToHR_ "$theCronDAYW")"

if [ "$theCronDAYW" = "*" ] && [ "$theCronDAYM" = "*" ]
then
Expand Down Expand Up @@ -6269,26 +6270,62 @@ _ValidateCronScheduleHOUR_()
}

##-------------------------------------##
## Added by Martinski W. [2024-Nov-23] ##
## Added by Martinski W. [2025-Mar-29] ##
##-------------------------------------##
_ConvertDAYW_NumberToName_()
{ echo "$1" | sed 's/0/Sun/g;s/1/Mon/g;s/2/Tue/g;s/3/Wed/g;s/4/Thu/g;s/5/Fri/g;s/6/Sat/g' ; }

##-------------------------------------##
## Added by Martinski W. [2024-Nov-24] ##
##-------------------------------------##
_ConvertDAYW_NameToNumber_()
{
if [ $# -eq 0 ] && [ -z "$1" ] ; then echo ; return 1; fi
echo "$1" | sed 's/[Ss]un/0/g;s/[Mm]on/1/g;s/[Tt]ue/2/g;s/[Ww]ed/3/g;s/[Tt]hu/4/g;s/[Ff]ri/5/g;s/[Ss]at/6/g'
}

##----------------------------------------##
## Modified by Martinski W. [2025-Mar-29] ##
##----------------------------------------##
_ConvertDAYW_NumToName_()
{
if [ $# -eq 0 ] && [ -z "$1" ] ; then echo ; return 1; fi
local rangeDays rangeFreq
local daysOfWeek rangeDays rangeFreq

if ! echo "$1" | grep -q "/" && \
echo "$1" | grep -q "[0-6]"
then
daysOfWeek="$(_ConvertDAYW_NumberToName_ "$1")"
echo "$daysOfWeek"
return 0
fi

rangeDays="$(echo "$1" | awk -F '/' '{print $1}')"
rangeFreq="$(echo "$1" | awk -F '/' '{print $2}')"
rangeDays="$(echo "$rangeDays" | sed 's/0/Sun/g;s/1/Mon/g;s/2/Tue/g;s/3/Wed/g;s/4/Thu/g;s/5/Fri/g;s/6/Sat/g')"
rangeDays="$(_ConvertDAYW_NumberToName_ "$rangeDays")"
if [ -z "$rangeFreq" ]
then echo "$rangeDays"
else echo "${rangeDays}/$rangeFreq"
fi
return 0
}

_ConvertDAYW_NameToNum_()
##-------------------------------------##
## Added by Martinski W. [2025-Mar-29] ##
##-------------------------------------##
_ConvertDayOfWeekToHR_()
{
if [ $# -eq 0 ] && [ -z "$1" ] ; then echo ; return 1; fi
echo "$1" | sed 's/[Ss]un/0/g;s/[Mm]on/1/g;s/[Tt]ue/2/g;s/[Ww]ed/3/g;s/[Tt]hu/4/g;s/[Ff]ri/5/g;s/[Ss]at/6/g'
local daysOfWeek="$1"
if echo "$1" | grep -qE "^[fmstw]"
then
daysOfWeek="$(_CapitalizeFirstChar_ "$1")"
elif ! echo "$1" | grep -q '[*/]' && \
echo "$1" | grep -q "[0-6]"
then
daysOfWeek="$(_ConvertDAYW_NumToName_ "$1")"
fi
echo "$daysOfWeek"
return 0
}

Expand All @@ -6301,7 +6338,7 @@ _ValidateCronNumOrderDAYW_()
local numDAYS numDays1 numDays2
if ! echo "$1" | grep -qE "[a-zA-Z]"
then numDAYS="$1"
else numDAYS="$(_ConvertDAYW_NameToNum_ "$1")"
else numDAYS="$(_ConvertDAYW_NameToNumber_ "$1")"
fi
numDays1="$(echo "$numDAYS" | awk -F '[-/]' '{print $1}')"
numDays2="$(echo "$numDAYS" | awk -F '[-/]' '{print $2}')"
Expand Down Expand Up @@ -6341,19 +6378,19 @@ _ValidateCronScheduleDAYofWEEK_()
return 1
}

##-------------------------------------##
## Added by Martinski W. [2024-Nov-24] ##
##-------------------------------------##
##----------------------------------------##
## Modified by Martinski W. [2025-Mar-30] ##
##----------------------------------------##
#----------------------------------------------------------#
# Allow ONLY full numbers within the range [1-31]
# some intervals [ * */[2-9] */10 */12 */15 ],
# some intervals [ * */[2-9] */10 */12 */14 */15 ],
# lists and ranges for the purposes of doing F/W Updates.
#----------------------------------------------------------#
_ValidateCronScheduleDAYofMONTH_()
{
if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi
if [ "$1" = "*" ] || \
echo "$1" | grep -qE "^[*]/([2-9]|10|12|15)$"
echo "$1" | grep -qE "^[*]/([2-9]|10|12|14|15)$"
then return 0 ; fi
if echo "$1" | grep -qE "^${CRON_DAYofMONTH_RegEx}$"
then
Expand All @@ -6369,8 +6406,8 @@ _ValidateCronScheduleDAYofMONTH_()
fi
fi
printf "\n${REDct}INVALID cron value for 'DAY of MONTH' [$1]${NOct}\n"
printf "${REDct}NOTE${NOct}: Only numbers within the range [1-31],\n"
printf "specific intervals (* */[2-9] */10 */12 */15),\n"
printf "${REDct}NOTE${NOct}: Only numbers within the range [1-31], some\n"
printf "specific intervals (* */[2-9] */10 */12 */14 */15),\n"
printf "lists of numbers, and single ranges are valid.\n"
return 1
}
Expand Down Expand Up @@ -6530,14 +6567,14 @@ _ShowCronMenuHeader_()
}

##----------------------------------------##
## Modified by Martinski W. [2024-Dec-20] ##
## Modified by Martinski W. [2025-Mar-29] ##
##----------------------------------------##
_GetCronScheduleInputDAYofMONTH_()
{
if [ $# -eq 0 ] || [ -z "$1" ] ; then return 1 ; fi
local oldSchedDAYM newSchedDAYM oldSchedDAYHR

_GetSchedDaysHR_()
_GetSchedDayOfMonthHR_()
{
local cruDAYS="$1"
[ "$1" = "*" ] && cruDAYS="Every day"
Expand All @@ -6546,7 +6583,7 @@ _GetCronScheduleInputDAYofMONTH_()

newSchedDAYM=""
oldSchedDAYM="$1"
oldSchedDAYHR="$(_GetSchedDaysHR_ "$1")"
oldSchedDAYHR="$(_GetSchedDayOfMonthHR_ "$1")"

while true
do
Expand Down Expand Up @@ -6578,7 +6615,7 @@ _GetCronScheduleInputDAYofMONTH_()
}

##----------------------------------------##
## Modified by Martinski W. [2024-Dec-20] ##
## Modified by Martinski W. [2025-Mar-29] ##
##----------------------------------------##
_GetCronScheduleInputDAYofWEEK_()
{
Expand All @@ -6588,7 +6625,7 @@ _GetCronScheduleInputDAYofWEEK_()
_DayOfWeekNumToDayName_()
{ echo "$1" | sed 's/0/Sun/;s/1/Mon/;s/2/Tue/;s/3/Wed/;s/4/Thu/;s/5/Fri/;s/6/Sat/;' ; }

_GetSchedDaysHR_()
_GetSchedDayOfWeekHR_()
{
local cruDAYS="$1"
if [ "$1" = "*" ]
Expand All @@ -6601,7 +6638,7 @@ _GetCronScheduleInputDAYofWEEK_()

newSchedDAYW=""
oldSchedDAYW="$1"
oldSchedDAYHR="$(_GetSchedDaysHR_ "$1")"
oldSchedDAYHR="$(_GetSchedDayOfWeekHR_ "$1")"

while true
do
Expand All @@ -6622,22 +6659,17 @@ _GetCronScheduleInputDAYofWEEK_()
then
newSchedDAYW="$oldSchedDAYW"
if _ValidateCronScheduleDAYofWEEK_ "$oldSchedDAYW"
then break #Keep Current Value#
then #Keep Current Value#
newSchedDAYW="$(_ConvertDayOfWeekToHR_ "$oldSchedDAYW")"
break
fi
elif _CheckForCancelAndExitMenu_ "$newSchedDAYW" || \
_CheckForReturnToBeginMenu_ "$newSchedDAYW" || \
_CheckForSavedThenExitMenu_ "$newSchedDAYW"
then break
elif _ValidateCronScheduleDAYofWEEK_ "$newSchedDAYW"
then
if echo "$newSchedDAYW" | grep -qE "[fmstw]"
then
newSchedDAYW="$(_CapitalizeFirstChar_ "$newSchedDAYW")"
elif ! echo "$newSchedDAYW" | grep -q '[*/]' && \
echo "$newSchedDAYW" | grep -q "[0-6]"
then
newSchedDAYW="$(_ConvertDAYW_NumToName_ "$newSchedDAYW")"
fi
newSchedDAYW="$(_ConvertDayOfWeekToHR_ "$newSchedDAYW")"
break
fi
_WaitForEnterKey_
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater
## v1.4.0
## 2025-Mar-29
## 2025-Mar-30

## WebUI:
![image](https://github.com/user-attachments/assets/10d0971c-b3c6-477a-8904-d4bf013f72df)
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1.4.0
25032921
25033001