vagrant/plugins/guests/darwin/cap/change_host_name.rb

15 lines
422 B
Ruby
Raw Normal View History

module VagrantPlugins
module GuestDarwin
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
if !machine.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'")
machine.communicate.sudo("scutil --set HostName #{name}")
machine.communicate.sudo("hostname #{name}")
end
end
end
end
end
end