Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support :public_network and writable issue #47

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/vagrant-hostsupdater/HostsUpdater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def getIps
ips = []
@machine.config.vm.networks.each do |network|
key, options = network[0], network[1]
ip = options[:ip] if key == :private_network
ip = options[:ip] if key == :private_network || key == :public_network
ips.push(ip) if ip
end
return ips
Expand Down Expand Up @@ -75,7 +75,7 @@ def getHostEntries(ip, hostnames, name, uuid = self.uuid)
def addToHosts(entries)
return if entries.length == 0
content = entries.join("\n").strip
if !File.writable?(@@hosts_path)
if !File.writable_real?(@@hosts_path)
sudo(%Q(sh -c 'echo "#{content}" >> #@@hosts_path'))
else
content = "\n" + content
Expand All @@ -88,7 +88,7 @@ def addToHosts(entries)
def removeFromHosts(options = {})
uuid = @machine.id || @machine.config.hostsupdater.id
hashedId = Digest::MD5.hexdigest(uuid)
if !File.writable?(@@hosts_path)
if !File.writable_real?(@@hosts_path)
sudo(%Q(sed -i -e '/#{hashedId}/ d' #@@hosts_path))
else
hosts = ""
Expand Down