Skip to content

Instantly share code, notes, and snippets.

@fnordfish
Created October 26, 2010 16:18
Show Gist options
  • Save fnordfish/647212 to your computer and use it in GitHub Desktop.
Save fnordfish/647212 to your computer and use it in GitHub Desktop.
A Vagrant system implementation for gentoo based linux
# A Vagrant system implementation for gentoo based linuxs
class Gentoo < Vagrant::Systems::Linux
class GentooConfig < Vagrant::Config::Base
configures :gentoo
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
def initialize
@halt_timeout = 30
@halt_check_interval = 1
end
end
#-------------------------------------------------------------------
# Overridden methods
#-------------------------------------------------------------------
def prepare_host_only_network
# Remove any previous host only network additions to the
# interface file.
vm.ssh.execute do |ssh|
# Verify gentoo
ssh.exec!("cat /etc/gentoo-release", :error_class => LinuxError, :_key => :network_not_gentoo)
# Clear out any previous entries
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/conf.d/net'")
end
end
def enable_host_only_network(net_options)
# manually render the net template
entry = nil
File.open(File.expand_path('network_entry_gentoo.erb', File.dirname(__FILE__)), 'r') do |f|
entry = Erubis::Eruby.new(f.read, :trim => true).result(binding)
end
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
vm.ssh.execute do |ssh|
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/conf.d/net'")
ssh.exec!("sudo su -c 'ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{net_options[:adapter]} && /etc/init.d/net.eth#{net_options[:adapter]} restart'")
end
end
end
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant.
# Please do not modify any of these contents.
config_eth<%= net_options[:adapter] %>=( "<%= net_options[:ip] %> netmask <%= net_options[:netmask] %>" )
#VAGRANT-END
require File.expand_path("./gentoo.rb", File.dirname(__FILE__))
Vagrant::Config.run do |config|
config.vm.system = Gentoo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment