From faf08b057592faf6f1dd47a2ff63de31f5d6f9f1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 4 Jan 2021 10:23:00 +0100 Subject: global-functions: introduce and use $RequiredRouterOS --- global-functions | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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; -- cgit v1.2.3-70-g09d2