aboutsummaryrefslogtreecommitdiffstats
path: root/lease-script
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-07-01 18:07:23 +0200
committerGravatar Christian Hesse <mail@eworm.de>2021-07-01 22:52:38 +0200
commit9c9fb46e4a95a7020b1fefb8fb0db3aafa9b2844 (patch)
tree645083f132195de4dcf244c9a23985e85ac1f70a /lease-script
parent5f2bc87b2244382fdff968df9e643722fcf26a68 (diff)
lease-script: do not run too many instances of scripts
Every instance of the scripts does all the work. If one script is running and a second script is waiting we do not have to start a third one.
Diffstat (limited to 'lease-script')
-rw-r--r--lease-script12
1 files changed, 7 insertions, 5 deletions
diff --git a/lease-script b/lease-script
index 537c832..2f67cb0 100644
--- a/lease-script
+++ b/lease-script
@@ -27,10 +27,12 @@ $LogPrintExit2 debug $0 ("DHCP Server " . $leaseServerName . " " . \
:foreach Script in=[ / system script find where source~("\n# provides: lease-script " . $State . "\n") ] do={
:local ScriptName [ / system script get $Script name ];
- :do {
- $LogPrintExit2 debug $0 ("Running script: " . $ScriptName) false;
- / system script run $Script;
- } on-error={
- $LogPrintExit2 warning $0 ("Running script '" . $ScriptName . "' failed!") false;
+ :if ([ :len [ / system script job find where script=$ScriptName ] ] < 2) do={
+ :do {
+ $LogPrintExit2 debug $0 ("Running script: " . $ScriptName) false;
+ / system script run $Script;
+ } on-error={
+ $LogPrintExit2 warning $0 ("Running script '" . $ScriptName . "' failed!") false;
+ }
}
}