mod/scriptrunonce: switch to $LogPrint

This commit is contained in:
Christian Hesse 2024-03-08 12:45:38 +01:00
parent 699f09c282
commit 8c62c31604

View file

@ -15,13 +15,14 @@
:global ScriptRunOnceBaseUrl;
:global ScriptRunOnceUrlSuffix;
:global LogPrintExit2;
:global LogPrint;
:global ValidateSyntax;
:foreach Script in=$Scripts do={
:if (!($Script ~ "^(ftp|https?|sftp)://")) do={
:if ([ :len $ScriptRunOnceBaseUrl ] = 0) do={
$LogPrintExit2 warning $0 ("Script '" . $Script . "' is not an url and base url is not available.") true;
$LogPrint warning $0 ("Script '" . $Script . "' is not an url and base url is not available.");
:error false;
}
:set Script ($ScriptRunOnceBaseUrl . $Script . ".rsc" . $ScriptRunOnceUrlSuffix);
}
@ -30,19 +31,19 @@
:do {
:set Source ([ /tool/fetch check-certificate=yes-without-crl $Script output=user as-value ]->"data");
} on-error={
$LogPrintExit2 warning $0 ("Failed fetching script '" . $Script . "'!") false;
$LogPrint warning $0 ("Failed fetching script '" . $Script . "'!");
}
:if ([ :len $Source ] > 0) do={
:if ([ $ValidateSyntax $Source ] = true) do={
:do {
$LogPrintExit2 info $0 ("Running script '" . $Script . "' now.") false;
$LogPrint info $0 ("Running script '" . $Script . "' now.");
[ :parse $Source ];
} on-error={
$LogPrintExit2 warning $0 ("The script '" . $Script . "' failed to run!") false;
$LogPrint warning $0 ("The script '" . $Script . "' failed to run!");
}
} else={
$LogPrintExit2 warning $0 ("The script '" . $Script . "' failed syntax validation!") false;
$LogPrint warning $0 ("The script '" . $Script . "' failed syntax validation!");
}
}
}