summaryrefslogtreecommitdiff
path: root/src/system/on-dhcp-event.sh
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2020-06-22 13:24:30 +0700
committerGitHub <noreply@github.com>2020-06-22 13:24:30 +0700
commit1d09b1a788cc91ff64134d853f063dc0a364ad50 (patch)
tree1dca2298b55d26ba24347a14dfc5a837d92aefff /src/system/on-dhcp-event.sh
parenta8041aa4a9e70c267c17451c14c7dcf9ca887023 (diff)
parent0ccdf15c0acb0be128fa2346b72cfdd8ce16b694 (diff)
downloadvyos-1x-1d09b1a788cc91ff64134d853f063dc0a364ad50.tar.gz
vyos-1x-1d09b1a788cc91ff64134d853f063dc0a364ad50.zip
Merge pull request #452 from jjakob/T2486-dns-hostsd-fixes
T2486: DNS, vyos-hostsd fixes
Diffstat (limited to 'src/system/on-dhcp-event.sh')
-rwxr-xr-xsrc/system/on-dhcp-event.sh19
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
-
-