Module: Vagrant::Util::GuestHosts::Linux
- Includes:
- Unix
- Defined in:
- lib/vagrant/util/guest_hosts.rb
Overview
Linux specific inspection helpers
Constant Summary
Constants included from Unix
Unix::DEAFAULT_LOOPBACK_CHECK_LIMIT
Instance Method Summary collapse
-
#replace_host(comm, name, ip) ⇒ Object
Remove any line in /etc/hosts that contains hostname, then add hostname with associated ip.
Methods included from Unix
#add_hostname_to_loopback_interface
Instance Method Details
#replace_host(comm, name, ip) ⇒ Object
Remove any line in /etc/hosts that contains hostname, then add hostname with associated ip
43 44 45 46 47 48 49 |
# File 'lib/vagrant/util/guest_hosts.rb', line 43 def replace_host(comm, name, ip) basename = name.split(".", 2)[0] comm.sudo <<-EOH.gsub(/^ {14}/, '') sed -i '/#{name}/d' /etc/hosts sed -i'' '1i '#{ip}'\\t#{name}\\t#{basename}' /etc/hosts EOH end |