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;