summaryrefslogtreecommitdiff
path: root/scripts/vyatta-address
diff options
context:
space:
mode:
authorAlex Harpin <development@landsofshadow.co.uk>2014-09-07 19:10:48 +0100
committerAlex Harpin <development@landsofshadow.co.uk>2014-09-07 19:10:48 +0100
commit7102d1e9b9c6b928bd4661849e9ab55fd5429e7c (patch)
tree95ce387f80bfd8c71af5b506cfc2783e8b8dc160 /scripts/vyatta-address
parentd095d3b8cc04b2eb52e3617c056fb0af40d8307d (diff)
downloadvyatta-cfg-system-7102d1e9b9c6b928bd4661849e9ab55fd5429e7c.tar.gz
vyatta-cfg-system-7102d1e9b9c6b928bd4661849e9ab55fd5429e7c.zip
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
Diffstat (limited to 'scripts/vyatta-address')
-rwxr-xr-xscripts/vyatta-address11
1 files changed, 10 insertions, 1 deletions
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