Class: Vagrant::Guest::Gentoo

Inherits:
Linux show all
Includes:
Util
Defined in:
lib/vagrant/guest/gentoo.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



37
38
39
40
41
42
43
# File 'lib/vagrant/guest/gentoo.rb', line 37

def change_host_name(name)
  if !vm.channel.test("sudo hostname --fqdn | grep '#{name}'")
    vm.channel.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
    vm.channel.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
    vm.channel.sudo("hostname #{name.split('.')[0]}")
  end
end

#configure_networks(networks) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vagrant/guest/gentoo.rb', line 11

def configure_networks(networks)
  # Remove any previous host only network additions to the interface file
  vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
  vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")

  # Configure each network interface
  networks.each do |network|
    entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
                                    :options => network)

    # Upload the entry to a temporary location
    temp = Tempfile.new("vagrant")
    temp.binmode
    temp.write(entry)
    temp.close

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

    # Configure the interface
    vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
    vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
    vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
    vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start")
  end
end