Skip to content

Commit

Permalink
Merge pull request #41 from robcoward/master
Browse files Browse the repository at this point in the history
Added support for windows guests
  • Loading branch information
smdahlen committed Oct 4, 2013
2 parents 4e198ed + b935e40 commit 0b3b8ae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/vagrant-hostmanager/hosts_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ def update_guest(machine)

if (machine.communicate.test("uname -s | grep SunOS"))
realhostfile = '/etc/inet/hosts'
move_cmd = 'mv'
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)
update_file(file)

# 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)
Expand Down

0 comments on commit 0b3b8ae

Please sign in to comment.