blob: d8d65624fb0fbdfa77e4cfbd9208025d7af6fea5 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!rsc
# RouterOS script: lease-script
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
#
# run scripts on DHCP lease
: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 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={
:log debug ("Running script from lease-script: " . $Script);
/ system script run $Script;
}
}
|