diff options
author | Jernej Jakob <jernej.jakob@gmail.com> | 2020-06-11 09:28:35 +0200 |
---|---|---|
committer | Jernej Jakob <jernej.jakob@gmail.com> | 2020-06-11 22:10:47 +0200 |
commit | 6fa9faa76c61fc17b78b600b715df0ed2761dd30 (patch) | |
tree | 1887ba56f566631f37199af2b9eca41ad7673ddd /src/system | |
parent | c1afb092815f5ea2bd8bacb8853195fa19103f2f (diff) | |
download | vyos-1x-6fa9faa76c61fc17b78b600b715df0ed2761dd30.tar.gz vyos-1x-6fa9faa76c61fc17b78b600b715df0ed2761dd30.zip |
on-dhcp-event.sh: T2486: modify for new vyos-hostsd syntax
- remove already existing entry check in /etc/hosts as vyos-hostsd will handle it
- vyos-hostsd-client syntax changed
- change tag "DHCP-$client_ip" to "dhcp-server-$client_ip" to make it more
distinct from dhcp client tag "dhcp-$intf"
Diffstat (limited to 'src/system')
-rwxr-xr-x | src/system/on-dhcp-event.sh | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh index 57f492401..a062dc810 100755 --- a/src/system/on-dhcp-event.sh +++ b/src/system/on-dhcp-event.sh @@ -19,7 +19,7 @@ client_name=$2 client_ip=$3 client_mac=$4 domain=$5 -file=/etc/hosts +hostsd_client="/usr/bin/vyos-hostsd-client" if [ -z "$client_name" ]; then logger -s -t on-dhcp-event "Client name was empty, using MAC \"$client_mac\" instead" @@ -36,26 +36,19 @@ fi case "$action" in commit) # add mapping for new lease - grep -q " $client_search_expr " $file - if [ $? == 0 ]; then - echo host $client_fqdn_name already exists, exiting - exit 1 - fi - # add host - /usr/bin/vyos-hostsd-client --add-hosts --tag "DHCP-$client_ip" --host "$client_fqdn_name,$client_ip" + $hostsd_client --add-hosts "$client_fqdn_name,$client_ip" --tag "dhcp-server-$client_ip" --apply + exit 0 ;; release) # delete mapping for released address - # delete host - /usr/bin/vyos-hostsd-client --delete-hosts --tag "DHCP-$client_ip" + $hostsd_client --delete-hosts --tag "dhcp-server-$client_ip" --apply + exit 0 ;; *) logger -s -t on-dhcp-event "Invalid command \"$1\"" - exit 1; + exit 1 ;; esac exit 0 - - |