Merge pull request #5558 from legal90/fix-darwin-hostname

Fixed error in ChangeHostName capability for Darwin
This commit is contained in:
Seth Vargo 2015-05-30 12:05:11 -07:00
commit 7dd7e1718e
1 changed files with 3 additions and 1 deletions

View File

@ -6,7 +6,9 @@ module VagrantPlugins
if !machine.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'")
machine.communicate.sudo("scutil --set ComputerName #{name}")
machine.communicate.sudo("scutil --set HostName #{name}")
machine.communicate.sudo("scutil --set LocalHostName #{name}")
# LocalHostName shouldn't contain dots.
# It is used by Bonjour and visible through file sharing services.
machine.communicate.sudo("scutil --set LocalHostName #{name.gsub(/\.+/, '')}")
machine.communicate.sudo("hostname #{name}")
end
end