Check if interface exists before shutting it down
This commit is contained in:
parent
81b7d1524b
commit
b24d4252c5
@ -45,7 +45,7 @@ module VagrantPlugins
|
||||
# each specifically, we avoid reconfiguring eth0 (the NAT interface) so
|
||||
# SSH never dies.
|
||||
interfaces.each do |interface|
|
||||
comm.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
|
||||
comm.sudo("if [[ $(/sbin/ip a show eth#{interface} | grep UP) ]]; then /sbin/ifdown eth#{interface} 2> /dev/null; fi")
|
||||
comm.sudo("/sbin/ip addr flush dev eth#{interface} 2> /dev/null")
|
||||
end
|
||||
|
||||
|
||||
@ -23,9 +23,9 @@ describe 'VagrantPlugins::GuestAlpine::Cap::ConfigureNetworks' do
|
||||
|
||||
expect(communicator).to receive(:sudo).with("sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre")
|
||||
expect(communicator).to receive(:sudo).with("sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tail -n +2 > /tmp/vagrant-network-interfaces.post")
|
||||
expect(communicator).to receive(:sudo).with('/sbin/ifdown eth0 2> /dev/null')
|
||||
expect(communicator).to receive(:sudo).with(/\/sbin\/ifdown eth0/)
|
||||
expect(communicator).to receive(:sudo).with('/sbin/ip addr flush dev eth0 2> /dev/null')
|
||||
expect(communicator).to receive(:sudo).with('/sbin/ifdown eth1 2> /dev/null')
|
||||
expect(communicator).to receive(:sudo).with(/\/sbin\/ifdown eth1/)
|
||||
expect(communicator).to receive(:sudo).with('/sbin/ip addr flush dev eth1 2> /dev/null')
|
||||
expect(communicator).to receive(:sudo).with('cat /tmp/vagrant-network-interfaces.pre /tmp/vagrant-network-entry /tmp/vagrant-network-interfaces.post > /etc/network/interfaces')
|
||||
expect(communicator).to receive(:sudo).with('rm -f /tmp/vagrant-network-interfaces.pre /tmp/vagrant-network-entry /tmp/vagrant-network-interfaces.post')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user