From c555a98de3d825530e97c80aba04f68d71072ceb Mon Sep 17 00:00:00 2001 From: Rob Coward Date: Thu, 3 Oct 2013 14:16:53 +0100 Subject: [PATCH 1/2] Added support for windows guests --- lib/vagrant-hostmanager/hosts_file.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index f367c04..dd2c6c3 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -8,8 +8,13 @@ module VagrantPlugins if (machine.communicate.test("uname -s | grep SunOS")) realhostfile = '/etc/inet/hosts' + move_cmd = 'mv' + elsif (machine.communicate.test("uname -s | grep MINGW32_NT")) + realhostfile = 'C:\Windows\System32\Drivers\etc\hosts' + move_cmd = 'mv -force' else realhostfile = '/etc/hosts' + move_cmd = 'mv' end # download and modify file with Vagrant-managed entries @@ -19,7 +24,7 @@ module VagrantPlugins # upload modified file and remove temporary file machine.communicate.upload(file, '/tmp/hosts') - machine.communicate.sudo("mv /tmp/hosts #{realhostfile}") + machine.communicate.sudo("#{move_cmd} /tmp/hosts #{realhostfile}") # i have no idea if this is a windows competibility issue or not, but sometimes it dosen't work on my machine begin FileUtils.rm(file) From b935e4002fd518f6a86ea7665d1085549694156b Mon Sep 17 00:00:00 2001 From: Rob Coward Date: Thu, 3 Oct 2013 14:51:49 +0100 Subject: [PATCH 2/2] Changed test for windows guest to use the same as the vagrant-windows plugin --- lib/vagrant-hostmanager/hosts_file.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index dd2c6c3..5735ded 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -9,14 +9,13 @@ module VagrantPlugins if (machine.communicate.test("uname -s | grep SunOS")) realhostfile = '/etc/inet/hosts' move_cmd = 'mv' - elsif (machine.communicate.test("uname -s | grep MINGW32_NT")) + elsif (machine.communicate.test("test -d $Env:SystemRoot")) realhostfile = 'C:\Windows\System32\Drivers\etc\hosts' move_cmd = 'mv -force' else realhostfile = '/etc/hosts' move_cmd = 'mv' end - # download and modify file with Vagrant-managed entries file = @global_env.tmp_path.join("hosts.#{machine.name}") machine.communicate.download(realhostfile, file)