From bee2ccd36607cc8ec1f5091e041e75e1eeb8cca9 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 11 Mar 2021 18:58:00 +0100 Subject: dhcp-server: T2927: Add empty args if does not possible to determine variables (cherry-picked from commit 2f8b33a26e63e5b9ac4e697b9312f2238d6241f3) --- src/system/on-dhcp-event.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/system/on-dhcp-event.sh') diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh index 1ccc7acf2..b612ad599 100755 --- a/src/system/on-dhcp-event.sh +++ b/src/system/on-dhcp-event.sh @@ -22,21 +22,21 @@ domain=$5 file=/etc/hosts changes=0 -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 + grep -q " $client_search_expr " $file if [ $? == 0 ]; then echo host $client_fqdn_name already exists, exiting -- cgit v1.2.3