Skip to content

Commit d660557

Browse files
authored
Merge pull request #234 from BadgerOps/master
Fix host file management for Linux and Windows hosts
2 parents 06b75cd + 84d2f9e commit d660557

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/vagrant-hostmanager/hosts_file/updater.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def update_guest(machine)
4141

4242
if update_file(file, machine, false, line_endings)
4343
# upload modified file and remove temporary file
44-
machine.communicate.upload(file.to_s, '/tmp/hosts')
44+
machine.communicate.upload(file.to_s, "/tmp/hosts.#{machine.name}")
4545
if windir
46-
machine.communicate.sudo("mv -force /tmp/hosts/hosts.#{machine.name} #{realhostfile}")
46+
machine.communicate.sudo("mv -force /tmp/hosts.#{machine.name} #{realhostfile}")
4747
else
48-
machine.communicate.sudo("cat /tmp/hosts > #{realhostfile}")
48+
machine.communicate.sudo("cat /tmp/hosts.#{machine.name} > #{realhostfile} && rm /tmp/hosts.#{machine.name}")
4949
end
5050
end
5151

0 commit comments

Comments
 (0)