mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
lease-script: split scripts for de/assign, add debug log
This commit is contained in:
parent
eb14820f2e
commit
07973066c9
1 changed files with 18 additions and 4 deletions
22
lease-script
22
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"
|
||||
}
|
||||
|
||||
# delay a second to give time to update the lease table
|
||||
:delay 1s;
|
||||
: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 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={
|
||||
|
|
Loading…
Reference in a new issue