2013-07-11 01:21:06 +00:00
|
|
|
module VagrantPlugins
|
2013-08-01 01:07:04 +00:00
|
|
|
module GuestDarwin
|
2013-07-11 01:21:06 +00:00
|
|
|
module Cap
|
|
|
|
class ChangeHostName
|
|
|
|
def self.change_host_name(machine, name)
|
|
|
|
if !machine.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'")
|
2014-09-21 17:14:57 +00:00
|
|
|
machine.communicate.sudo("scutil --set ComputerName #{name}")
|
2013-07-11 01:21:06 +00:00
|
|
|
machine.communicate.sudo("scutil --set HostName #{name}")
|
2015-04-04 13:26:38 +00:00
|
|
|
# LocalHostName shouldn't contain dots.
|
|
|
|
# It is used by Bonjour and visible through file sharing services.
|
|
|
|
machine.communicate.sudo("scutil --set LocalHostName #{name.gsub(/\.+/, '')}")
|
2013-07-11 01:21:06 +00:00
|
|
|
machine.communicate.sudo("hostname #{name}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|