Module: VagrantPlugins::Hostentries::GuestCapability::Linux::UpdateHostsEntry

Defined in:
lib/vagrant-hostentries/guest_capability/linux/update_hosts_entry.rb

Class Method Summary collapse

Class Method Details

.update_hosts_entry(machine, ip, name) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/vagrant-hostentries/guest_capability/linux/update_hosts_entry.rb', line 6

def self.update_hosts_entry(machine, ip, name)
	machine.communicate.tap do |comm|
		comm.sudo("cat /etc/hosts | grep -v '#{name} \#VAGRANTHOSTS$' >>/etc/hosts.tmp")
		comm.sudo("mv /etc/hosts.tmp /etc/hosts")
		comm.sudo("echo '#{ip}    #{name} \#VAGRANTHOSTS' >>/etc/hosts")
	end
end