diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7433ee2..dc38f23fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ FEATURES: - **New guest:** Funtoo (change host name and networks supported) - **New guest:** NetBSD + - **New guest:** TinyCore Linux. This allows features such as networking, + halting, rsync and more work with Boot2Docker. - Password-based SSH authentication. This lets you use almost any off-the-shelf virtual machine image with Vagrant. Additionally, Vagrant will automatically insert a keypair into the machine. diff --git a/plugins/guests/tinycore/cap/configure_networks.rb b/plugins/guests/tinycore/cap/configure_networks.rb new file mode 100644 index 000000000..cccc0e311 --- /dev/null +++ b/plugins/guests/tinycore/cap/configure_networks.rb @@ -0,0 +1,21 @@ +require "ipaddr" + +module VagrantPlugins + module GuestTinyCore + module Cap + class ConfigureNetworks + def self.configure_networks(machine, networks) + machine.communicate.tap do |comm| + networks.each do |n| + ifc = "/sbin/ifconfig eth#{n[:interface]}" + broadcast = (IPAddr.new(n[:ip]) | (~ IPAddr.new(n[:netmask]))).to_s + comm.sudo("#{ifc} down") + comm.sudo("#{ifc} #{n[:ip]} netmask #{n[:netmask]} broadcast #{broadcast}") + comm.sudo("#{ifc} up") + end + end + end + end + end + end +end diff --git a/plugins/guests/tinycore/cap/halt.rb b/plugins/guests/tinycore/cap/halt.rb new file mode 100644 index 000000000..97c045257 --- /dev/null +++ b/plugins/guests/tinycore/cap/halt.rb @@ -0,0 +1,16 @@ +module VagrantPlugins + module GuestTinyCore + module Cap + class Halt + def self.halt(machine) + begin + machine.communicate.sudo("poweroff") + rescue Net::SSH::Disconnect, IOError + # Do nothing, because it probably means the machine shut down + # and SSH connection was lost. + end + end + end + end + end +end diff --git a/plugins/guests/tinycore/guest.rb b/plugins/guests/tinycore/guest.rb new file mode 100644 index 000000000..ae24f0066 --- /dev/null +++ b/plugins/guests/tinycore/guest.rb @@ -0,0 +1,11 @@ +require "vagrant" + +module VagrantPlugins + module GuestTinyCore + class Guest < Vagrant.plugin("2", :guest) + def detect?(machine) + machine.communicate.test("cat /etc/issue | grep 'Core Linux'") + end + end + end +end diff --git a/plugins/guests/tinycore/plugin.rb b/plugins/guests/tinycore/plugin.rb new file mode 100644 index 000000000..f4b0c83cc --- /dev/null +++ b/plugins/guests/tinycore/plugin.rb @@ -0,0 +1,25 @@ +require "vagrant" + +module VagrantPlugins + module GuestTinyCore + class Plugin < Vagrant.plugin("2") + name "TinyCore Linux guest." + description "TinyCore Linux guest support." + + guest("tinycore", "linux") do + require File.expand_path("../guest", __FILE__) + Guest + end + + guest_capability("tinycore", "configure_networks") do + require_relative "cap/configure_networks" + Cap::ConfigureNetworks + end + + guest_capability("tinycore", "halt") do + require_relative "cap/halt" + Cap::Halt + end + end + end +end