Fix up the debian guest to work with the new machine API
This commit is contained in:
parent
1efee6edcb
commit
f193d69fbc
|
@ -15,9 +15,9 @@ module VagrantPlugins
|
|||
def configure_networks(networks)
|
||||
# First, remove any previous network modifications
|
||||
# from the interface file.
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
||||
vm.channel.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||
vm.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
||||
vm.communicate.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
||||
vm.communicate.sudo("rm /tmp/vagrant-network-interfaces")
|
||||
|
||||
# Accumulate the configurations to add to the interfaces file as
|
||||
# well as what interfaces we're actually configuring since we use that
|
||||
|
@ -39,30 +39,32 @@ module VagrantPlugins
|
|||
temp.write(entries.join("\n"))
|
||||
temp.close
|
||||
|
||||
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")
|
||||
vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry")
|
||||
|
||||
# Bring down all the interfaces we're reconfiguring. By bringing down
|
||||
# each specifically, we avoid reconfiguring eth0 (the NAT interface) so
|
||||
# SSH never dies.
|
||||
interfaces.each do |interface|
|
||||
vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
|
||||
vm.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
|
||||
end
|
||||
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
|
||||
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||
vm.communicate.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
|
||||
vm.communicate.sudo("rm /tmp/vagrant-network-entry")
|
||||
|
||||
# Bring back up each network interface, reconfigured
|
||||
interfaces.each do |interface|
|
||||
vm.channel.sudo("/sbin/ifup eth#{interface}")
|
||||
vm.communicate.sudo("/sbin/ifup eth#{interface}")
|
||||
end
|
||||
end
|
||||
|
||||
def change_host_name(name)
|
||||
if !vm.channel.test("hostname --fqdn | grep '^#{name}$' || hostname --short | grep '^#{name}$'")
|
||||
vm.channel.sudo("sed -r -i 's/^(127[.]0[.]1[.]1[[:space:]]+).*$/\\1#{name} #{name.split('.')[0]}/' /etc/hosts")
|
||||
vm.channel.sudo("sed -i 's/.*$/#{name.split('.')[0]}/' /etc/hostname")
|
||||
vm.channel.sudo("hostname -F /etc/hostname")
|
||||
vm.channel.sudo("hostname --fqdn > /etc/mailname")
|
||||
vm.communicate.tap do |comm|
|
||||
if !comm.test("hostname --fqdn | grep '^#{name}$' || hostname --short | grep '^#{name}$'")
|
||||
comm.sudo("sed -r -i 's/^(127[.]0[.]1[.]1[[:space:]]+).*$/\\1#{name} #{name.split('.')[0]}/' /etc/hosts")
|
||||
comm.sudo("sed -i 's/.*$/#{name.split('.')[0]}/' /etc/hostname")
|
||||
comm.sudo("hostname -F /etc/hostname")
|
||||
comm.sudo("hostname --fqdn > /etc/mailname")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue