Sha256: e5445aa49ec2ec1f7e27312c3e1d76c4f0d520de6abb033da5beba1661c2e52d

Contents?: true

Size: 1.69 KB

Versions: 15

Compression:

Stored size: 1.69 KB

Contents

require 'set'
require 'tempfile'

module Vagrant
  module Guest
    class Arch < Linux
      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

      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])
          entries << TemplateRenderer.render("guests/arch/network_#{network[:type]}",
                                             :options => network)
        end

        # Perform the careful dance necessary to reconfigure
        # the network interfaces
        temp = Tempfile.new("vagrant")
        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
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
vagrantup-0.9.7 lib/vagrant/guest/arch.rb
vagrantup-0.9.6 lib/vagrant/guest/arch.rb
vagrantup-0.9.5 lib/vagrant/guest/arch.rb
vagrantup-0.9.4 lib/vagrant/guest/arch.rb
vagrantup-0.9.3 lib/vagrant/guest/arch.rb
vagrantup-0.9.2 lib/vagrant/guest/arch.rb
vagrantup-0.9.1 lib/vagrant/guest/arch.rb
vagrantup-0.9.0 lib/vagrant/guest/arch.rb
vagrant-0.9.7 lib/vagrant/guest/arch.rb
vagrant-0.9.5 lib/vagrant/guest/arch.rb
vagrant-0.9.4 lib/vagrant/guest/arch.rb
vagrant-0.9.3 lib/vagrant/guest/arch.rb
vagrant-0.9.2 lib/vagrant/guest/arch.rb
vagrant-0.9.1 lib/vagrant/guest/arch.rb
vagrant-0.9.0 lib/vagrant/guest/arch.rb