aboutsummaryrefslogtreecommitdiffstats
path: root/lease-script
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-01-15 10:29:12 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-01-15 10:29:12 +0100
commit07973066c967a64aa3fc1a9a8472955a0fcc7569 (patch)
tree54e6cabb251b92f0e4590a2f3c8433522adb328b /lease-script
parenteb14820f2e1150965a670924350de461681cc8b4 (diff)
lease-script: split scripts for de/assign, add debug log
Diffstat (limited to 'lease-script')
-rw-r--r--lease-script22
1 files changed, 18 insertions, 4 deletions
diff --git a/lease-script b/lease-script
index c110201..d8d6562 100644
--- a/lease-script
+++ b/lease-script
@@ -3,18 +3,32 @@
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
#
# run scripts on DHCP lease
-# ( / ip dhcp-server set lease-script=lease-script [ find ] )
-:local Scripts {
+:local Scripts;
+:local ScriptsAssign {
"dhcp-to-dns";
"collect-wireless-mac.local";
"dhcp-lease-comment.local";
"collect-wireless-mac.capsman";
"dhcp-lease-comment.capsman"
}
+:local ScriptsDeAssign {
+ "dhcp-to-dns"
+}
+
+:local State "";
+:if ($leaseBound = 0) do={
+ :set State "de";
+ :set Scripts $ScriptsDeAssign;
+} else={
+ :set Scripts $ScriptsAssign;
+}
+
+:log debug ("DHCP Server " . $leaseServerName . " " . \
+ $State . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
-# delay a second to give time to update the lease table
-:delay 1s;
+# delay a moment to update the lease table, do not run in parallel for de/assign
+:delay ((1 + $leaseBound) . "s");
:foreach Script in=$Scripts do={
:if ([ / system script print count-only where name=$Script ] > 0) do={