Skip to content

Commit 0505771

Browse files
committed
Do not return an error if ifdown fails
Ubuntu versions prior to 16.04 always returned a successful exit status, even if one tried to down an interface that does not exist. This behavior changed in Ubuntu 16.04 to return an error. This commit preserves the old behavior. Fixes GH-7155
1 parent fa19783 commit 0505771

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

plugins/guests/debian/cap/configure_networks.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def self.configure_networks(machine, networks)
4242
# each specifically, we avoid reconfiguring eth0 (the NAT interface) so
4343
# SSH never dies.
4444
interfaces.each do |interface|
45-
comm.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
45+
# Ubuntu 16.04+ returns an error when downing an interface that
46+
# does not exist. The `|| true` preserves the behavior that older
47+
# Ubuntu versions exhibit and Vagrant expects (GH-7155)
48+
comm.sudo("/sbin/ifdown eth#{interface} 2> /dev/null || true")
4649
comm.sudo("/sbin/ip addr flush dev eth#{interface} 2> /dev/null")
4750
end
4851

0 commit comments

Comments
 (0)