aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-01-04 10:23:00 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-01-04 10:39:11 +0100
commitfaf08b057592faf6f1dd47a2ff63de31f5d6f9f1 (patch)
tree6dc74c3714c9644e9a6e81dbde2666dc385754b9 /global-functions
parentab267d54b35d11fcadbb2b0e3fae7c2e7a61b2a6 (diff)
global-functions: introduce and use $RequiredRouterOS
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions21
1 files changed, 21 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 6f4ffbb..7fa41ea 100644
--- a/global-functions
+++ b/global-functions
@@ -35,6 +35,7 @@
:global MkDir;
:global ParseKeyValueStore;
:global RandomDelay;
+:global RequiredRouterOS;
:global ScriptFromTerminal;
:global ScriptInstallUpdate;
:global ScriptLock;
@@ -517,6 +518,23 @@
:delay ([ $GetRandomNumber $1 ] . "s");
}
+# check for required RouterOS version
+:set RequiredRouterOS do={
+ :local Caller [ :tostr $1 ];
+ :local Required [ :tostr $2 ];
+
+ :global IfThenElse;
+ :global LogPrintExit;
+ :global VersionToNum;
+
+ :if ([ $VersionToNum $Required ] > [ $VersionToNum [ / system package update get installed-version ] ]) do={
+ $LogPrintExit warning ("This " . [ $IfThenElse ([ :pick $Caller 0 ] = "\$") "function" "script" ] . \
+ " '" . $Caller . "' (at least specific functionality) requires RouterOS " . $Required . ". Please update!") false;
+ :return false;
+ }
+ :return true;
+}
+
# check if script is run from terminal
:set ScriptFromTerminal do={
:local Script [ :tostr $1 ];
@@ -1056,5 +1074,8 @@
}
}
+# check for required RouterOS version
+$RequiredRouterOS "global-functions" "6.43";
+
# signal we are ready
:set GlobalFunctionsReady true;