mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
global-functions: split $CertificateAvailable to $CertificateDownload
This allows to force download even if certificate is available. We need this for a clean update path with Let's Encrypt.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
# global functions
|
# global functions
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
|
:global CertificateDownload;
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
:global SendEMail;
|
:global SendEMail;
|
||||||
:global SendTelegram;
|
:global SendTelegram;
|
||||||
@@ -79,8 +80,8 @@
|
|||||||
:return ($Return . $String);
|
:return ($Return . $String);
|
||||||
}
|
}
|
||||||
|
|
||||||
# check and import required certificates
|
# download and import certificate
|
||||||
:set CertificateAvailable do={
|
:set CertificateDownload do={
|
||||||
:local CommonName [ :tostr $1 ];
|
:local CommonName [ :tostr $1 ];
|
||||||
|
|
||||||
:global ScriptUpdatesBaseUrl;
|
:global ScriptUpdatesBaseUrl;
|
||||||
@@ -89,9 +90,8 @@
|
|||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
|
|
||||||
:if ([ / certificate print count-only where common-name=$CommonName ] = 0) do={
|
:log info ("Downloading and importing certificate with " . \
|
||||||
:log info ("Certificate with CommonName " . $CommonName . \
|
"CommonName " . $CommonName . ".");
|
||||||
" not available, downloading and importing.");
|
|
||||||
:do {
|
:do {
|
||||||
:local LocalFileName ($CommonName . ".pem");
|
:local LocalFileName ($CommonName . ".pem");
|
||||||
:local UrlFileName ([ $UrlEncode $CommonName ] . ".pem");
|
:local UrlFileName ([ $UrlEncode $CommonName ] . ".pem");
|
||||||
@@ -106,6 +106,17 @@
|
|||||||
:log warning "Failed imprting certificate!";
|
:log warning "Failed imprting certificate!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check and download required certificate
|
||||||
|
:set CertificateAvailable do={
|
||||||
|
:local CommonName [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global CertificateDownload;
|
||||||
|
|
||||||
|
:if ([ / certificate print count-only where common-name=$CommonName ] = 0) do={
|
||||||
|
:log info ("Certificate with CommonName " . $CommonName . " not available.");
|
||||||
|
$CertificateDownload $CommonName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# send notification via e-mail
|
# send notification via e-mail
|
||||||
|
Reference in New Issue
Block a user