vagrant-guest-netbsd 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +3 -0
- data/lib/vagrant-guest-netbsd.rb +1 -0
- data/lib/vagrant-guest-netbsd/cap/change_host_name.rb +15 -0
- data/lib/vagrant-guest-netbsd/cap/configure_networks.rb +48 -0
- data/lib/vagrant-guest-netbsd/cap/halt.rb +16 -0
- data/lib/vagrant-guest-netbsd/cap/mount_nfs_folder.rb +14 -0
- data/lib/vagrant-guest-netbsd/guest.rb +11 -0
- data/lib/vagrant-guest-netbsd/plugin.rb +35 -0
- data/vagrant-guest-netbsd.gemspec +22 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Stoned Elipot
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Vagrant::Guest::Netbsd
|
2
|
+
|
3
|
+
This plugin allows you to run NetBSD under [Vagrant][vagrant].
|
4
|
+
|
5
|
+
This Vagrant plugin had only been tested with Vagrant version 1.3.5
|
6
|
+
|
7
|
+
Please report any issue you will encounter.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
|
12
|
+
$ vagrant plugin install vagrant-guest-netbsd
|
13
|
+
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Add something like the following to your `Vagrantfile`
|
18
|
+
|
19
|
+
|
20
|
+
Vagrant.require_plugin "vagrant-guest-netbsd"
|
21
|
+
|
22
|
+
Vagrant.configure("2") do |config|
|
23
|
+
|
24
|
+
# Only NFS synced folder is supported
|
25
|
+
#
|
26
|
+
# And note that a private network with static IP
|
27
|
+
# is required for the virtualbox provider
|
28
|
+
config.vm.network :private_network, ip: "192.168.33.10"
|
29
|
+
config.vm.synced_folder "/some/host/pathname", "/vagrant", :nfs => true
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
40
|
+
|
41
|
+
|
42
|
+
[vagrant]: http://www.vagrantup.com/ "Vagrant"
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "vagrant-guest-netbsd/plugin"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestNetBSD
|
3
|
+
module Cap
|
4
|
+
class ChangeHostName
|
5
|
+
def self.change_host_name(machine, name)
|
6
|
+
if !machine.communicate.test("hostname -s | grep '^#{name}$'")
|
7
|
+
machine.communicate.sudo("sed -e 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf > /tmp/rc.conf.vagrant_changehostname_#{name}")
|
8
|
+
machine.communicate.sudo("mv /tmp/rc.conf.vagrant_changehostname_#{name} /etc/rc.conf")
|
9
|
+
machine.communicate.sudo("hostname #{name}")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
3
|
+
require "vagrant/util/template_renderer"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module GuestNetBSD
|
7
|
+
module Cap
|
8
|
+
class ConfigureNetworks
|
9
|
+
include Vagrant::Util
|
10
|
+
|
11
|
+
def self.configure_networks(machine, networks)
|
12
|
+
networks.each do |network|
|
13
|
+
ifname = "wm#{network[:interface]}"
|
14
|
+
newrcconf = "/tmp/rc.conf.vagrant_configurenetworks_#{network[:interface]}"
|
15
|
+
|
16
|
+
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > #{newrcconf}")
|
17
|
+
|
18
|
+
# using templates would be cleaner but I can't find a way
|
19
|
+
# to use templates in a non-core vagrant plugin -stoned
|
20
|
+
machine.communicate.sudo("echo '#VAGRANT-BEGIN' >> #{newrcconf}")
|
21
|
+
|
22
|
+
if network[:type].to_sym == :static
|
23
|
+
machine.communicate.sudo(%Q{echo 'ifconfig_#{ifname}="media autoselect up;inet #{network[:ip]} netmask #{network[:netmask]}"' >> #{newrcconf}})
|
24
|
+
elsif network[:type].to_sym == :dhcp
|
25
|
+
machine.communicate.sudo("echo 'ifconfig_#{ifname}=dhcp' >> #{newrcconf}")
|
26
|
+
end
|
27
|
+
|
28
|
+
machine.communicate.sudo("echo '#VAGRANT-END' >> #{newrcconf}")
|
29
|
+
|
30
|
+
machine.communicate.sudo("mv #{newrcconf} /etc/rc.conf")
|
31
|
+
|
32
|
+
|
33
|
+
# remove old configurations
|
34
|
+
machine.communicate.sudo("/sbin/dhcpcd -x #{ifname}", { :error_check => false })
|
35
|
+
machine.communicate.sudo("/sbin/ifconfig #{ifname} inet delete", { :error_check => false })
|
36
|
+
|
37
|
+
if network[:type].to_sym == :static
|
38
|
+
machine.communicate.sudo("/sbin/ifconfig #{ifname} media autoselect up")
|
39
|
+
machine.communicate.sudo("/sbin/ifconfig #{ifname} inet #{network[:ip]} netmask #{network[:netmask]}")
|
40
|
+
elsif network[:type].to_sym == :dhcp
|
41
|
+
machine.communicate.sudo("/sbin/dhcpcd -n -q #{ifname}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestNetBSD
|
3
|
+
module Cap
|
4
|
+
class Halt
|
5
|
+
def self.halt(machine)
|
6
|
+
begin
|
7
|
+
machine.communicate.sudo("/sbin/shutdown -p -h now")
|
8
|
+
rescue IOError
|
9
|
+
# Do nothing, because it probably means the machine shut down
|
10
|
+
# and SSH connection was lost.
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestNetBSD
|
3
|
+
module Cap
|
4
|
+
class MountNFSFolder
|
5
|
+
def self.mount_nfs_folder(machine, ip, folders)
|
6
|
+
folders.each do |name, opts|
|
7
|
+
machine.communicate.sudo("mkdir -p #{opts[:guestpath]}")
|
8
|
+
machine.communicate.sudo("/sbin/mount -t nfs '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestNetBSD
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "NetBSD guest"
|
7
|
+
description "NetBSD guest support."
|
8
|
+
|
9
|
+
guest("netbsd") do
|
10
|
+
require File.expand_path("../guest", __FILE__)
|
11
|
+
Guest
|
12
|
+
end
|
13
|
+
|
14
|
+
guest_capability("netbsd", "change_host_name") do
|
15
|
+
require_relative "cap/change_host_name"
|
16
|
+
Cap::ChangeHostName
|
17
|
+
end
|
18
|
+
|
19
|
+
guest_capability("netbsd", "configure_networks") do
|
20
|
+
require_relative "cap/configure_networks"
|
21
|
+
Cap::ConfigureNetworks
|
22
|
+
end
|
23
|
+
|
24
|
+
guest_capability("netbsd", "halt") do
|
25
|
+
require_relative "cap/halt"
|
26
|
+
Cap::Halt
|
27
|
+
end
|
28
|
+
|
29
|
+
guest_capability("netbsd", "mount_nfs_folder") do
|
30
|
+
require_relative "cap/mount_nfs_folder"
|
31
|
+
Cap::MountNFSFolder
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "vagrant-guest-netbsd"
|
7
|
+
spec.version = "0.0.2"
|
8
|
+
spec.authors = ["Stoned Elipot"]
|
9
|
+
spec.email = ["stoned.elipot@gmail.com"]
|
10
|
+
spec.description = %q{Vagrant Guest Plugin for NetBSD}
|
11
|
+
spec.summary = %q{This plugins allows you to run NetBSD under vagrant}
|
12
|
+
spec.homepage = "https://github.com/stoned/vagrant-guest-netbsd"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-guest-netbsd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stoned Elipot
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Vagrant Guest Plugin for NetBSD
|
47
|
+
email:
|
48
|
+
- stoned.elipot@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/vagrant-guest-netbsd.rb
|
59
|
+
- lib/vagrant-guest-netbsd/cap/change_host_name.rb
|
60
|
+
- lib/vagrant-guest-netbsd/cap/configure_networks.rb
|
61
|
+
- lib/vagrant-guest-netbsd/cap/halt.rb
|
62
|
+
- lib/vagrant-guest-netbsd/cap/mount_nfs_folder.rb
|
63
|
+
- lib/vagrant-guest-netbsd/guest.rb
|
64
|
+
- lib/vagrant-guest-netbsd/plugin.rb
|
65
|
+
- vagrant-guest-netbsd.gemspec
|
66
|
+
homepage: https://github.com/stoned/vagrant-guest-netbsd
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: 3233232354346185170
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
hash: 3233232354346185170
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.23
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: This plugins allows you to run NetBSD under vagrant
|
97
|
+
test_files: []
|