Sha256: 5cfa4faabb7dc1721af58d8bb07caa50a337d2744899d4343fbb61595ea697ce

Contents?: true

Size: 1.81 KB

Versions: 56

Compression:

Stored size: 1.81 KB

Contents

require "tempfile"

require_relative "../../../../lib/vagrant/util/template_renderer"

module VagrantPlugins
  module GuestFuntoo
    module Cap
      class ConfigureNetworks
        include Vagrant::Util

        def self.configure_networks(machine, networks)
          machine.communicate.tap do |comm|
            # Configure each network interface
            networks.each do |network|
              # http://www.funtoo.org/Funtoo_Linux_Networking
              # dhcpcd generally runs on all interfaces by default
              # in the future we can change this, dhcpcd has lots of features
              # it would be nice to expose more of its capabilities...
              if not /dhcp/i.match(network[:type])
                line = "denyinterfaces eth#{network[:interface]}"
                cmd = "grep '#{line}' /etc/dhcpcd.conf; if [ $? -ne 0 ]; then echo '#{line}' >> /etc/dhcpcd.conf ;  fi"
                comm.sudo(cmd)
                ifFile = "netif.eth#{network[:interface]}"
                entry = TemplateRenderer.render("guests/funtoo/network_#{network[:type]}",
                                                 options: network)

                # Upload the entry to a temporary location
                Tempfile.open("vagrant-funtoo-configure-networks") do |f|
                  f.binmode
                  f.write(entry)
                  f.fsync
                  f.close
                  comm.upload(f.path, "/tmp/vagrant-#{ifFile}")
                end

                comm.sudo("cp /tmp/vagrant-#{ifFile} /etc/conf.d/#{ifFile}")
                comm.sudo("chmod 0644 /etc/conf.d/#{ifFile}")
                comm.sudo("ln -fs /etc/init.d/netif.tmpl /etc/init.d/#{ifFile}")
                comm.sudo("/etc/init.d/#{ifFile} start")
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

56 entries across 52 versions & 6 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/guests/funtoo/cap/configure_networks.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.3.3.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.3.2.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.19.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.18.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.16.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.14.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.10.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.9.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.8.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.7.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.6.2 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.6.1 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.6.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.5.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.4.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.3.0 plugins/guests/funtoo/cap/configure_networks.rb
vagrant-unbundled-2.2.2.0 plugins/guests/funtoo/cap/configure_networks.rb