guests/tinycore: TinyCore Linux support
This commit is contained in:
parent
397407b7a5
commit
72702b4884
|
@ -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.
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue