Fix Fedora /etc/hosts bug

Update so that localhost entries don't get deleted when the hostname
gets added to the 127.0.0.1 line. Closes #6202
This commit is contained in:
Dusty Mabe 2015-08-27 16:44:17 -04:00
parent c84e05fd06
commit be90f6b1da
1 changed files with 2 additions and 2 deletions

View File

@ -48,7 +48,7 @@ module VagrantPlugins
def update_etc_hosts
ip_address = '([0-9]{1,3}\.){3}[0-9]{1,3}'
search = "^(#{ip_address})\\s+#{Regexp.escape(current_hostname)}(\\s.*)?$"
replace = "\\1 #{fqdn} #{short_hostname}"
replace = "\\1 #{fqdn} #{short_hostname} \\3"
expression = ['s', search, replace, 'g'].join('@')
sudo("sed -ri '#{expression}' /etc/hosts")