aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-11-15 22:17:43 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-11-16 22:21:37 +0100
commit185fe2c73035b66b2c8e0048eedca47fd438e3e6 (patch)
tree06daedc04508595aa2f69f6b9ea21d4324d6c9d1
parent3b997d30870b08b18adc051af5ecca639bd12add (diff)
reintroduce global-waitchange-68
-rw-r--r--README.md1
-rw-r--r--doc/global-wait.md40
-rw-r--r--doc/mod/bridge-port-to.md4
-rw-r--r--doc/mod/bridge-port-vlan.md4
-rw-r--r--global-config2
-rw-r--r--global-config-overlay2
-rw-r--r--global-config.changes3
-rw-r--r--global-functions2
-rw-r--r--global-wait13
9 files changed, 65 insertions, 6 deletions
diff --git a/README.md b/README.md
index d252deb..dfec35a 100644
--- a/README.md
+++ b/README.md
@@ -172,6 +172,7 @@ Available Scripts
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md)
* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md)
* [Send backup via e-mail](doc/email-backup.md)
+* [Wait for global functions und modules](doc/global-wait.md)
* [Send GPS position to server](doc/gps-track.md)
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
* [Create DNS records for IPSec peers](doc/ipsec-to-dns.md)
diff --git a/doc/global-wait.md b/doc/global-wait.md
new file mode 100644
index 0000000..2d9dad3
--- /dev/null
+++ b/doc/global-wait.md
@@ -0,0 +1,40 @@
+Wait for global functions and modules
+=====================================
+
+[◀ Go back to main README](../README.md)
+
+🛈 This script can not be used on its own but requires the base installation.
+See [main README](../README.md) for details.
+
+Description
+-----------
+
+The global functions from `global-functions` and modules are loaded by
+scheduler at system startup. Running these functions at system startup may
+result in race condition where configuration and/or function are not yet
+available. This script is supposed to wait for everything being prepared.
+
+Do **not** add this script `global-wait` to the `global-scripts` scheduler!
+It would inhibit the initialization of configuration and functions.
+
+Requirements and installation
+-----------------------------
+
+Just install the script:
+
+ $ScriptInstallUpdate global-wait;
+
+... and add it to your scheduler, for example in combination with the module
+to [manage VLANs on bridge ports](mod/bridge-port-vlan.md):
+
+ / system scheduler add name=bridge-port-vlan on-event="/ system script run global-wait; :global BridgePortVlan; \$BridgePortVlan default;" start-time=startup;
+
+See also
+--------
+
+* [Manage ports in bridge](mod/bridge-port-to.md)
+* [Manage VLANs on bridge ports](mod/bridge-port-vlan.md)
+
+---
+[◀ Go back to main README](../README.md)
+[▲ Go back to top](#top)
diff --git a/doc/mod/bridge-port-to.md b/doc/mod/bridge-port-to.md
index 89ee5d0..5b2817b 100644
--- a/doc/mod/bridge-port-to.md
+++ b/doc/mod/bridge-port-to.md
@@ -34,7 +34,8 @@ Also dhcp client can be handled:
Add a scheduler to start with default setup on system startup:
- / system scheduler add name=bridge-port-to on-event=":global GlobalFunctionsReady; :while (\$GlobalFunctionsReady != true) do={ :delay 500ms; }; :global BridgePortTo; \$BridgePortTo default;" start-time=startup;
+ $ScriptInstallUpdate global-wait;
+ / system scheduler add name=bridge-port-vlan on-event="/ system script run global-wait; :global BridgePortTo; \$BridgePortTo default;" start-time=startup;
Usage and invocation
--------------------
@@ -72,6 +73,7 @@ configuration:
See also
--------
+* [Wait for global functions und modules](../global-wait.md)
* [Manage VLANs on bridge ports](bridge-port-vlan.md)
---
diff --git a/doc/mod/bridge-port-vlan.md b/doc/mod/bridge-port-vlan.md
index 8b88777..67dd04d 100644
--- a/doc/mod/bridge-port-vlan.md
+++ b/doc/mod/bridge-port-vlan.md
@@ -39,7 +39,8 @@ Also dhcp client can be handled:
Add a scheduler to start with default setup on system startup:
- / system scheduler add name=bridge-port-vlan on-event=":global GlobalFunctionsReady; :while (\$GlobalFunctionsReady != true) do={ :delay 500ms; }; :global BridgePortVlan; \$BridgePortVlan default;" start-time=startup;
+ $ScriptInstallUpdate global-wait;
+ / system scheduler add name=bridge-port-vlan on-event="/ system script run global-wait; :global BridgePortVlan; \$BridgePortVlan default;" start-time=startup;
Usage and invocation
--------------------
@@ -76,6 +77,7 @@ configuration:
See also
--------
+* [Wait for global functions und modules](../global-wait.md)
* [Manage ports in bridge](bridge-port-to.md)
---
diff --git a/global-config b/global-config
index 2ad80d7..5f533b4 100644
--- a/global-config
+++ b/global-config
@@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
-:global GlobalConfigVersion 67;
+:global GlobalConfigVersion 68;
# This is used for DNS and backup file.
:global Domain "example.com";
diff --git a/global-config-overlay b/global-config-overlay
index 07280cd..4f8eee5 100644
--- a/global-config-overlay
+++ b/global-config-overlay
@@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
# Comment or remove to disable news and change notifications.
-:global GlobalConfigVersion 67;
+:global GlobalConfigVersion 68;
# Copy configuration from global-config here and modify it.
diff --git a/global-config.changes b/global-config.changes
index 2f30563..2914ea9 100644
--- a/global-config.changes
+++ b/global-config.changes
@@ -71,6 +71,7 @@
65="Added module to manage VLANs on bridge ports.";
66="Moved script 'bridge-port-to-default' to new module.";
67="Moved modules to directory with shorter name.";
+ 68="Reintroduced 'global-wait' for functions in scheduler.";
};
# Migration steps to be applied on script updates
@@ -79,7 +80,7 @@
47="/ certificate remove [ find where fingerprint=\"731d3d9cfaa061487a1d71445a42f67df0afca2a6c2d2f98ff7b3ce112b1f568\" or fingerprint=\"25847d668eb4f04fdd40b12b6b0740c567da7d024308eb6c2c96fe41d9de218d\" ];";
52=":global CertificateDownload; :if ([ :len [ / certificate find where fingerprint=\"67add1166b020ae61b8f5fc96813c04c2aa589960796865572a3c7e737613dfd\" or fingerprint=\"96bcec06264976f37460779acf28c5a7cfe8a3c0aae11a8ffcee05c0bddf08c6\" ] ] < 2) do={ \$CertificateDownload \"R3\"; }; / certificate remove [ find where fingerprint=\"0687260331a72403d909f105e69bcf0d32e1bd2493ffc6d9206d11bcd6770739\" ];";
54=":global ScriptInstallUpdate; :global TelegramTokenId; :global TelegramChatId; :if ([ :len \$TelegramTokenId ] > 0 && [ :len \$TelegramChatId ] > 0) do={ \$ScriptInstallUpdate mod/notification-telegram; }";
- 61="/ system script remove [ find where name~\"^(early-errors|global-wait|mode-button-(event|scheduler)|script-updates)\\\$\" source~\"^#!rsc by RouterOS\\n\" ];";
+ 61="/ system script remove [ find where name~\"^(early-errors|mode-button-(event|scheduler)|script-updates)\\\$\" source~\"^#!rsc by RouterOS\\n\" ];";
66=":global ScriptInstallUpdate; :if ([ :len [ / system script find where name=\"bridge-port-to-default\" ] ] > 0) do={ / system script remove [ find where name~\"^bridge-port-to(-default|ggle)\\\$\" ]; \$ScriptInstallUpdate mod/bridge-port-to; }";
67=":global ScriptInstallUpdate; :global CharacterReplace; :foreach Script in=[ / system script find where name~\"^global-functions.d/\" ] do={ / system script set name=[ \$CharacterReplace [ / system script get \$Script name ] \"global-functions.d/\" \"mod/\" ] \$Script; }; \$ScriptInstallUpdate;";
};
diff --git a/global-functions b/global-functions
index ad6b555..f5bca7a 100644
--- a/global-functions
+++ b/global-functions
@@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
-:global ExpectedConfigVersion 67;
+:global ExpectedConfigVersion 68;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
diff --git a/global-wait b/global-wait
new file mode 100644
index 0000000..c601f69
--- /dev/null
+++ b/global-wait
@@ -0,0 +1,13 @@
+#!rsc by RouterOS
+# RouterOS script: global-wait
+# Copyright (c) 2020-2021 Christian Hesse <mail@eworm.de>
+# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+#
+# provides: backup-script
+#
+# wait for global-functions to finish
+# https://git.eworm.de/cgit/routeros-scripts/about/doc/global-wait.md
+
+:local 0 "global-wait";
+:global GlobalFunctionsReady;
+:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }