global-functions: introduce and use $RequiredRouterOS

This commit is contained in:
Christian Hesse 2021-01-04 10:23:00 +01:00
parent ab267d54b3
commit faf08b0575

View file

@ -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;