diff options
author | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2021-02-23 17:38:05 +0000 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-09-19 12:36:08 +0200 |
commit | 404b4c7b7b4f3063bc2bb608a32833d6cf23d834 (patch) | |
tree | cdcca33cde32dee508f775b6ca764e81e01a17c5 /src/system/on-dhcp-event.sh | |
parent | b72fff14c4061e26657835d72e0944229a196940 (diff) | |
download | vyos-1x-404b4c7b7b4f3063bc2bb608a32833d6cf23d834.tar.gz vyos-1x-404b4c7b7b4f3063bc2bb608a32833d6cf23d834.zip |
dhcp-server: T2927: Add empty args if does not possible to determine variables
(cherry picked from commit 2f8b33a26e63e5b9ac4e697b9312f2238d6241f3)
Diffstat (limited to 'src/system/on-dhcp-event.sh')
-rwxr-xr-x | src/system/on-dhcp-event.sh | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh index a062dc810..49e53d7e1 100755 --- a/src/system/on-dhcp-event.sh +++ b/src/system/on-dhcp-event.sh @@ -21,21 +21,20 @@ client_mac=$4 domain=$5 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" - client_name=$(echo "client-"$client_mac | tr : -) -fi - -if [ "$domain" == "..YYZ!" ]; then - client_fqdn_name=$client_name - client_search_expr=$client_name -else - client_fqdn_name=$client_name.$domain - client_search_expr="$client_name\\.$domain" -fi - case "$action" in commit) # add mapping for new lease + if [ -z "$client_name" ]; then + logger -s -t on-dhcp-event "Client name was empty, using MAC \"$client_mac\" instead" + client_name=$(echo "client-"$client_mac | tr : -) + fi + + if [ "$domain" == "..YYZ!" ]; then + client_fqdn_name=$client_name + client_search_expr=$client_name + else + client_fqdn_name=$client_name.$domain + client_search_expr="$client_name\\.$domain" + fi $hostsd_client --add-hosts "$client_fqdn_name,$client_ip" --tag "dhcp-server-$client_ip" --apply exit 0 ;; |