diff options
author | Christian Hesse <mail@eworm.de> | 2020-07-16 21:27:44 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-07-16 21:46:20 +0200 |
commit | e709af4c4d824560999c9bbd36f7e3504c28e9f6 (patch) | |
tree | 20a671502599e32348814b631358c880dc29735c | |
parent | 6dfd8ed41a18a10dd6c640bb0dfc37f1a561ee8c (diff) |
dhcp-to-dns: use $IfThenElse
-rw-r--r-- | dhcp-to-dns | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/dhcp-to-dns b/dhcp-to-dns index 4496854..352b53f 100644 --- a/dhcp-to-dns +++ b/dhcp-to-dns @@ -12,15 +12,12 @@ :global PrefixInZone; :global CharacterReplace; +:global IfThenElse; :global LogPrintExit; -:local Zone $Domain; -:if ($HostNameInZone = true) do={ - :set Zone ($Identity . "." . $Zone); -} -:if ($PrefixInZone = true) do={ - :set Zone ("dhcp." . $Zone); -} +:local Zone \ + ([ $IfThenElse ($PrefixInZone = true) "dhcp." ] . \ + [ $IfThenElse ($HostNameInZone = true) ($Identity . ".") ] . $Domain); :local Ttl 5m; :local CommentPrefix "managed by dhcp-to-dns for "; @@ -45,10 +42,9 @@ :foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={ :local LeaseVal [ / ip dhcp-server lease get $Lease ]; :local Comment ($CommentPrefix . $LeaseVal->"mac-address"); - :local HostName [ $CharacterReplace ($LeaseVal->"host-name") " " "" ]; - :if ($HostName = "") do={ - :set HostName [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ]; - } + :local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \ + [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \ + [ $CharacterReplace ($LeaseVal->"host-name") " " "" ] ]; :local Fqdn ($HostName . "." . $Zone); :local DnsRecord [ / ip dns static find where name=$Fqdn ]; |