Debian system. Linux distro dispatch to debian/gentoo
This commit is contained in:
parent
76f10f920c
commit
2fe2246bbd
|
@ -12,6 +12,16 @@ module Vagrant
|
|||
@session = session
|
||||
end
|
||||
|
||||
# Executes a given command and simply returns true/false if the
|
||||
# command succeeded or not.
|
||||
def test?(command)
|
||||
exec!(command) do |ch, type, data|
|
||||
return true if type == :exit_status && data == 0
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
# Executes a given command on the SSH session and blocks until
|
||||
# the command completes. This is an almost line for line copy of
|
||||
# the actual `exec!` implementation, except that this
|
||||
|
|
|
@ -3,4 +3,6 @@
|
|||
require 'vagrant/systems/base'
|
||||
require 'vagrant/systems/linux'
|
||||
require 'vagrant/systems/solaris'
|
||||
|
||||
require 'vagrant/systems/debian'
|
||||
require 'vagrant/systems/gentoo'
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
module Vagrant
|
||||
module Systems
|
||||
class Debian < Linux
|
||||
def prepare_host_only_network
|
||||
# Remove any previous host only network additions to the
|
||||
# interface file.
|
||||
vm.ssh.execute do |ssh|
|
||||
# Clear out any previous entries
|
||||
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
||||
end
|
||||
end
|
||||
|
||||
def enable_host_only_network(net_options)
|
||||
entry = TemplateRenderer.render('network_entry_debian', :net_options => net_options)
|
||||
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
||||
|
||||
vm.ssh.execute do |ssh|
|
||||
ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null")
|
||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/network/interfaces'")
|
||||
ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,9 +5,6 @@ module Vagrant
|
|||
# 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 => GentooError, :_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'")
|
||||
|
|
|
@ -4,6 +4,16 @@ require 'vagrant/systems/linux/config'
|
|||
module Vagrant
|
||||
module Systems
|
||||
class Linux < Base
|
||||
def distro_dispatch
|
||||
vm.ssh.execute do |ssh|
|
||||
return :debian if ssh.test?("cat /etc/debian_version")
|
||||
return :gentoo if ssh.test?("cat /etc/gentoo-release")
|
||||
end
|
||||
|
||||
# Can't detect the distro, assume vanilla linux
|
||||
nil
|
||||
end
|
||||
|
||||
def halt
|
||||
vm.env.ui.info I18n.t("vagrant.systems.linux.attempting_halt")
|
||||
vm.ssh.execute do |ssh|
|
||||
|
@ -39,30 +49,6 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
def prepare_host_only_network
|
||||
# Remove any previous host only network additions to the
|
||||
# interface file.
|
||||
vm.ssh.execute do |ssh|
|
||||
# Verify debian/ubuntu
|
||||
ssh.exec!("cat /etc/debian_version", :error_class => LinuxError, :_key => :network_not_debian)
|
||||
|
||||
# Clear out any previous entries
|
||||
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
||||
end
|
||||
end
|
||||
|
||||
def enable_host_only_network(net_options)
|
||||
entry = TemplateRenderer.render('network_entry', :net_options => net_options)
|
||||
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
||||
|
||||
vm.ssh.execute do |ssh|
|
||||
ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null")
|
||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/network/interfaces'")
|
||||
ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
|
||||
end
|
||||
end
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# "Private" methods which assist above methods
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
@ -58,9 +58,10 @@ module Vagrant
|
|||
elsif system.is_a?(Symbol)
|
||||
# Hard-coded internal systems
|
||||
mapping = {
|
||||
:debian => Systems::Debian,
|
||||
:gentoo => Systems::Gentoo,
|
||||
:linux => Systems::Linux,
|
||||
:solaris => Systems::Solaris,
|
||||
:gentoo => Systems::Gentoo
|
||||
:solaris => Systems::Solaris
|
||||
}
|
||||
|
||||
raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !mapping.has_key?(system)
|
||||
|
|
Loading…
Reference in New Issue