aboutsummaryrefslogtreecommitdiffstats
path: root/dhcp-to-dns.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-03-25 22:33:02 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-03-28 12:05:47 +0200
commitd700dbc00e6e22ea9521d3b359f0d3635d9af682 (patch)
tree5d43b7ef1080a480d5d910a80ac6ed2c321a4b44 /dhcp-to-dns.rsc
parent40f0d54ea89b701afbbc1cfa2ade8913c4d137eb (diff)
dhcp-to-dns: support host name from dhcp lease comment
The lease comment is supposed to be a human readable string... But we could allow parsable information.
Diffstat (limited to 'dhcp-to-dns.rsc')
-rw-r--r--dhcp-to-dns.rsc4
1 files changed, 3 insertions, 1 deletions
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc
index b925fdb..259a904 100644
--- a/dhcp-to-dns.rsc
+++ b/dhcp-to-dns.rsc
@@ -19,8 +19,10 @@
:global ServerNameInZone;
:global CharacterReplace;
+:global EitherOr;
:global IfThenElse;
:global LogPrintExit2;
+:global ParseKeyValueStore;
:global ScriptLock;
$ScriptLock $0 false 10;
@@ -62,7 +64,7 @@ $ScriptLock $0 false 10;
:if ([ :len ($LeaseVal->"address") ] > 0) do={
:local Comment ($CommentPrefix . $LeaseVal->"mac-address");
:local MacDash [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ];
- :local HostName [ $CharacterReplace ($LeaseVal->"host-name") " " "" ];
+ :local HostName [ $CharacterReplace [ $EitherOr ([ $ParseKeyValueStore ($LeaseVal->"comment") ]->"hostname") ($LeaseVal->"host-name") ] " " "" ];
:local Domain ([ $IfThenElse ($ServerNameInZone = true) ($LeaseVal->"server" . ".") ] . $Zone);
:local DnsRecord [ /ip/dns/static/find where name=($MacDash . "." . $Domain) ];