From 7102d1e9b9c6b928bd4661849e9ab55fd5429e7c Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sun, 7 Sep 2014 19:10:48 +0100 Subject: vyatta-cfg-system: allow interfaces with dhcp addresses to be deleted Update the checks in scripts/vyatta-address to allow the deletetion of an interface that has a DHCP address. The patch put in place for Bug #259 (http://bugzilla.vyos.net/show_bug.cgi?id=259) checks that an interface exists before preceding with the delete, but this chokes when supplied with the address 'dhcp'. This patch checks if the supplied interface is a DHCP address, before extracting the IP address and then using that address for the check. Bug #305 http://bugzilla.vyos.net/show_bug.cgi?id=305 --- scripts/vyatta-address | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/vyatta-address b/scripts/vyatta-address index bc496996..3cc1755b 100755 --- a/scripts/vyatta-address +++ b/scripts/vyatta-address @@ -26,10 +26,19 @@ case $1 in fi ;; delete) - if ! /sbin/ip address show dev $2 2>/dev/null | grep -q "$3"; then + # Get current address from interface when using DHCP + if [[ "$3" = "dhcp" ]]; then + file=/var/lib/dhcp3/dhclient_"$2"_lease; + ip_address=$(sed -n "/new_ip_address='/ s/.*\='*//p" $file | sed -n "s/'//p"); + else + ip_address=$3; + fi + + if ! /sbin/ip address show dev $2 2>/dev/null | grep -q "$ip_address"; then # Address doesn't exist there, nothing to delete exit 0 fi + if [ ! -d "/sys/class/net/$2" ]; then # device is already gone exit 0 -- cgit v1.2.3