Sha256: 69ad93ea089a106d0e1f3a55fb790b835dee1448a7a1172be3f15b87e3fc4e31

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module VagrantPlugins
  module GuestOpenBSD
    module Cap
      class ConfigureNetworks
        def self.configure_networks(machine, networks)
          # remove any hostname.em expect hostname.em0
          machine.communicate.sudo("[ -f /etc/hostname.em0 ] && mv /etc/hostname.em0 /tmp")
          machine.communicate.sudo("rm /etc/hostname.em* || :")
          machine.communicate.sudo("[ -f /tmp/hostname.em0 ] && mv /tmp/hostname.em0 /etc")

          networks.each do |network|
            case network[:type]
            when :static
              machine.communicate.sudo("su -m root -c 'echo inet #{network[:ip]} #{network[:netmask]}" +
                                  " > /etc/hostname.em#{network[:interface]}'")
              machine.communicate.sudo("sh /etc/netstart em#{network[:interface]}")
            when :dhcp
              machine.communicate.sudo("su -m root -c 'echo dhcp > /etc/hostname.em#{network[:interface]}'")
              machine.communicate.sudo("sh /etc/netstart em#{network[:interface]}")
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-guests-openbsd-0.0.3 lib/vagrant-guests-openbsd/cap/configure_networks.rb