From 8ef90f5e6cfa6a2f7916bef7871364691c9127f3 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 20 May 2019 17:24:02 +0200 Subject: [interfaces] T1387: Fix removal of DHCP interface w/o assigned address If a DHCP interface fails to get an IP address, deleting the interface results in a bash script error. --- scripts/vyatta-address | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/vyatta-address b/scripts/vyatta-address index 0727911e..ed9a298e 100755 --- a/scripts/vyatta-address +++ b/scripts/vyatta-address @@ -32,13 +32,16 @@ case $1 in ip=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p'); #ip_address=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p'); # T1053 we need IP/prefix for normalize-ip to function - ip_address=$(ip a s dev $2 | grep $ip | awk '{print $2}') + ip_address=$(ip a s dev $2 | grep "inet $ip" | awk '{print $2}') elif [[ "$3" = "dhcpv6" ]]; then lease_file=/var/lib/dhcp/dhclient_v6_"$(echo $2 | sed -e 's/\./_/')".leases; ip_address=$(sed -n 's/^\s\s\s\siaaddr\s\(.*\)\s{/\1/p' $lease_file | sed -n '$p'); else ip_address=$3; fi + if [[ "$ip_address" = "" ]]; then + ip_address='0.0.0.0/0' + fi ### T1053 parameter $ip_address needs to be prefixed, not just the IP ip_address=$(/usr/libexec/vyos/system/normalize-ip $ip_address) -- cgit v1.2.3