aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--global-functions4
-rw-r--r--global-wait11
-rw-r--r--script-updates4
3 files changed, 17 insertions, 2 deletions
diff --git a/global-functions b/global-functions
index be7a7ba..eda9ab6 100644
--- a/global-functions
+++ b/global-functions
@@ -9,6 +9,7 @@
:global ExpectedConfigVersion 13;
# global variables not to be changed by user
+:global GlobalFunctionsReady false;
:global Identity [ / system identity get name ];
:global SentConfigChangesNotification "-";
:global SentLteFirmwareUpgradeNotification "-";
@@ -524,3 +525,6 @@
:delay 1s;
}
}
+
+# signal we are ready
+:set GlobalFunctionsReady true;
diff --git a/global-wait b/global-wait
new file mode 100644
index 0000000..29d634d
--- /dev/null
+++ b/global-wait
@@ -0,0 +1,11 @@
+#!rsc
+# RouterOS script: global-wait
+# Copyright (c) 2020 Christian Hesse <mail@eworm.de>
+#
+# wait for global-functions to finish
+
+:global GlobalFunctionsReady;
+
+:while ($GlobalFunctionsReady != true) do={
+ :delay 500ms;
+}
diff --git a/script-updates b/script-updates
index 6ecdd37..38165c9 100644
--- a/script-updates
+++ b/script-updates
@@ -36,9 +36,9 @@
:if ($SchedulerVal->"name" != "global-scripts" && \
$SchedulerVal->"start-time" = "startup" && \
$SchedulerVal->"interval" = 0s && \
- [ :pick ($SchedulerVal->"on-event") 0 7 ] != ":delay ") do={
+ !(($SchedulerVal->"on-event") ~ "\\brun global-wait\\b")) do={
$LogPrintExit warning ("Scheduler " . $SchedulerVal->"name" . " starts on startup, " . \
- "without interval. Add delay to make sure the configuration is available!") false;
+ "without waiting for global-functions. Run 'global-wait' to avoid race conditions!") false;
}
}