Class: Vagrant::Guest::Arch

Inherits:
Linux show all
Includes:
Util
Defined in:
lib/vagrant/guest/arch.rb

Instance Attribute Summary

Attributes inherited from Base

#vm

Instance Method Summary collapse

Methods inherited from Linux

#distro_dispatch, #halt, #initialize, #mount_nfs, #mount_shared_folder

Methods inherited from Base

#distro_dispatch, #halt, #initialize, #mount_nfs, #mount_shared_folder

Constructor Details

This class inherits a constructor from Vagrant::Guest::Linux

Instance Method Details

#change_host_name(name) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/vagrant/guest/arch.rb', line 12

def change_host_name(name)
  # Only do this if the hostname is not already set
  if !vm.channel.test("sudo hostname | grep '#{name}'")
    vm.channel.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/rc.conf")
    vm.channel.sudo("hostname #{name}")
    vm.channel.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} @' /etc/hosts")
  end
end

#configure_networks(networks) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vagrant/guest/arch.rb', line 21

def configure_networks(networks)
  # Remove previous Vagrant-managed network interfaces
  vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
  vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/rc.conf")

  # Configure the network interfaces
  interfaces = Set.new
  entries = []
  networks.each do |network|
    interfaces.add(network[:interface])
    entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}",
                                    :options => network)

    entries << entry
  end

  # Perform the careful dance necessary to reconfigure
  # the network interfaces
  temp = Tempfile.new("vagrant")
  temp.binmode
  temp.write(entries.join("\n"))
  temp.close

  vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")

  # Reconfigure the network interfaces
  vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/rc.conf")
  vm.channel.sudo("/etc/rc.d/network restart")

  interfaces.each do |interface|
    vm.channel.sudo("dhcpcd -k eth#{interface} && dhcpcd eth#{interface} && sleep 3")
  end
end