aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-04-28 09:34:12 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-04-28 10:39:25 +0200
commit4cda1281f1d83208bf6a6c704cbf67b7e7e83b8a (patch)
tree757baf278cf75e1c0d310a01a8b15dec2032348c
parent006e054517954b4bf97f11f9d9a5061bf32d3a3e (diff)
global-functions: validate syntax of modules
(cherry picked from commit 7c8e230521f1a936da034dfc05197fe9434926ed)
-rw-r--r--global-functions7
1 files changed, 6 insertions, 1 deletions
diff --git a/global-functions b/global-functions
index a86c1ea..89234f9 100644
--- a/global-functions
+++ b/global-functions
@@ -1271,7 +1271,12 @@
# load modules
:foreach Script in=[ / system script find where name ~ "^mod/." ] do={
- / system script run $Script;
+ :local ScriptVal [ / system script get $Script ];
+ :if ([ $ValidateSyntax ($ScriptVal->"source") ] = true) do={
+ / system script run $Script;
+ } else={
+ $LogPrintExit2 error $0 ("Module '" . $ScriptVal->"name" . "' failed syntax validation, skipping.") false;
+ }
}
# check for required RouterOS version