diff --git a/plugins/guests/arch/cap/change_host_name.rb b/plugins/guests/arch/cap/change_host_name.rb index 39bc5e586..6717f342e 100644 --- a/plugins/guests/arch/cap/change_host_name.rb +++ b/plugins/guests/arch/cap/change_host_name.rb @@ -8,9 +8,6 @@ module VagrantPlugins if !comm.test("hostname -f | grep '^#{name}$'", sudo: false) basename = name.split(".", 2)[0] comm.sudo <<-EOH.gsub(/^ {14}/, "") - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Set hostname hostnamectl set-hostname '#{basename}' diff --git a/plugins/guests/atomic/cap/change_host_name.rb b/plugins/guests/atomic/cap/change_host_name.rb index 1833cf32a..40a74a3e7 100644 --- a/plugins/guests/atomic/cap/change_host_name.rb +++ b/plugins/guests/atomic/cap/change_host_name.rb @@ -8,9 +8,6 @@ module VagrantPlugins if !comm.test("hostname -f | grep '^#{name}$'", sudo: false) basename = name.split(".", 2)[0] comm.sudo <<-EOH.gsub(/^ {14}/, "") - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Set hostname hostnamectl set-hostname '#{basename}' diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb index 03bc70840..9bb37cc0d 100644 --- a/plugins/guests/darwin/cap/change_host_name.rb +++ b/plugins/guests/darwin/cap/change_host_name.rb @@ -22,10 +22,6 @@ module VagrantPlugins hostname '#{name}' - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' /etc/hosts - sed -i'' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts - sed on bsd is sad grep -w '#{name}' /etc/hosts || { echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts && diff --git a/plugins/guests/debian/cap/change_host_name.rb b/plugins/guests/debian/cap/change_host_name.rb index e496004ad..877416cc3 100644 --- a/plugins/guests/debian/cap/change_host_name.rb +++ b/plugins/guests/debian/cap/change_host_name.rb @@ -16,9 +16,6 @@ module VagrantPlugins hostnamectl set-hostname '#{basename}' fi - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts diff --git a/plugins/guests/freebsd/cap/change_host_name.rb b/plugins/guests/freebsd/cap/change_host_name.rb index 35b924af3..9ddd0a614 100644 --- a/plugins/guests/freebsd/cap/change_host_name.rb +++ b/plugins/guests/freebsd/cap/change_host_name.rb @@ -12,10 +12,6 @@ module VagrantPlugins hostname '#{name}' sed -i '' 's/^hostname=.*$/hostname=\"#{name}\"/' /etc/rc.conf - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' /etc/hosts - sed -i'' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts diff --git a/plugins/guests/gentoo/cap/change_host_name.rb b/plugins/guests/gentoo/cap/change_host_name.rb index bf79d02a3..dea5176a1 100644 --- a/plugins/guests/gentoo/cap/change_host_name.rb +++ b/plugins/guests/gentoo/cap/change_host_name.rb @@ -18,10 +18,6 @@ module VagrantPlugins echo "hostname=#{basename}" > /etc/conf.d/hostname fi - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' /etc/hosts - sed -i'' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts && diff --git a/plugins/guests/omnios/cap/change_host_name.rb b/plugins/guests/omnios/cap/change_host_name.rb index 9cf9d5b2f..1fdcdd4b7 100644 --- a/plugins/guests/omnios/cap/change_host_name.rb +++ b/plugins/guests/omnios/cap/change_host_name.rb @@ -12,9 +12,6 @@ module VagrantPlugins echo '#{name}' > /etc/nodename hostname '#{name}' - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts diff --git a/plugins/guests/openbsd/cap/change_host_name.rb b/plugins/guests/openbsd/cap/change_host_name.rb index 20f879d81..131c8fc45 100644 --- a/plugins/guests/openbsd/cap/change_host_name.rb +++ b/plugins/guests/openbsd/cap/change_host_name.rb @@ -13,10 +13,6 @@ module VagrantPlugins sed -i'' 's/^hostname=.*$/hostname=\"#{name}\"/' /etc/rc.conf echo '#{name}' > /etc/myname - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' /etc/hosts - sed -i'' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts diff --git a/plugins/guests/photon/cap/change_host_name.rb b/plugins/guests/photon/cap/change_host_name.rb index 49fe25c5b..a2cf2adce 100644 --- a/plugins/guests/photon/cap/change_host_name.rb +++ b/plugins/guests/photon/cap/change_host_name.rb @@ -12,9 +12,6 @@ module VagrantPlugins echo '#{name}' > /etc/hostname hostname '#{name}' - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts diff --git a/plugins/guests/pld/cap/change_host_name.rb b/plugins/guests/pld/cap/change_host_name.rb index 7697c4a20..5ac55c1e7 100644 --- a/plugins/guests/pld/cap/change_host_name.rb +++ b/plugins/guests/pld/cap/change_host_name.rb @@ -13,9 +13,6 @@ module VagrantPlugins sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{name}\"/' /etc/sysconfig/interfaces/ifcfg-* - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb index afe461d4f..55fcdc4b4 100644 --- a/plugins/guests/redhat/cap/change_host_name.rb +++ b/plugins/guests/redhat/cap/change_host_name.rb @@ -23,9 +23,6 @@ module VagrantPlugins hostname -F /etc/hostname fi - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts diff --git a/plugins/guests/slackware/cap/change_host_name.rb b/plugins/guests/slackware/cap/change_host_name.rb index c8f51e0d6..6b3f6610d 100644 --- a/plugins/guests/slackware/cap/change_host_name.rb +++ b/plugins/guests/slackware/cap/change_host_name.rb @@ -14,9 +14,6 @@ module VagrantPlugins chmod o-w /etc/hostname hostname -F /etc/hostname - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts diff --git a/plugins/guests/suse/cap/change_host_name.rb b/plugins/guests/suse/cap/change_host_name.rb index 2e8cc1940..c168885f3 100644 --- a/plugins/guests/suse/cap/change_host_name.rb +++ b/plugins/guests/suse/cap/change_host_name.rb @@ -11,9 +11,6 @@ module VagrantPlugins echo '#{name}' > /etc/HOSTNAME hostname '#{name}' - # Remove comments and blank lines from /etc/hosts - sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts - # Prepend ourselves to /etc/hosts grep -w '#{name}' /etc/hosts || { sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts