Class: VagrantPlugins::GuestNetBSD::Cap::ChangeHostName

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-guest-netbsd/cap/change_host_name.rb

Class Method Summary collapse

Class Method Details

.change_host_name(machine, name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/vagrant-guest-netbsd/cap/change_host_name.rb', line 5

def self.change_host_name(machine, name)
  if !machine.communicate.test("hostname -s | grep '^#{name}$'")
    machine.communicate.sudo("sed -e 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf > /tmp/rc.conf.vagrant_changehostname_#{name}")
    machine.communicate.sudo("mv /tmp/rc.conf.vagrant_changehostname_#{name} /etc/rc.conf")
    machine.communicate.sudo("hostname #{name}")
  end
end