Sha256: a8580b052979080cd8219f78de7a4da8871d45deba5e454bc05ca10aa3fb4248
Contents?: true
Size: 1 KB
Versions: 10
Compression:
Stored size: 1 KB
Contents
require 'vagrant/util/guest_hosts' module VagrantPlugins module GuestOpenBSD module Cap class ChangeHostName extend Vagrant::Util::GuestHosts::BSD def self.change_host_name(machine, name) comm = machine.communicate if !comm.test("hostname -f | grep '^#{name}$'", sudo: false, shell: "sh") basename = name.split(".", 2)[0] command = <<-EOH.gsub(/^ {14}/, '') # Set the hostname hostname '#{name}' sed -i'' 's/^hostname=.*$/hostname=\"#{name}\"/' /etc/rc.conf echo '#{name}' > /etc/myname EOH comm.sudo(command, shell: "sh") end network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0] if network_with_hostname replace_host(comm, name, network_with_hostname[:ip]) else add_hostname_to_loopback_interface(comm, name) end end end end end end
Version data entries
10 entries across 10 versions & 3 rubygems