aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions.d/scriptrunonce
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-11-15 20:22:56 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-11-15 22:18:10 +0100
commit8fc88c73f8cb99774727e7b96f9b85a8bf216c2c (patch)
treee5a36de5fd846a210088b2a21bd436f3f53b4805 /global-functions.d/scriptrunonce
parentf484e45b6a1fe5284462da19c90219d0716d916a (diff)
shorten modules directory name (global-functions.d -> mod)change-67
Diffstat (limited to 'global-functions.d/scriptrunonce')
-rw-r--r--global-functions.d/scriptrunonce46
1 files changed, 0 insertions, 46 deletions
diff --git a/global-functions.d/scriptrunonce b/global-functions.d/scriptrunonce
deleted file mode 100644
index ce9425b..0000000
--- a/global-functions.d/scriptrunonce
+++ /dev/null
@@ -1,46 +0,0 @@
-#!rsc by RouterOS
-# RouterOS script: global-functions.d/scriptrunonece
-# Copyright (c) 2020-2021 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
-
-:global ScriptRunOnce;
-
-# fetch and run script(s) once
-:set ScriptRunOnce do={
- :local Scripts [ :toarray $1 ];
-
- :global ScriptRunOnceBaseUrl;
- :global ScriptRunOnceUrlSuffix;
-
- :global LogPrintExit2;
- :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;
- }
- :set Script ($ScriptRunOnceBaseUrl . $Script . $ScriptRunOnceUrlSuffix);
- }
-
- :local Source;
- :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;
- }
-
- :if ([ :len $Source ] > 0) do={
- :if ([ $ValidateSyntax $Source ] = true) do={
- :do {
- $LogPrintExit2 info $0 ("Running script '" . $Script . "' now.") false;
- [ :parse $Source ];
- } on-error={
- $LogPrintExit2 warning $0 ("The script '" . $Script . "' failed to run!") false;
- }
- } else={
- $LogPrintExit2 warning $0 ("The script '" . $Script . "' failed syntax validation!") false;
- }
- }
- }
-}