guests/funtoo: Behave like a gentoo guest
This commit is contained in:
parent
d9936e8808
commit
3eebff5bf3
|
@ -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
|
|
|
@ -6,16 +6,11 @@ module VagrantPlugins
|
||||||
name "Funtoo guest"
|
name "Funtoo guest"
|
||||||
description "Funtoo guest support."
|
description "Funtoo guest support."
|
||||||
|
|
||||||
guest(:funtoo, :linux) do
|
guest(:funtoo, :gentoo) do
|
||||||
require_relative "guest"
|
require_relative "guest"
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:funtoo, :change_host_name) do
|
|
||||||
require_relative "cap/change_host_name"
|
|
||||||
Cap::ChangeHostName
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability(:funtoo, :configure_networks) do
|
guest_capability(:funtoo, :configure_networks) do
|
||||||
require_relative "cap/configure_networks"
|
require_relative "cap/configure_networks"
|
||||||
Cap::ConfigureNetworks
|
Cap::ConfigureNetworks
|
||||||
|
|
|
@ -3,12 +3,25 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class ChangeHostName
|
class ChangeHostName
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
machine.communicate.tap do |comm|
|
comm = machine.communicate
|
||||||
if !comm.test("sudo hostname --fqdn | grep '#{name}'")
|
|
||||||
comm.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
|
if !comm.test("hostname -f | grep '^#{name}$'")
|
||||||
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo("hostname #{name.split('.')[0]}")
|
comm.sudo <<-EOH.gsub(/^ {14}/, "")
|
||||||
end
|
# 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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue