global: drop script 'global-wait'

All scripts wait for the global functions on their own now.
This commit is contained in:
Christian Hesse 2021-02-18 14:52:47 +01:00
parent 2db73a189c
commit d5afc79eed
51 changed files with 137 additions and 81 deletions

View file

@ -165,7 +165,6 @@ 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 configuration und functions](doc/global-wait.md)
* [Send GPS position to server](doc/gps-track.md)
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
* [Update configuration on IPv6 prefix change](doc/ipv6-update.md)

View file

@ -8,6 +8,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local Seen [ :toarray "" ];
:local Shown [ :toarray "" ];

View file

@ -8,6 +8,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local Seen [ :toarray "" ];
:local Shown [ :toarray "" ];

View file

@ -9,6 +9,9 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local Seen [ :toarray "" ];
:local Shown [ :toarray "" ];

View file

@ -6,6 +6,9 @@
# reset bridge ports to default bridge
# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BridgePortTo;
:global IfThenElse;

View file

@ -6,6 +6,9 @@
# toggle bridge ports between default and alt bridge
# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BridgePortTo;
:if ($BridgePortTo != "default") do={

View file

@ -7,6 +7,9 @@
# download and cleanup packages for CAP installation from CAPsMAN
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-download-packages.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CleanFilePath;
:global DownloadPackage;
:global LogPrintExit;

View file

@ -7,6 +7,9 @@
# upgrade CAPs one after another
# https://git.eworm.de/cgit/routeros-scripts/about/doc/capsman-rolling-upgrade.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:global ScriptLock;

View file

@ -6,6 +6,9 @@
# renew locally issued certificates
# https://git.eworm.de/cgit/routeros-scripts/about/doc/certificate-renew-issued.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertIssuedExportPass;
:global LogPrintExit;

View file

@ -6,6 +6,9 @@
# check for certificate validity
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-certificates.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertRenewPass;
:global CertRenewTime;
:global CertRenewUrl;

View file

@ -6,6 +6,9 @@
# check for RouterOS health state
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-health.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CheckHealthLast;
:global CheckHealthTemperature;
:global CheckHealthTemperatureDeviation;

View file

@ -6,6 +6,9 @@
# check for LTE firmware upgrade, send notification
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-lte-firmware-upgrade.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global SentLteFirmwareUpgradeNotification;

View file

@ -6,6 +6,9 @@
# check for RouterOS update, send notification and/or install
# https://git.eworm.de/cgit/routeros-scripts/about/doc/check-routeros-update.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global SafeUpdateNeighbor;
:global SafeUpdatePatch;

View file

@ -6,6 +6,9 @@
# upload backup to MikroTik cloud
# https://git.eworm.de/cgit/routeros-scripts/about/doc/cloud-backup.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BackupPassword;
:global Identity;

View file

@ -8,6 +8,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global GetMacVendor;

View file

@ -8,6 +8,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global GetMacVendor;

View file

@ -9,6 +9,9 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global GetMacVendor;

View file

@ -9,6 +9,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment;
:global Identity;

View file

@ -9,6 +9,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment;
:global Identity;

View file

@ -10,6 +10,9 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DailyPskMatchComment;
:global Identity;

View file

@ -8,6 +8,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={

View file

@ -8,6 +8,9 @@
#
# !! Do not edit this file, it is generated from template!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={

View file

@ -9,6 +9,9 @@
# !! This is just a template! Replace '%PATH%' with 'caps-man'
# !! or 'interface wireless'!
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={

View file

@ -6,6 +6,9 @@
# check DHCP leases and add/remove/update DNS entries
# https://git.eworm.de/cgit/routeros-scripts/about/doc/dhcp-to-dns.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Domain;
:global HostNameInZone;
:global Identity;

View file

@ -33,11 +33,9 @@ There is also global configuration:
* `BridgePortTo`: specify the configuration to be applied by default
Install [global-wait](global-wait.md) and add a scheduler to start with
default setup on system startup:
Add a scheduler to start with default setup on system startup:
$ScriptInstallUpdate global-wait;
/ system scheduler add name=bridge-port-to-default on-event="/ system script { run global-wait; run bridge-port-to-default; }" start-time=startup;
/ system scheduler add name=bridge-port-to-default on-event="/ system script run bridge-port-to-default;" start-time=startup;
Usage and invocation
--------------------
@ -75,11 +73,6 @@ More configuration can be loaded by setting `BridgePortTo`:
* Interfaces `en1` and `en2` are unchanged.
* Interface `en3` is put in bridge `br-intern`.
See also
--------
* [Wait for configuration und functions](global-wait.md)
---
[◀ Go back to main README](../README.md)
[▲ Go back to top](#top)

View file

@ -19,11 +19,9 @@ Just install the script on CAPsMAN device:
$ScriptInstallUpdate capsman-download-packages;
Optionally install [global-wait](global-wait.md) and add a scheduler to run
after startup:
Optionally add a scheduler to run after startup:
$ScriptInstallUpdate global-wait;
/ system scheduler add name=capsman-download-packages on-event="/ system script { run global-wait; run capsman-download-packages; }" start-time=startup;
/ system scheduler add name=capsman-download-packages on-event="/ system script run capsman-download-packages;" start-time=startup;
Only packages available in older version are downloaded. For initial setup
place the required packages to CAPsMAN package path (see
@ -55,7 +53,6 @@ See also
--------
* [Run rolling CAP upgrades from CAPsMAN](capsman-rolling-upgrade.md)
* [Wait for configuration und functions](global-wait.md)
---
[◀ Go back to main README](../README.md)

View file

@ -44,7 +44,7 @@ Just run the script:
Alternatively running on startup may be desired:
/ system scheduler add name=check-certificates-startup on-event="/ system script { run global-wait; run check-certificates; }" start-time=startup;
/ system scheduler add name=check-certificates-startup on-event="/ system script run check-certificates;" start-time=startup;
See also
--------

View file

@ -12,23 +12,23 @@ passphrase to a pseudo-random string daily.
Requirements and installation
-----------------------------
Just install this script and [global-wait](global-wait.md).
Just install this script.
Depending on whether you use CAPsMAN (`/ caps-man`) or local wireless
interface (`/ interface wireless`) you need to install a different script.
For CAPsMAN:
$ScriptInstallUpdate daily-psk.capsman,global-wait;
$ScriptInstallUpdate daily-psk.capsman;
For local interface:
$ScriptInstallUpdate daily-psk.local,global-wait;
$ScriptInstallUpdate daily-psk.local;
And add schedulers to run the script:
/ system scheduler add interval=1d name=daily-psk-nightly on-event="/ system script run daily-psk.local;" start-date=may/23/2018 start-time=03:00:00;
/ system scheduler add name=daily-psk-startup on-event="/ system script { run global-wait; run daily-psk.local; }" start-time=startup;
/ system scheduler add name=daily-psk-startup on-event="/ system script run daily-psk.local;" start-time=startup;
These will update the passphrase on boot and nightly at 3:00.
@ -46,11 +46,6 @@ Then add an access list entry:
Also notification settings are required for e-mail and telegram.
See also
--------
* [Wait for configuration und functions](global-wait.md)
---
[◀ Go back to main README](../README.md)
[▲ Go back to top](#top)

View file

@ -1,40 +0,0 @@
Wait for configuration und functions
====================================
[◀ Go back to main README](../README.md)
Description
-----------
The global scripts `global-config`, `global-config-overlay` and
`global-functions` are run by scheduler at system startup. Running another
script 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
[bridge-port](bridge-port.md):
/ system scheduler add name=bridge-port-to-default on-event="/ system script { run global-wait; run bridge-port-to-default; }" start-time=startup;
See also
--------
* [Manage ports in bridge](bridge-port.md)
* [Download packages for CAP upgrade from CAPsMAN](capsman-download-packages.md)
* [Renew certificates and notify on expiration](check-certificates.md)
* [Use wireless network with daily psk](daily-psk.md)
---
[◀ Go back to main README](../README.md)
[▲ Go back to top](#top)

View file

@ -6,6 +6,9 @@
# create and email backup and config file
# https://git.eworm.de/cgit/routeros-scripts/about/doc/email-backup.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BackupPassword;
:global BackupSendBinary;
:global BackupSendExport;

View file

@ -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 43;
:global GlobalConfigVersion 44;
# This is used for DNS and backup file.
:global Domain "example.com";

View file

@ -9,7 +9,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 change notifications.
:global GlobalConfigVersion 43;
:global GlobalConfigVersion 44;
# Copy configuration from global-config here and modify it.

View file

@ -47,6 +47,7 @@
41="Implemented migration mechanism for script updates.";
42="Made severity in terminal output colorful, with opt-out.";
43="Added queue for e-mail notifications to resend later on error.";
44="Dropped script 'global-wait', all scripts wait on their own now.";
};
# Migration steps to be applied on script updates

View file

@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
:global ExpectedConfigVersion 43;
:global ExpectedConfigVersion 44;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
@ -624,13 +624,6 @@
$LogPrintExit warning ("Policies differ for script " . $ScriptVal->"name" . \
" and its scheduler " . $SchedulerVal->"name" . "!") false;
}
:if ($SchedulerVal->"name" != "global-scripts" && \
$SchedulerVal->"start-time" = "startup" && \
$SchedulerVal->"interval" = 0s && \
!(($SchedulerVal->"on-event") ~ "\\brun global-wait\\b")) do={
$LogPrintExit warning ("Scheduler " . $SchedulerVal->"name" . " starts on startup, " . \
"without waiting for global-functions. Run 'global-wait' to avoid race conditions!") false;
}
}
:if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={

View file

@ -1,13 +1,11 @@
#!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
#
# wait for global-functions to finish
# https://git.eworm.de/cgit/routeros-scripts/about/doc/global-wait.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={
:delay 500ms;
}
:global LogPrintExit;
$LogPrintExit warning ("This script 'global-wait' is now useless, please remove it from configuration.") true;

View file

@ -6,6 +6,9 @@
# track gps data by sending json data to http server
# https://git.eworm.de/cgit/routeros-scripts/about/doc/gps-track.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global GpsTrackUrl;
:global Identity;

View file

@ -6,6 +6,9 @@
# add private WPA passphrase after hotspot login
# https://git.eworm.de/cgit/routeros-scripts/about/doc/hotspot-to-wpa.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:local MacAddress $"mac-address";

View file

@ -6,6 +6,9 @@
# update firewall and dns settings on IPv6 prefix change
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ipv6-update.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local PdPrefix $"pd-prefix";
:global LogPrintExit;

View file

@ -6,6 +6,9 @@
# run scripts on DHCP lease
# https://git.eworm.de/cgit/routeros-scripts/about/doc/lease-script.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:if ([ :typeof $leaseActIP ] = "nothing" || \

View file

@ -6,6 +6,9 @@
# forward log messages via notification
# https://git.eworm.de/cgit/routeros-scripts/about/doc/log-forward.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global LogForwardFilter;
:global LogForwardFilterMessage;

View file

@ -6,6 +6,9 @@
# act on multiple mode and reset button presses
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global ModeButton;
:global LogPrintExit;

View file

@ -6,6 +6,9 @@
# monitor netwatch and send notifications
# https://git.eworm.de/cgit/routeros-scripts/about/doc/netwatch-notify.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NetwatchNotify;
:global IfThenElse;

View file

@ -6,6 +6,9 @@
# visualize ospf instance state via leds
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ospf-to-leds.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:global ParseKeyValueStore;

View file

@ -6,6 +6,9 @@
# download packages and reboot for installation
# https://git.eworm.de/cgit/routeros-scripts/about/doc/packages-update.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DownloadPackage;
:global LogPrintExit;
:global ScriptFromTerminal;

View file

@ -6,6 +6,9 @@
# run scripts on ppp up
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ppp-on-up.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
:local Interface $interface;

View file

@ -6,6 +6,9 @@
# rotate the ntp servers
# https://git.eworm.de/cgit/routeros-scripts/about/doc/rotate-ntp.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NtpPool;
:global LogPrintExit;

View file

@ -6,6 +6,9 @@
# run action on received SMS
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-action.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global SmsAction;
:global LogPrintExit;

View file

@ -6,6 +6,9 @@
# forward SMS to e-mail
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-forward.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global Identity;
:global IfThenElse;

View file

@ -7,6 +7,9 @@
# ipsec remote peer
# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-gre-address.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit;
/ interface gre set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ];

View file

@ -7,6 +7,9 @@
# update local address of tunnelbroker interface
# https://git.eworm.de/cgit/routeros-scripts/about/doc/update-tunnelbroker.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CertificateAvailable;
:global LogPrintExit;
:global ParseKeyValueStore;

View file

@ -6,6 +6,9 @@
# create and upload backup and config file
# https://git.eworm.de/cgit/routeros-scripts/about/doc/upload-backup.md
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global BackupPassword;
:global BackupSendBinary;
:global BackupSendExport;