Sha256: de527919e51959d4f4eafb42951df831de584530b6d2162f45021efac36b5b26

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

require "tempfile"

require "vagrant/util/template_renderer"

module VagrantPlugins
  module GuestFreeBSD
    module Cap
      class ChangeHostName
        include Vagrant::Util

        def self.configure_networks(machine, networks)
          machine.communicate.tap do |comm|
            # Remove any previous host only network additions to the interface file
            comm.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
            comm.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
            comm.sudo("rm /tmp/vagrant-network-interfaces")

            # 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

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

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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/guests/gentoo/cap/configure_networks.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/guests/gentoo/cap/configure_networks.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/guests/gentoo/cap/configure_networks.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/guests/gentoo/cap/configure_networks.rb
tnargav-1.2.2 plugins/guests/gentoo/cap/configure_networks.rb