mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-07 19:55:01 +02:00
global-functions: $ScriptInstallUpdate: support checking for device-mode features
This commit is contained in:
parent
106a9bddef
commit
b177e298d7
1 changed files with 24 additions and 10 deletions
|
@ -5,6 +5,7 @@
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.14
|
# requires RouterOS, version=7.14
|
||||||
|
# requires device-mode, fetch, scheduler
|
||||||
#
|
#
|
||||||
# global functions
|
# global functions
|
||||||
# https://rsc.eworm.de/
|
# https://rsc.eworm.de/
|
||||||
|
@ -1071,6 +1072,7 @@
|
||||||
:local ExpectedConfigVersionBefore $ExpectedConfigVersion;
|
:local ExpectedConfigVersionBefore $ExpectedConfigVersion;
|
||||||
:local ReloadGlobalFunctions false;
|
:local ReloadGlobalFunctions false;
|
||||||
:local ReloadGlobalConfig false;
|
:local ReloadGlobalConfig false;
|
||||||
|
:local DeviceMode [ /system/device-mode/get ];
|
||||||
|
|
||||||
:foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={
|
:foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={
|
||||||
:local ScriptVal [ /system/script/get $Script ];
|
:local ScriptVal [ /system/script/get $Script ];
|
||||||
|
@ -1113,6 +1115,14 @@
|
||||||
:if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={
|
:if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={
|
||||||
:local Required ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version");
|
:local Required ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version");
|
||||||
:if ([ $RequiredRouterOS $0 [ $EitherOr $Required "0.0" ] false ] = true) do={
|
:if ([ $RequiredRouterOS $0 [ $EitherOr $Required "0.0" ] false ] = true) do={
|
||||||
|
:local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ];
|
||||||
|
:local MissingDM ({});
|
||||||
|
:foreach Feature,Value in=$RequiredDM do={
|
||||||
|
:if ([ :typeof ($DeviceMode->$Feature) ] = "bool" && ($DeviceMode->$Feature) = false) do={
|
||||||
|
:set MissingDM ($MissingDM, $Feature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:if ([ :len $MissingDM ] = 0) do={
|
||||||
:if ([ $ValidateSyntax $SourceNew ] = true) do={
|
:if ([ $ValidateSyntax $SourceNew ] = true) do={
|
||||||
$LogPrint info $0 ("Updating script: " . $ScriptVal->"name");
|
$LogPrint info $0 ("Updating script: " . $ScriptVal->"name");
|
||||||
/system/script/set owner=($ScriptVal->"name") \
|
/system/script/set owner=($ScriptVal->"name") \
|
||||||
|
@ -1127,6 +1137,10 @@
|
||||||
$LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \
|
$LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \
|
||||||
"' failed! Ignoring!");
|
"' failed! Ignoring!");
|
||||||
}
|
}
|
||||||
|
} else={
|
||||||
|
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \
|
||||||
|
"device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!");
|
||||||
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \
|
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \
|
||||||
$Required . ", which is not met by your installation. Ignoring!");
|
$Required . ", which is not met by your installation. Ignoring!");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue