Compare commits

...

3 commits

Author SHA1 Message Date
Christian Hesse
fa16e79746 mod/notification-email: suppress another racy condition 2026-03-10 13:13:03 +01:00
Christian Hesse
2567c332de mod/notification-email: always use :find for scheduler
This is still racy... Try to improve.
2026-03-10 13:13:03 +01:00
Christian Hesse
51ec9dafb9 check-certificates: decrease the defaults for renewal and warning
https://letsencrypt.org/2025/12/02/from-90-to-45.html
2026-03-10 13:13:03 +01:00
4 changed files with 19 additions and 14 deletions

View file

@ -259,12 +259,12 @@
# Use this for certificate auto-renew
:global CertRenewUrl "";
#:global CertRenewUrl "https://example.com/certificates/";
:global CertRenewTime 3w;
:global CertRenewTime 2w;
:global CertRenewPass {
"v3ry-s3cr3t";
"4n0th3r-s3cr3t";
};
:global CertWarnTime 2w;
:global CertWarnTime 1w;
:global CertIssuedExportPass {
"cert1-cn"="v3ry-s3cr3t";
"cert2-cn"="4n0th3r-s3cr3t";

View file

@ -15,7 +15,7 @@
# Git commit id & info, expected configuration version
:global CommitId "unknown";
:global CommitInfo "unknown";
:global ExpectedConfigVersion 138;
:global ExpectedConfigVersion 139;
# global variables not to be changed by user
:global GlobalFunctionsReady false;

View file

@ -48,11 +48,10 @@
:local AllDone true;
:local QueueLen [ :len $EmailQueue ];
:local Scheduler [ /system/scheduler/find where name="_FlushEmailQueue" ];
:if ([ :len $Scheduler ] > 0 && $QueueLen = 0) do={
:if ([ :len [ /system/scheduler/find where name="_FlushEmailQueue" ] ] > 0 && $QueueLen = 0) do={
$LogPrint warning $0 ("Flushing E-Mail messages from scheduler, but queue is empty.");
/system/scheduler/remove $Scheduler;
/system/scheduler/remove [ find where name="_FlushEmailQueue" ];
:return false;
}
@ -60,15 +59,19 @@
:return true;
}
:if ([ :len $Scheduler ] < 0) do={
:if ([ :len [ /system/scheduler/find where name="_FlushEmailQueue" ] ] < 0) do={
/system/scheduler/add name="_FlushEmailQueue" interval=1m start-time=startup \
comment="Doing initial checks..." on-event=(":global FlushEmailQueue; \$FlushEmailQueue;");
:set Scheduler [ /system/scheduler/find where name="_FlushEmailQueue" ];
}
:local SchedVal [ /system/scheduler/get $Scheduler ];
:if (($SchedVal->"interval") < 1m) do={
/system/scheduler/set interval=1m comment="Doing initial checks..." $Scheduler;
:do {
:if (([ /system/scheduler/get [ find where name="_FlushEmailQueue" ] ]->"interval") < 1m) do={
/system/scheduler/set interval=1m comment="Doing initial checks..." \
[ find where name="_FlushEmailQueue" ];
}
} on-error={
$LogPrint debug $0 ("The scheduler is gone, aborting.");
:return false;
}
:if ([ /tool/e-mail/get last-status ] = "in-progress") do={
@ -87,7 +90,8 @@
:return false;
}
/system/scheduler/set interval=($QueueLen . "m") comment="Sending..." $Scheduler;
/system/scheduler/set interval=($QueueLen . "m") comment="Sending..." \
[ find where name="_FlushEmailQueue" ];
:foreach Id,Message in=$EmailQueue do={
:if ([ :typeof $Message ] = "array" ) do={
@ -143,8 +147,8 @@
:return false;
}
/system/scheduler/set interval=(($SchedVal->"run-count") . "m") \
comment="Waiting for retry..." $Scheduler;
/system/scheduler/set interval=(([ get [ find where name="_FlushEmailQueue" ] ]->"run-count") . "m") \
comment="Waiting for retry..." [ find where name="_FlushEmailQueue" ];
} do={
:global ExitOnError; $ExitOnError $0 $Err;
} }

View file

@ -63,6 +63,7 @@
136="Introduced script 'check-perpetual-license' to check for license state on CHR.";
137="Added support to send notifications via Gotify (gotify.net).";
138="RouterOS 7.19 is suffering an issue with certificate store. Fixing trust state for all certificates...";
139="Certificate Authorities will reduce the leaf certificate validity times soon. Thus the defaults for renewal and warning in 'check-certificates' were decreased.";
};
# Migration steps to be applied on script updates