vagrant-bindfs 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +15 -13
- data/lib/vagrant-bindfs.rb +20 -10
- data/lib/vagrant-bindfs/bind.rb +112 -0
- data/lib/vagrant-bindfs/cap/debian/bindfs_install.rb +18 -0
- data/lib/vagrant-bindfs/cap/linux/bindfs_installed.rb +15 -0
- data/lib/vagrant-bindfs/config.rb +63 -23
- data/lib/vagrant-bindfs/errors.rb +9 -0
- data/lib/vagrant-bindfs/plugin.rb +31 -0
- data/lib/vagrant-bindfs/version.rb +1 -1
- data/locales/en.yml +17 -11
- metadata +11 -17
- data/lib/vagrant-bindfs/error.rb +0 -5
- data/lib/vagrant-bindfs/middleware.rb +0 -91
- data/lib/vagrant_init.rb +0 -2
data/README.md
CHANGED
@@ -6,7 +6,8 @@ This allow you to change owner, group and permissions on files and, for example,
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Vagrant-bindfs is distributed as a Ruby gem.
|
9
|
+
Vagrant-bindfs is distributed as a Ruby gem.
|
10
|
+
You can install it as any other Vagrant plugin with `vagrant plugin install vagrant-bindfs`.
|
10
11
|
|
11
12
|
|
12
13
|
## Configure your VM
|
@@ -16,18 +17,18 @@ In your VagrantFile, you can use `config.bindfs.bind_folder` to configure folder
|
|
16
17
|
# In your Vagrantfile
|
17
18
|
Vagrant::Config.run do |config|
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
[...] # Your VM configuration
|
21
|
+
|
22
|
+
# Basic usage
|
23
|
+
config.bindfs.bind_folder "source/dir", "mount/point"
|
24
|
+
|
25
|
+
# Advanced options
|
26
|
+
config.bindfs.bind_folder "source/dir", "mount/point", :perms => "u=rw:g=r:o=r", :create_as_user => true
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
# Complete example for a NFS shared folder
|
29
|
+
config.vm.network :hostonly, "33.33.33.10" # (required to use NFS shared folder)
|
30
|
+
config.vm.share_folder "nfs-share", "/vagrant-nfs", "host/source/dir", :nfs => true
|
31
|
+
config.bindfs.bind_folder "/vagrant-nfs", "guest/mount/point"
|
31
32
|
|
32
33
|
end
|
33
34
|
|
@@ -68,4 +69,5 @@ You can overwrite default options _via_ `config.bindfs.default_options`.
|
|
68
69
|
|
69
70
|
See [bindfs man page](http://www.cs.helsinki.fi/u/partel/bindfs_docs/bindfs.1.html) for details.
|
70
71
|
|
71
|
-
vagrant-bindfs does not check compatibility between given arguments but warn you when a binding command fail or
|
72
|
+
vagrant-bindfs does not check compatibility between given arguments but warn you when a binding command fail or if bindfs is not installed on your virtual machine.
|
73
|
+
On Debian systems, it will try to install bindfs automatically.
|
data/lib/vagrant-bindfs.rb
CHANGED
@@ -1,13 +1,23 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant bindfs plugin must be run within Vagrant"
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
require 'vagrant-bindfs/plugin'
|
8
|
+
require 'vagrant-bindfs/version'
|
9
|
+
require 'vagrant-bindfs/errors'
|
8
10
|
|
9
|
-
|
10
|
-
Vagrant.actions[:start].insert Vagrant::Action::VM::Provision, VagrantBindfs::Middleware
|
11
|
+
require "pathname"
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
module VagrantPlugins
|
14
|
+
module Bindfs
|
15
|
+
# Returns the path to the source of this plugin
|
16
|
+
def self.source_root
|
17
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
18
|
+
end
|
19
|
+
|
20
|
+
I18n.load_path << File.expand_path('locales/en.yml', source_root)
|
21
|
+
I18n.reload!
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Bindfs
|
3
|
+
module Action
|
4
|
+
class Bind
|
5
|
+
# Options
|
6
|
+
@@options = {
|
7
|
+
:owner => 'vagrant',
|
8
|
+
:group => 'vagrant',
|
9
|
+
:perms => 'u=rwX:g=rD:o=rD',
|
10
|
+
:mirror => nil,
|
11
|
+
:'mirror-only' => nil,
|
12
|
+
:'create-for-user' => nil,
|
13
|
+
:'create-for-group' => nil,
|
14
|
+
:'create-with-perms' => nil,
|
15
|
+
}
|
16
|
+
|
17
|
+
# Flags
|
18
|
+
@@flags = {
|
19
|
+
:'no-allow-other' => false,
|
20
|
+
:'create-as-user' => false,
|
21
|
+
:'create-as-mounter' => false,
|
22
|
+
:'chown-normal' => false,
|
23
|
+
:'chown-ignore' => false,
|
24
|
+
:'chown-deny' => false,
|
25
|
+
:'chgrp-normal' => false,
|
26
|
+
:'chgrp-ignore' => false,
|
27
|
+
:'chgrp-deny' => false,
|
28
|
+
:'chmod-normal' => false,
|
29
|
+
:'chmod-ignore' => false,
|
30
|
+
:'chmod-deny' => false,
|
31
|
+
:'chmod-allow-x' => false,
|
32
|
+
:'xattr-none' => false,
|
33
|
+
:'xattr-ro' => false,
|
34
|
+
:'xattr-rw' => false,
|
35
|
+
:'ctime-from-mtime' => false,
|
36
|
+
}
|
37
|
+
|
38
|
+
def initialize(app, env)
|
39
|
+
@app = app
|
40
|
+
@env = env
|
41
|
+
end
|
42
|
+
|
43
|
+
def call(env)
|
44
|
+
@app.call(env)
|
45
|
+
@env = env
|
46
|
+
|
47
|
+
@machine = env[:machine]
|
48
|
+
|
49
|
+
handle_bindfs_installation
|
50
|
+
bind_folders if !binded_folders.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def binded_folders
|
54
|
+
@machine.config.bindfs.bind_folders
|
55
|
+
end
|
56
|
+
|
57
|
+
def default_options
|
58
|
+
@@options.merge(@@flags).merge(@machine.config.bindfs.default_options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def normalize_options opts
|
62
|
+
source = opts.delete(:source_path)
|
63
|
+
dest = opts.delete(:dest_path)
|
64
|
+
opts = default_options.merge(opts)
|
65
|
+
|
66
|
+
args = []
|
67
|
+
opts.each do |key, value|
|
68
|
+
args << "--#{key.to_s}" if @@flags.key?(key) and !!value
|
69
|
+
args << "--#{key.to_s}=#{value}" if @@options.key?(key) and !value.nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
[ source, dest, " #{args.join(" ")}" ]
|
73
|
+
end
|
74
|
+
|
75
|
+
def bind_folders
|
76
|
+
@env[:ui].info I18n.t("vagrant.config.bindfs.status.binding_all")
|
77
|
+
|
78
|
+
binded_folders.each do |id, opts|
|
79
|
+
source, dest, args = normalize_options opts
|
80
|
+
bind_command = "sudo bindfs#{args} #{source} #{dest}"
|
81
|
+
|
82
|
+
unless @machine.communicate.test("test -d #{source}")
|
83
|
+
@env[:ui].error(I18n.t('vagrant.config.bindfs.errors.source_path_not_exist', :path => source))
|
84
|
+
next
|
85
|
+
end
|
86
|
+
|
87
|
+
if @machine.communicate.test("mount | grep bindfs | grep ' #{dest} '")
|
88
|
+
@env[:ui].info(I18n.t('vagrant.config.bindfs.already_mounted', :dest => dest))
|
89
|
+
next
|
90
|
+
end
|
91
|
+
|
92
|
+
@env[:ui].info I18n.t("vagrant.config.bindfs.status.binding_entry", :source => source, :dest => dest)
|
93
|
+
|
94
|
+
@machine.communicate.sudo("mkdir -p #{dest}")
|
95
|
+
@machine.communicate.sudo(bind_command, :error_class => Error, :error_key => :binding_failed)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def handle_bindfs_installation
|
100
|
+
if !@machine.guest.capability(:bindfs_installed)
|
101
|
+
@env[:ui].warn(I18n.t('vagrant.config.bindfs.not_installed'))
|
102
|
+
|
103
|
+
if !@machine.guest.capability(:bindfs_install)
|
104
|
+
raise Vagrant::Bindfs::Error, :cannot_install
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end #Bind
|
110
|
+
end #Action
|
111
|
+
end #Bindfs
|
112
|
+
end #VagrantPlugins
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Bindfs
|
3
|
+
module Cap
|
4
|
+
module Debian
|
5
|
+
module BindfsInstall
|
6
|
+
|
7
|
+
def self.bindfs_install(machine)
|
8
|
+
machine.communicate.tap do |comm|
|
9
|
+
comm.sudo('apt-get update')
|
10
|
+
comm.sudo('apt-get install -y bindfs')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end # BindfsInstall
|
15
|
+
end # Debian
|
16
|
+
end # Cap
|
17
|
+
end # Bindfs
|
18
|
+
end # VagrantPlugins
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Bindfs
|
3
|
+
module Cap
|
4
|
+
module Linux
|
5
|
+
module BindfsInstalled
|
6
|
+
|
7
|
+
def self.bindfs_installed(machine)
|
8
|
+
machine.communicate.test('bindfs --help')
|
9
|
+
end
|
10
|
+
|
11
|
+
end # BindfsInstalled
|
12
|
+
end # Linux
|
13
|
+
end # Cap
|
14
|
+
end # Bindfs
|
15
|
+
end # module VagrantPlugins
|
@@ -1,26 +1,66 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
module VagrantPlugins
|
2
|
+
module Bindfs
|
3
|
+
class Config < Vagrant.plugin('2', :config)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@__default_options = {}
|
7
|
+
@__bind_folders = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def bind_folders
|
11
|
+
@__bind_folders
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_options(new_options = {})
|
15
|
+
@__default_options.merge! new_options
|
16
|
+
end
|
17
|
+
|
18
|
+
def bind_folder(source_path, dest_path, opts = nil)
|
19
|
+
options ||= {}
|
20
|
+
options[:source_path] = source_path
|
21
|
+
options[:dest_path] = dest_path
|
22
|
+
|
23
|
+
@__bind_folders[options[:dest_path]] = options
|
24
|
+
end
|
25
|
+
|
26
|
+
def merge(other)
|
27
|
+
super.tap do |result|
|
28
|
+
# merge the changes to default options
|
29
|
+
result.instance_variable_set(
|
30
|
+
:@__default_options, default_options(other.default_options))
|
31
|
+
|
32
|
+
# merge the folders to be bound
|
33
|
+
new_folders = @__bind_folders.dup
|
34
|
+
other_folders = other.instance_variable_get(:@__bind_folders)
|
35
|
+
|
36
|
+
other_folders.each do |id, options|
|
37
|
+
new_folders[id] ||= {}
|
38
|
+
new_folders[id].merge!(options)
|
39
|
+
end
|
40
|
+
|
41
|
+
result.instance_variable_set(:@__bind_folders, new_folders)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate(machine)
|
46
|
+
errors = []
|
47
|
+
|
48
|
+
@__bind_folders.each do |id, options|
|
49
|
+
next if options[:disabled]
|
50
|
+
|
51
|
+
if Pathname.new(options[:dest_path]).relative?
|
52
|
+
errors << I18n.t('vagrant.config.bindfs.errors.destination_path_relative',
|
53
|
+
:path => options[:dest_path])
|
54
|
+
end
|
55
|
+
|
56
|
+
if Pathname.new(options[:source_path]).relative?
|
57
|
+
errors << I18n.t('vagrant.config.bindfs.errors.source_path_relative',
|
58
|
+
:path => options[:source_path])
|
59
|
+
end
|
60
|
+
end
|
16
61
|
|
17
|
-
|
18
|
-
|
19
|
-
@binded_folders << {
|
20
|
-
:path => path,
|
21
|
-
:bindpath => bindpath
|
22
|
-
}.merge(opts)
|
62
|
+
errors.empty? && {} || { 'bindfs' => errors }
|
63
|
+
end
|
23
64
|
end
|
24
|
-
|
25
65
|
end
|
26
|
-
end
|
66
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Bindfs
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
4
|
+
name "Bindfs"
|
5
|
+
description <<-DESC
|
6
|
+
This plugin allows you to mount -o bind filesystems inside the guest. This is
|
7
|
+
useful to change their ownership and permissions.
|
8
|
+
DESC
|
9
|
+
|
10
|
+
config(:bindfs) do
|
11
|
+
require 'vagrant-bindfs/config'
|
12
|
+
Config
|
13
|
+
end
|
14
|
+
|
15
|
+
guest_capability("debian", "bindfs_install") do
|
16
|
+
require 'vagrant-bindfs/cap/debian/bindfs_install'
|
17
|
+
Cap::Debian::BindfsInstall
|
18
|
+
end
|
19
|
+
|
20
|
+
guest_capability("linux", "bindfs_installed") do
|
21
|
+
require 'vagrant-bindfs/cap/linux/bindfs_installed'
|
22
|
+
Cap::Linux::BindfsInstalled
|
23
|
+
end
|
24
|
+
|
25
|
+
action_hook(:bindfs, :machine_action_up) do |hook|
|
26
|
+
require 'vagrant-bindfs/bind'
|
27
|
+
hook.prepend(Action::Bind)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/locales/en.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
en:
|
2
2
|
vagrant:
|
3
|
-
|
4
|
-
|
5
|
-
bindfs
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
config:
|
4
|
+
bindfs:
|
5
|
+
not_installed: bindfs seems to not be installed on the virtual machine
|
6
|
+
already_mounted: "there's already a bindfs mount to destination %{dest}"
|
7
|
+
status:
|
8
|
+
binding_all: creating bind mounts for selected devices
|
9
|
+
binding_entry: creating bind mount from %{source} to %{dest}
|
10
|
+
errors:
|
11
|
+
destination_path_relative: "destination path is relative for bind whatever"
|
12
|
+
source_path_relative: "source path is relative for bind whatever"
|
13
|
+
source_path_not_exist: "cannot bind source path %{path} because it doesn't exist"
|
14
|
+
binding_failed: |-
|
15
|
+
bind command %{command} failed to run!
|
16
|
+
|
17
|
+
Please check options values and compatibility.
|
18
|
+
For a complete documentation, run `sudo bindfs --help` on the VM or see bindfs man page at http://www.cs.helsinki.fi/u/partel/bindfs_docs/bindfs.1.html
|
19
|
+
|
metadata
CHANGED
@@ -2,30 +2,22 @@
|
|
2
2
|
name: vagrant-bindfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Folken La\xC3\xABneck"
|
9
|
+
- Igor Serebryany
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: vagrant
|
17
|
-
prerelease: false
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
21
|
-
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.0.5
|
24
|
-
type: :runtime
|
25
|
-
version_requirements: *id001
|
14
|
+
date: 2013-06-03 00:00:00 Z
|
15
|
+
dependencies: []
|
16
|
+
|
26
17
|
description: A Vagrant plugin to automate bindfs mount in the VM. This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues.
|
27
18
|
email:
|
28
19
|
- folken.laeneck@gmail.com
|
20
|
+
- igor.serebryany@airbnb.com
|
29
21
|
executables: []
|
30
22
|
|
31
23
|
extensions: []
|
@@ -33,12 +25,14 @@ extensions: []
|
|
33
25
|
extra_rdoc_files: []
|
34
26
|
|
35
27
|
files:
|
36
|
-
- lib/vagrant-bindfs/
|
37
|
-
- lib/vagrant-bindfs/
|
28
|
+
- lib/vagrant-bindfs/cap/linux/bindfs_installed.rb
|
29
|
+
- lib/vagrant-bindfs/cap/debian/bindfs_install.rb
|
30
|
+
- lib/vagrant-bindfs/bind.rb
|
31
|
+
- lib/vagrant-bindfs/errors.rb
|
38
32
|
- lib/vagrant-bindfs/version.rb
|
33
|
+
- lib/vagrant-bindfs/plugin.rb
|
39
34
|
- lib/vagrant-bindfs/config.rb
|
40
35
|
- lib/vagrant-bindfs.rb
|
41
|
-
- lib/vagrant_init.rb
|
42
36
|
- locales/en.yml
|
43
37
|
- README.md
|
44
38
|
- LICENSE.txt
|
data/lib/vagrant-bindfs/error.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
module VagrantBindfs
|
2
|
-
# A Vagrant middleware which use bindfs to relocate directories inside a VM
|
3
|
-
# and change their owner, group and permission.
|
4
|
-
class Middleware
|
5
|
-
|
6
|
-
# Options
|
7
|
-
@@options = {
|
8
|
-
:owner => 'vagrant',
|
9
|
-
:group => 'vagrant',
|
10
|
-
:perms => 'u=rwX:g=rD:o=rD',
|
11
|
-
:mirror => nil,
|
12
|
-
:'mirror-only' => nil,
|
13
|
-
:'create-for-user' => nil,
|
14
|
-
:'create-for-group' => nil,
|
15
|
-
:'create-with-perms' => nil,
|
16
|
-
}
|
17
|
-
|
18
|
-
# Flags
|
19
|
-
@@flags = {
|
20
|
-
:'no-allow-other' => false,
|
21
|
-
:'create-as-user' => false,
|
22
|
-
:'create-as-mounter' => false,
|
23
|
-
:'chown-normal' => false,
|
24
|
-
:'chown-ignore' => false,
|
25
|
-
:'chown-deny' => false,
|
26
|
-
:'chgrp-normal' => false,
|
27
|
-
:'chgrp-ignore' => false,
|
28
|
-
:'chgrp-deny' => false,
|
29
|
-
:'chmod-normal' => false,
|
30
|
-
:'chmod-ignore' => false,
|
31
|
-
:'chmod-deny' => false,
|
32
|
-
:'chmod-allow-x' => false,
|
33
|
-
:'xattr-none' => false,
|
34
|
-
:'xattr-ro' => false,
|
35
|
-
:'xattr-rw' => false,
|
36
|
-
:'ctime-from-mtime' => false,
|
37
|
-
}
|
38
|
-
|
39
|
-
def initialize(app, env)
|
40
|
-
@app = app
|
41
|
-
@env = env
|
42
|
-
end
|
43
|
-
|
44
|
-
def call(env)
|
45
|
-
@app.call(env)
|
46
|
-
@env = env
|
47
|
-
|
48
|
-
bind_folders if !binded_folders.empty? and bindfs_supported?
|
49
|
-
end
|
50
|
-
|
51
|
-
def binded_folders
|
52
|
-
@env[:vm].config.bindfs.binded_folders
|
53
|
-
end
|
54
|
-
|
55
|
-
def default_options
|
56
|
-
@@options.merge(@@flags).merge(@env[:vm].config.bindfs.default_options)
|
57
|
-
end
|
58
|
-
|
59
|
-
def bindfs_supported?
|
60
|
-
@env[:vm].channel.execute("bindfs --help", :error_class => Error, :error_key => :not_installed)
|
61
|
-
end
|
62
|
-
|
63
|
-
def normalize_options opts
|
64
|
-
|
65
|
-
path = opts.delete(:path)
|
66
|
-
bindpath = opts.delete(:bindpath)
|
67
|
-
opts = default_options.merge(opts)
|
68
|
-
|
69
|
-
args = []
|
70
|
-
opts.each do |key, value|
|
71
|
-
args << "--#{key.to_s}" if @@flags.key?(key) and !!value
|
72
|
-
args << "--#{key.to_s}=#{value}" if @@options.key?(key) and !value.nil?
|
73
|
-
end
|
74
|
-
|
75
|
-
[ path, bindpath, " #{args.join(" ")}" ]
|
76
|
-
end
|
77
|
-
|
78
|
-
def bind_folders
|
79
|
-
@env[:ui].info I18n.t("vagrant.guest.linux.bindfs.status.binding")
|
80
|
-
binded_folders.each do |opts|
|
81
|
-
path, bindpath, args = normalize_options opts
|
82
|
-
|
83
|
-
@env[:vm].channel.sudo("mkdir -p #{bindpath}")
|
84
|
-
@env[:vm].channel.sudo("sudo bindfs#{args} #{path} #{bindpath}", :error_class => Error, :error_key => :bindfs_command_fail)
|
85
|
-
@env[:ui].info I18n.t("vagrant.guest.linux.bindfs.status.binding_entry", :path => path, :bindpath => bindpath)
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
data/lib/vagrant_init.rb
DELETED