diff --git a/plugins/guests/funtoo/cap/change_host_name.rb b/plugins/guests/funtoo/cap/change_host_name.rb deleted file mode 100644 index 298ff5b12..000000000 --- a/plugins/guests/funtoo/cap/change_host_name.rb +++ /dev/null @@ -1,17 +0,0 @@ -module VagrantPlugins - module GuestFuntoo - module Cap - class ChangeHostName - def self.change_host_name(machine, name) - machine.communicate.tap do |comm| - if !comm.test("sudo hostname --fqdn | grep '#{name}'") - comm.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname") - comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") - comm.sudo("hostname #{name.split('.')[0]}") - end - end - end - end - end - end -end diff --git a/plugins/guests/funtoo/plugin.rb b/plugins/guests/funtoo/plugin.rb index 59f76da98..2f768d669 100644 --- a/plugins/guests/funtoo/plugin.rb +++ b/plugins/guests/funtoo/plugin.rb @@ -6,16 +6,11 @@ module VagrantPlugins name "Funtoo guest" description "Funtoo guest support." - guest(:funtoo, :linux) do + guest(:funtoo, :gentoo) do require_relative "guest" Guest end - guest_capability(:funtoo, :change_host_name) do - require_relative "cap/change_host_name" - Cap::ChangeHostName - end - guest_capability(:funtoo, :configure_networks) do require_relative "cap/configure_networks" Cap::ConfigureNetworks diff --git a/plugins/guests/gentoo/cap/change_host_name.rb b/plugins/guests/gentoo/cap/change_host_name.rb index a8112b7d5..c36274e5c 100644 --- a/plugins/guests/gentoo/cap/change_host_name.rb +++ b/plugins/guests/gentoo/cap/change_host_name.rb @@ -3,12 +3,25 @@ module VagrantPlugins module Cap class ChangeHostName def self.change_host_name(machine, name) - machine.communicate.tap do |comm| - if !comm.test("sudo hostname --fqdn | grep '#{name}'") - comm.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname") - comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") - comm.sudo("hostname #{name.split('.')[0]}") - end + comm = machine.communicate + + if !comm.test("hostname -f | grep '^#{name}$'") + basename = name.split(".", 2)[0] + comm.sudo <<-EOH.gsub(/^ {14}/, "") + # Set the hostname + hostname '#{basename}' + echo "hostname=#{basename}" > /etc/conf.d/hostname + + # 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 + mv /tmp/tmp-hosts /etc/hosts + } + EOH end end end diff --git a/templates/guests/funtoo/network_static6.erb b/templates/guests/funtoo/network_static6.erb new file mode 100644 index 000000000..d74408959 --- /dev/null +++ b/templates/guests/funtoo/network_static6.erb @@ -0,0 +1,9 @@ +#VAGRANT-BEGIN +template='interface' +ipaddr='<%= options[:ip] %>/<%= options[:netmask] %>' +<% [:gateway, :nameservers, :domain, :route, :gateway6, :route6, :mtu].each do |key| %> +<% if options[key] %> +<%= key %>='<%= options[key] %>' +<% end %> +<% end %> +#VAGRANT-END