summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-17 08:31:35 +0100
committerGitHub <noreply@github.com>2023-12-17 08:31:35 +0100
commit59ea01766d0da03d649e7c0be3f1fe33d0612450 (patch)
tree9528a8151a127e39c0314c892e6f3a425cb4f869
parent55e10e3b5962ccbc52400392c383c15417d46f35 (diff)
parent04e958c15364abd9ed6f82ee9453e8d72f04b547 (diff)
downloadvyos-1x-59ea01766d0da03d649e7c0be3f1fe33d0612450.tar.gz
vyos-1x-59ea01766d0da03d649e7c0be3f1fe33d0612450.zip
Merge pull request #2647 from indrajitr/kea-hook-fix
dhcp: T3316: Adjust dhcp-run script to align with kea hooks
-rwxr-xr-xsrc/system/on-dhcp-event.sh24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh
index 7b25bf338..03574bdc3 100755
--- a/src/system/on-dhcp-event.sh
+++ b/src/system/on-dhcp-event.sh
@@ -8,7 +8,7 @@
# Thanks to forum user "ruudboon" for multiple domain fix
# Thanks to forum user "chibby85" for expire patch and static-mapping
-if [ $# -lt 5 ]; then
+if [ $# -lt 1 ]; then
echo Invalid args
logger -s -t on-dhcp-event "Invalid args \"$@\""
exit 1
@@ -18,36 +18,30 @@ action=$1
client_name=$LEASE4_HOSTNAME
client_ip=$LEASE4_ADDRESS
client_mac=$LEASE4_HWADDR
-domain=$(echo "$client_name" | cut -d"." -f2-)
hostsd_client="/usr/bin/vyos-hostsd-client"
case "$action" in
- leases4_renew|lease4_recover) # add mapping for new lease
+ lease4_renew|lease4_recover) # add mapping for new/recovered lease address
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 : -)
+ client_name=$(echo "host-$client_mac" | tr : -)
fi
- if [ -z "$domain" ]; 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
+ $hostsd_client --add-hosts "$client_name,$client_ip" --tag "dhcp-server-$client_ip" --apply
exit 0
;;
- lease4_release|lease4_expire) # delete mapping for released address)
+ lease4_release|lease4_expire|lease4_decline) # delete mapping for released/declined address
$hostsd_client --delete-hosts --tag "dhcp-server-$client_ip" --apply
exit 0
;;
+ leases4_committed) # nothing to do
+ exit 0
+ ;;
+
*)
logger -s -t on-dhcp-event "Invalid command \"$1\""
exit 1
;;
esac
-
-exit 0