summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-05-20 17:24:02 +0200
committerDaniil Baturin <daniil@baturin.org>2019-05-26 15:24:22 +0200
commit8ef90f5e6cfa6a2f7916bef7871364691c9127f3 (patch)
tree7786e2b580f3f24babd04320398aac862e58654c
parentaf29b29fca4a343945ef2c674aeaa34491f43c3e (diff)
downloadvyatta-cfg-system-8ef90f5e6cfa6a2f7916bef7871364691c9127f3.tar.gz
vyatta-cfg-system-8ef90f5e6cfa6a2f7916bef7871364691c9127f3.zip
[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.
-rwxr-xr-xscripts/vyatta-address5
1 files changed, 4 insertions, 1 deletions
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)