From 286e9cd01ee6422e9631ac9a3293d6a3a561e658 Mon Sep 17 00:00:00 2001 From: Johannes Plunien Date: Sun, 21 Sep 2014 19:14:57 +0200 Subject: [PATCH] Set ComputerName and LocalHostName on darwin guests This sets the bonjour host name for darwin guests to the same value as config.vm.hostname. It also sets the user-friendly name for the system. --- plugins/guests/darwin/cap/change_host_name.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb index 80df9870d..ad7242c91 100644 --- a/plugins/guests/darwin/cap/change_host_name.rb +++ b/plugins/guests/darwin/cap/change_host_name.rb @@ -4,7 +4,9 @@ module VagrantPlugins 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 ComputerName #{name}") machine.communicate.sudo("scutil --set HostName #{name}") + machine.communicate.sudo("scutil --set LocalHostName #{name}") machine.communicate.sudo("hostname #{name}") end end