mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $ScriptInstallUpdate: add syntax validation
This commit is contained in:
parent
d0cdad791c
commit
bd6b67ad7a
|
@ -670,6 +670,13 @@
|
||||||
:if ([ :len $SourceNew ] > 0) do={
|
:if ([ :len $SourceNew ] > 0) do={
|
||||||
:if ($SourceNew != $ScriptVal->"source") do={
|
:if ($SourceNew != $ScriptVal->"source") do={
|
||||||
:if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={
|
:if ([ :pick $SourceNew 0 18 ] = "#!rsc by RouterOS\n") do={
|
||||||
|
:local SyntaxOK true;
|
||||||
|
:do {
|
||||||
|
[ :parse (":local ValidateFunction do={ " . $SourceNew . " }") ]
|
||||||
|
} on-error={
|
||||||
|
:set SyntaxOK false;
|
||||||
|
}
|
||||||
|
:if ($SyntaxOK = true) do={
|
||||||
:local DontRequirePermissions \
|
:local DontRequirePermissions \
|
||||||
($SourceNew~"\n# requires: dont-require-permissions=yes\n");
|
($SourceNew~"\n# requires: dont-require-permissions=yes\n");
|
||||||
$LogPrintExit2 info $0 ("Updating script: " . $ScriptVal->"name") false;
|
$LogPrintExit2 info $0 ("Updating script: " . $ScriptVal->"name") false;
|
||||||
|
@ -680,7 +687,8 @@
|
||||||
:do {
|
:do {
|
||||||
/ system script { run global-config; run global-config-overlay; }
|
/ system script { run global-config; run global-config-overlay; }
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 error $0 ("Reloading global configuration and overlay failed! Syntax error\?") false;
|
$LogPrintExit2 error $0 ("Reloading global configuration and overlay failed!" . \
|
||||||
|
" Syntax error or missing overlay\?") false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:if ($ScriptVal->"name" = "global-functions") do={
|
:if ($ScriptVal->"name" = "global-functions") do={
|
||||||
|
@ -691,6 +699,10 @@
|
||||||
$LogPrintExit2 error $0 ("Reloading global functions failed!") false;
|
$LogPrintExit2 error $0 ("Reloading global functions failed!") false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else={
|
||||||
|
$LogPrintExit2 warning $0 ("Syntax validation for script " . $ScriptVal->"name" . \
|
||||||
|
" failed! Ignoring!") false;
|
||||||
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 warning $0 ("Looks like new script " . $ScriptVal->"name" . \
|
$LogPrintExit2 warning $0 ("Looks like new script " . $ScriptVal->"name" . \
|
||||||
" is not valid (missing shebang). Ignoring!") false;
|
" is not valid (missing shebang). Ignoring!") false;
|
||||||
|
|
Loading…
Reference in a new issue