aboutsummaryrefslogtreecommitdiffstats
path: root/lease-script.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'lease-script.rsc')
-rw-r--r--lease-script.rsc26
1 files changed, 13 insertions, 13 deletions
diff --git a/lease-script.rsc b/lease-script.rsc
index 995c7e4..ab44956 100644
--- a/lease-script.rsc
+++ b/lease-script.rsc
@@ -1,18 +1,18 @@
#!rsc by RouterOS
# RouterOS script: lease-script
-# Copyright (c) 2013-2024 Christian Hesse <mail@eworm.de>
-# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
+# Copyright (c) 2013-2025 Christian Hesse <mail@eworm.de>
+# https://rsc.eworm.de/COPYING.md
#
-# requires RouterOS, version=7.14
+# requires RouterOS, version=7.15
#
# 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; }
+# https://rsc.eworm.de/doc/lease-script.md
:local ExitOK false;
-:do {
+:onerror Err {
+ :global GlobalConfigReady; :global GlobalFunctionsReady;
+ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
+ do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global Grep;
@@ -53,13 +53,13 @@
}
:foreach Order,Script in=$RunOrder do={
- :do {
+ :onerror Err {
$LogPrint debug $ScriptName ("Running script with order " . $Order . ": " . $Script);
/system/script/run $Script;
- } on-error={
- $LogPrint warning $ScriptName ("Running script '" . $Script . "' failed!");
+ } do={
+ $LogPrint warning $ScriptName ("Running script '" . $Script . "' failed: " . $Err);
}
}
-} on-error={
- :global ExitError; $ExitError $ExitOK [ :jobname ];
+} do={
+ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
}