diff --git a/global-config.rsc b/global-config.rsc index e55d9830..e8a86aac 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -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"; diff --git a/global-functions.rsc b/global-functions.rsc index 45bb24d3..e0a73045 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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; @@ -726,11 +726,14 @@ } :do { - :local Line [ :pick $Input 0 [ :find $Input "\n" ] ]; + # Do *NOT* try :deserialize here to split lines. It can fail with + # scripts, and it *does* fail with global-functions! + :local Len [ :find $Input "\n" ]; + :local Line [ :pick $Input 0 $Len ]; :if ([ :typeof [ :find $Line $Pattern ] ] = "num") do={ :return $Line; } - :set Input [ :pick $Input ([ :find $Input "\n" ] + 1) [ :len $Input ] ]; + :set Input [ :pick $Input ($Len + 1) [ :len $Input ] ]; } while=([ :len $Input ] > 0); :return []; diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index b14e1868..b0ac77ac 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -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; } } diff --git a/news-and-changes.rsc b/news-and-changes.rsc index 53f3e7b6..709e7744 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -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