diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-03-11 18:58:00 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-03-11 19:00:59 +0100 |
commit | bee2ccd36607cc8ec1f5091e041e75e1eeb8cca9 (patch) | |
tree | 208ebe6bb6b91091592adbf44a25bbc38a5b5193 /src/system | |
parent | 1c286a3e0807f4c7f0ead3669ea9c78979702888 (diff) | |
download | vyos-1x-bee2ccd36607cc8ec1f5091e041e75e1eeb8cca9.tar.gz vyos-1x-bee2ccd36607cc8ec1f5091e041e75e1eeb8cca9.zip |
dhcp-server: T2927: Add empty args if does not possible to determine variables
(cherry-picked from commit 2f8b33a26e63e5b9ac4e697b9312f2238d6241f3)
Diffstat (limited to 'src/system')
-rwxr-xr-x | src/system/on-dhcp-event.sh | 26 |
1 files changed, 13 insertions, 13 deletions
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 |