aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-07-15 11:45:35 +0200
committerGravatar Christian Hesse <mail@eworm.de>2021-07-15 11:45:35 +0200
commit9509371690c26bb67918448458f7b2989df4635c (patch)
tree18335e91e9d92396c022e58731ef5839759e6730
parent698c795eeeb76fb2911cbff0acb54c93bea2f846 (diff)
lease-script: use $ScriptLock
There were still ways to produce errors from lease scripts... Let's lock earlier, this should fix it.
-rw-r--r--lease-script19
1 files changed, 12 insertions, 7 deletions
diff --git a/lease-script b/lease-script
index 44360a4..3134cb6 100644
--- a/lease-script
+++ b/lease-script
@@ -13,6 +13,7 @@
:global IfThenElse;
:global LogPrintExit2;
:global ParseKeyValueStore;
+:global ScriptLock;
:if ([ :typeof $leaseActIP ] = "nothing" || \
[ :typeof $leaseActMAC ] = "nothing" || \
@@ -21,6 +22,12 @@
$LogPrintExit2 error $0 ("This script is supposed to run from ip dhcp-server.") true;
}
+$ScriptLock $0 false 10;
+
+:if ([ :len [ / system script job find where script=$0 ] ] > 1) do={
+ $LogPrintExit2 debug $0 ("More invocations are waiting, exiting early.") true;
+}
+
:local State ([ $IfThenElse ($leaseBound = 0) "de" "" ] . "assign");
:local RunOrder [ :toarray "" ];
@@ -41,12 +48,10 @@ $LogPrintExit2 debug $0 ("DHCP Server " . $leaseServerName . " " . \
}
:foreach Order,Script in=$RunOrder do={
- :if ([ :len [ / system script job find where script=$Script ] ] < 2) do={
- :do {
- $LogPrintExit2 debug $0 ("Running script with order " . $Order . ": " . $Script) false;
- / system script run $Script;
- } on-error={
- $LogPrintExit2 warning $0 ("Running script '" . $Script . "' failed!") false;
- }
+ :do {
+ $LogPrintExit2 debug $0 ("Running script with order " . $Order . ": " . $Script) false;
+ / system script run $Script;
+ } on-error={
+ $LogPrintExit2 warning $0 ("Running script '" . $Script . "' failed!") false;
}
}