vagrant-bindfs 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/README.md +91 -68
- data/lib/vagrant-bindfs.rb +4 -5
- data/lib/vagrant-bindfs/bind.rb +172 -72
- data/lib/vagrant-bindfs/cap/debian/bindfs_install.rb +7 -7
- data/lib/vagrant-bindfs/cap/linux/bindfs_installed.rb +6 -6
- data/lib/vagrant-bindfs/cap/suse/bindfs_install.rb +17 -0
- data/lib/vagrant-bindfs/config.rb +49 -26
- data/lib/vagrant-bindfs/errors.rb +0 -2
- data/lib/vagrant-bindfs/plugin.rb +15 -7
- data/lib/vagrant-bindfs/version.rb +1 -1
- data/locales/en.yml +12 -11
- metadata +26 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e5ede475244f757129e5549bd4efa08da086515
|
4
|
+
data.tar.gz: f1fc218651127f7ade08604adaac9ebb4200e762
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53435c06bc292ad42a6d8803ee0d576b376f5141a41e570c74b644ce2e8bd8fad95be68bfb0fe761582fd8a9474fee97f6b4bd5a37f1befbbf87d5b301e96c01
|
7
|
+
data.tar.gz: 122c7a0fb83f8a088b84eb24a1af6a8d394c130b84a5f08b7e8890fe1d1877652ab0cd273056441b453b5e86d0309d514564b6de1efc0dad23f7b635bcc83c3a
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# vagrant-bindfs
|
2
2
|
|
3
|
-
A Vagrant plugin to automate [bindfs](http://bindfs.org/) mount in the VM.
|
4
|
-
|
3
|
+
A Vagrant plugin to automate [bindfs](http://bindfs.org/) mount in the VM. This allow you to change
|
4
|
+
owner, group and permissions on files and, for example, work around NFS share permissions issues.
|
5
5
|
|
6
6
|
|
7
7
|
## Some Background: Why `vagrant-bindfs`
|
@@ -28,103 +28,126 @@ _Note that `map_uid` and `map_gid` NFS options can be used to set the identity u
|
|
28
28
|
|
29
29
|
## Installation
|
30
30
|
|
31
|
-
Vagrant-bindfs is distributed as a Ruby gem.
|
32
|
-
|
31
|
+
Vagrant-bindfs is distributed as a Ruby gem. You can install it as any other Vagrant plugin
|
32
|
+
with `vagrant plugin install vagrant-bindfs`.
|
33
33
|
|
34
34
|
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
In your `Vagrantfile`, use `config.bindfs.bind_folder` to configure folders that will be binded on VM
|
38
|
-
The format is:
|
37
|
+
In your `Vagrantfile`, use `config.bindfs.bind_folder` to configure folders that will be binded on VM
|
38
|
+
startup. The format is:
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
|
41
|
+
config.bindfs.bind_folder "/path/to/source", "/path/to/destination", options
|
42
42
|
```
|
43
43
|
|
44
44
|
|
45
45
|
### Example
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
48
|
+
Vagrant::Config.run do |config|
|
49
|
+
|
50
|
+
[...] # Your VM configuration
|
51
|
+
|
52
|
+
## Basic usage
|
53
|
+
config.bindfs.bind_folder "source/dir", "mount/point"
|
54
|
+
|
55
|
+
## Advanced options
|
56
|
+
config.bindfs.bind_folder "source/dir", "mount/point",
|
57
|
+
perms: "u=rw:g=r:o=r",
|
58
|
+
create_as_user: true
|
59
|
+
|
60
|
+
## Complete example for a NFS shared folder
|
61
|
+
|
62
|
+
# Declare shared folder with Vagrant syntax
|
63
|
+
config.vm.synced_folder ".", "/vagrant-nfs", type: :nfs
|
64
|
+
|
65
|
+
# Use vagrant-bindfs to re-mount folder
|
66
|
+
config.bindfs.bind_folder "/vagrant-nfs", "/vagrant"
|
67
|
+
|
68
|
+
end
|
69
69
|
```
|
70
70
|
|
71
71
|
|
72
72
|
### Supported options
|
73
73
|
|
74
|
-
`bind_folder` supports the following arguments
|
74
|
+
The `bind_folder` config supports the following long arguments, some of them are overwritable
|
75
|
+
with short options:
|
75
76
|
|
76
|
-
- `:
|
77
|
-
- `:
|
77
|
+
- `:force_user` (defaults to 'vagrant')
|
78
|
+
- `:force_group` (defaults to 'vagrant')
|
78
79
|
- `:perms` (defaults to 'u=rwX:g=rD:o=rD')
|
79
80
|
- `:mirror`
|
81
|
+
- `:mirror_only`
|
82
|
+
- `:map`
|
83
|
+
- `:create_for_user`
|
84
|
+
- `:create_for_group`
|
85
|
+
- `:create_with_perms`
|
86
|
+
- `:chmod_filter`
|
87
|
+
- `:read_rate`
|
88
|
+
- `:write_rate`
|
89
|
+
|
90
|
+
There are also options available for backward compatibility, if one of these options is defined
|
91
|
+
the newer counterpart will be unset:
|
92
|
+
|
93
|
+
- `:owner`
|
94
|
+
- `:group`
|
95
|
+
|
96
|
+
The following shortcuts are also available:
|
97
|
+
|
80
98
|
- `:o`
|
81
|
-
- `:
|
82
|
-
- `:
|
83
|
-
- `:
|
84
|
-
- `:
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
- `:
|
90
|
-
- `:
|
91
|
-
- `:
|
92
|
-
- `:
|
93
|
-
- `:
|
94
|
-
- `:
|
95
|
-
- `:
|
96
|
-
- `:
|
97
|
-
- `:
|
98
|
-
- `:
|
99
|
-
- `:
|
100
|
-
- `:
|
101
|
-
- `:
|
102
|
-
- `:
|
103
|
-
- `:
|
104
|
-
- `:
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
99
|
+
- `:u` (Overwrites the value of force_user)
|
100
|
+
- `:g` (Overwrites the value of force_group)
|
101
|
+
- `:m` (Overwrites the value of mirror)
|
102
|
+
- `:M` (Overwrites the value of mirror_only)
|
103
|
+
- `:p` (Overwrites the value of perms)
|
104
|
+
|
105
|
+
… and the following flags (all disabled by default, vagrant-bindfs rely on bindfs own defaults):
|
106
|
+
|
107
|
+
- `:create_as_user`
|
108
|
+
- `:create_as_mounter`
|
109
|
+
- `:chown_normal`
|
110
|
+
- `:chown_ignore`
|
111
|
+
- `:chown_deny`
|
112
|
+
- `:chgrp_normal`
|
113
|
+
- `:chgrp_ignore`
|
114
|
+
- `:chgrp_deny`
|
115
|
+
- `:chmod_normal`
|
116
|
+
- `:chmod_ignore`
|
117
|
+
- `:chmod_deny`
|
118
|
+
- `:chmod_allow_x`
|
119
|
+
- `:xattr_none`
|
120
|
+
- `:xattr_ro`
|
121
|
+
- `:xattr_rw`
|
122
|
+
- `:no_allow_other`
|
123
|
+
- `:realistic_permissions`
|
124
|
+
- `:ctime_from_mtime`
|
125
|
+
- `:hide_hard_links`
|
126
|
+
- `:multithreaded`
|
127
|
+
|
128
|
+
You can overwrite default options _via_ `config.bindfs.default_options`. See
|
129
|
+
[bindfs man page](http://bindfs.org/docs/bindfs.1.html) for details.
|
130
|
+
|
131
|
+
vagrant-bindfs does not check compatibility between given arguments but warn you when a binding
|
132
|
+
command fail or if bindfs is not installed on your virtual machine. On Debian and SUSE systems, it
|
133
|
+
will try to install bindfs automatically.
|
112
134
|
|
113
135
|
|
114
136
|
## Contributing
|
115
137
|
|
116
|
-
If you find this plugin useful, we could use a few enhancements!
|
117
|
-
|
138
|
+
If you find this plugin useful, we could use a few enhancements! In particular, capabilities files
|
139
|
+
for installing vagrant-bindfs on systems other than Debian or SUSE would be useful. We could also
|
140
|
+
use some specs…
|
118
141
|
|
119
142
|
|
120
143
|
### How to Test Changes
|
121
144
|
|
122
|
-
If you've made changes to this plugin, you can easily test it locally in vagrant.
|
123
|
-
|
145
|
+
If you've made changes to this plugin, you can easily test it locally in vagrant. From the root of
|
146
|
+
the repo, do:
|
124
147
|
|
125
148
|
- `bundle install`
|
126
149
|
- `rake build`
|
127
150
|
- `bundle exec vagrant up`
|
128
151
|
|
129
|
-
This will spin up a default Debian VM and try to bindfs-mount some shares in it.
|
130
|
-
|
152
|
+
This will spin up a default Debian VM and try to bindfs-mount some shares in it. Feel free to modify
|
153
|
+
the included `Vagrantfile` to add additional test cases.
|
data/lib/vagrant-bindfs.rb
CHANGED
@@ -4,19 +4,18 @@ rescue LoadError
|
|
4
4
|
raise "The Vagrant bindfs plugin must be run within Vagrant"
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require "vagrant-bindfs/plugin"
|
8
|
+
require "vagrant-bindfs/errors"
|
9
9
|
|
10
10
|
require "pathname"
|
11
11
|
|
12
12
|
module VagrantPlugins
|
13
13
|
module Bindfs
|
14
|
-
# Returns the path to the source of this plugin
|
15
14
|
def self.source_root
|
16
|
-
@source_root ||= Pathname.new(File.expand_path(
|
15
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
17
16
|
end
|
18
17
|
|
19
|
-
I18n.load_path << File.expand_path(
|
18
|
+
I18n.load_path << File.expand_path("locales/en.yml", source_root)
|
20
19
|
I18n.reload!
|
21
20
|
end
|
22
21
|
end
|
data/lib/vagrant-bindfs/bind.rb
CHANGED
@@ -2,45 +2,6 @@ module VagrantPlugins
|
|
2
2
|
module Bindfs
|
3
3
|
module Action
|
4
4
|
class Bind
|
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
|
-
# Shorthands
|
19
|
-
@@shorthands = {
|
20
|
-
:o => nil,
|
21
|
-
}
|
22
|
-
|
23
|
-
# Flags
|
24
|
-
@@flags = {
|
25
|
-
:'no-allow-other' => false,
|
26
|
-
:'create-as-user' => false,
|
27
|
-
:'create-as-mounter' => false,
|
28
|
-
:'chown-normal' => false,
|
29
|
-
:'chown-ignore' => false,
|
30
|
-
:'chown-deny' => false,
|
31
|
-
:'chgrp-normal' => false,
|
32
|
-
:'chgrp-ignore' => false,
|
33
|
-
:'chgrp-deny' => false,
|
34
|
-
:'chmod-normal' => false,
|
35
|
-
:'chmod-ignore' => false,
|
36
|
-
:'chmod-deny' => false,
|
37
|
-
:'chmod-allow-x' => false,
|
38
|
-
:'xattr-none' => false,
|
39
|
-
:'xattr-ro' => false,
|
40
|
-
:'xattr-rw' => false,
|
41
|
-
:'ctime-from-mtime' => false,
|
42
|
-
}
|
43
|
-
|
44
5
|
def initialize(app, env)
|
45
6
|
@app = app
|
46
7
|
@env = env
|
@@ -49,7 +10,7 @@ module VagrantPlugins
|
|
49
10
|
def call(env)
|
50
11
|
@app.call(env)
|
51
12
|
@env = env
|
52
|
-
|
13
|
+
|
53
14
|
@machine = env[:machine]
|
54
15
|
|
55
16
|
unless binded_folders.empty?
|
@@ -63,59 +24,198 @@ module VagrantPlugins
|
|
63
24
|
end
|
64
25
|
|
65
26
|
def default_options
|
66
|
-
|
27
|
+
current_defaults = @machine.config.bindfs.default_options
|
28
|
+
|
29
|
+
new_defaults = {}.tap do |new_default|
|
30
|
+
current_defaults.each do |key, value|
|
31
|
+
new_default[key.to_s.gsub("_", "-")] = value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
available_options.merge(
|
36
|
+
available_shortcuts
|
37
|
+
).merge(
|
38
|
+
available_flags
|
39
|
+
).merge(
|
40
|
+
new_defaults
|
41
|
+
)
|
67
42
|
end
|
68
|
-
|
69
|
-
def normalize_options
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
43
|
+
|
44
|
+
def normalize_options(current_options)
|
45
|
+
new_options = {}.tap do |new_option|
|
46
|
+
current_options.each do |key, value|
|
47
|
+
new_option[key.to_s.gsub("_", "-")] = value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
source = new_options.delete("source-path")
|
52
|
+
dest = new_options.delete("dest-path")
|
53
|
+
options = default_options.merge(new_options)
|
54
|
+
|
55
|
+
args = [].tap do |arg|
|
56
|
+
options.each do |key, value|
|
57
|
+
next if key == "force-user" and options.keys.include? "owner"
|
58
|
+
next if key == "force-user" and options.keys.include? "u"
|
59
|
+
|
60
|
+
next if key == "force-group" and options.keys.include? "group"
|
61
|
+
next if key == "force-group" and options.keys.include? "g"
|
62
|
+
|
63
|
+
next if key == "mirror" and options.keys.include? "m"
|
64
|
+
next if key == "mirror-only" and options.keys.include? "M"
|
65
|
+
next if key == "perms" and options.keys.include? "p"
|
66
|
+
|
67
|
+
if available_flags.keys.include? key
|
68
|
+
arg.push "--#{key}" if value
|
69
|
+
next
|
70
|
+
end
|
71
|
+
|
72
|
+
next if value.nil?
|
73
|
+
|
74
|
+
if available_shortcuts.keys.include?(key) or additional_shortcuts.keys.include?(key)
|
75
|
+
arg.push "-#{key} '#{value}'"
|
76
|
+
next
|
77
|
+
end
|
78
|
+
|
79
|
+
if available_options.keys.include?(key) or additional_options.keys.include?(key)
|
80
|
+
arg.push "--#{key}='#{value}'"
|
81
|
+
next
|
82
|
+
end
|
83
|
+
end
|
79
84
|
end
|
80
|
-
|
81
|
-
[
|
85
|
+
|
86
|
+
[
|
87
|
+
source,
|
88
|
+
dest,
|
89
|
+
args.join(" ")
|
90
|
+
]
|
82
91
|
end
|
83
92
|
|
84
93
|
def bind_folders
|
85
94
|
@env[:ui].info I18n.t("vagrant.config.bindfs.status.binding_all")
|
86
95
|
|
87
|
-
binded_folders.each do |id,
|
88
|
-
source, dest, args = normalize_options
|
89
|
-
|
90
|
-
|
96
|
+
binded_folders.each do |id, options|
|
97
|
+
source, dest, args = normalize_options(options)
|
98
|
+
|
99
|
+
bind_command = [
|
100
|
+
"bindfs",
|
101
|
+
args,
|
102
|
+
source,
|
103
|
+
dest
|
104
|
+
].compact
|
105
|
+
|
91
106
|
unless @machine.communicate.test("test -d #{source}")
|
92
|
-
@env[:ui].error
|
107
|
+
@env[:ui].error I18n.t(
|
108
|
+
"vagrant.config.bindfs.errors.source_path_not_exist",
|
109
|
+
path: source
|
110
|
+
)
|
111
|
+
|
93
112
|
next
|
94
113
|
end
|
95
114
|
|
96
|
-
if @machine.communicate.test("mount | grep bindfs | grep
|
97
|
-
@env[:ui].info
|
115
|
+
if @machine.communicate.test("mount | grep bindfs | grep #{dest}")
|
116
|
+
@env[:ui].info I18n.t(
|
117
|
+
"vagrant.config.bindfs.already_mounted",
|
118
|
+
dest: dest
|
119
|
+
)
|
120
|
+
|
98
121
|
next
|
99
122
|
end
|
100
123
|
|
101
|
-
@env[:ui].info I18n.t(
|
124
|
+
@env[:ui].info I18n.t(
|
125
|
+
"vagrant.config.bindfs.status.binding_entry",
|
126
|
+
dest: dest,
|
127
|
+
source: source
|
128
|
+
)
|
102
129
|
|
103
|
-
@machine.communicate.
|
104
|
-
|
130
|
+
@machine.communicate.tap do |comm|
|
131
|
+
comm.sudo("mkdir -p #{dest}")
|
132
|
+
|
133
|
+
comm.sudo(
|
134
|
+
bind_command.join(" "),
|
135
|
+
error_class: Error,
|
136
|
+
error_key: :binding_failed
|
137
|
+
)
|
138
|
+
end
|
105
139
|
end
|
106
140
|
end
|
107
141
|
|
108
142
|
def handle_bindfs_installation
|
109
|
-
|
110
|
-
@env[:ui].warn(I18n.t(
|
143
|
+
unless @machine.guest.capability(:bindfs_installed)
|
144
|
+
@env[:ui].warn(I18n.t("vagrant.config.bindfs.not_installed"))
|
111
145
|
|
112
|
-
|
146
|
+
unless @machine.guest.capability(:bindfs_install)
|
113
147
|
raise Vagrant::Bindfs::Error, :cannot_install
|
114
148
|
end
|
115
149
|
end
|
116
150
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
151
|
+
|
152
|
+
def available_options
|
153
|
+
@available_options ||= {
|
154
|
+
"force-user" => "vagrant",
|
155
|
+
"force-group" => "vagrant",
|
156
|
+
"perms" => "u=rwX:g=rD:o=rD",
|
157
|
+
"mirror" => nil,
|
158
|
+
"mirror-only" => nil,
|
159
|
+
"map" => nil,
|
160
|
+
"create-for-user" => nil,
|
161
|
+
"create-for-group" => nil,
|
162
|
+
"create-with-perms" => nil,
|
163
|
+
"chmod-filter" => nil,
|
164
|
+
"read-rate" => nil,
|
165
|
+
"write-rate" => nil
|
166
|
+
}.freeze
|
167
|
+
end
|
168
|
+
|
169
|
+
def additional_options
|
170
|
+
@additional_options ||= {
|
171
|
+
# only for old versions, this will result in an error
|
172
|
+
# if you try that within current bindfs versions!
|
173
|
+
"owner" => "vagrant",
|
174
|
+
"group" => "vagrant"
|
175
|
+
}.freeze
|
176
|
+
end
|
177
|
+
|
178
|
+
def available_shortcuts
|
179
|
+
@available_shortcuts ||= {
|
180
|
+
"o" => nil
|
181
|
+
}.freeze
|
182
|
+
end
|
183
|
+
|
184
|
+
def additional_shortcuts
|
185
|
+
@additional_shortcuts ||= {
|
186
|
+
"u" => nil, # overwrites the value of force-user
|
187
|
+
"g" => nil, # overwrites the value of force-group
|
188
|
+
"m" => nil, # overwrites the value of mirror
|
189
|
+
"M" => nil, # overwrites the value of mirror-only
|
190
|
+
"p" => nil # overwrites the value of perms
|
191
|
+
}.freeze
|
192
|
+
end
|
193
|
+
|
194
|
+
def available_flags
|
195
|
+
@available_flags ||= {
|
196
|
+
"create-as-user" => false,
|
197
|
+
"create-as-mounter" => false,
|
198
|
+
"chown-normal" => false,
|
199
|
+
"chown-ignore" => false,
|
200
|
+
"chown-deny" => false,
|
201
|
+
"chgrp-normal" => false,
|
202
|
+
"chgrp-ignore" => false,
|
203
|
+
"chgrp-deny" => false,
|
204
|
+
"chmod-normal" => false,
|
205
|
+
"chmod-ignore" => false,
|
206
|
+
"chmod-deny" => false,
|
207
|
+
"chmod-allow-x" => false,
|
208
|
+
"xattr-none" => false,
|
209
|
+
"xattr-ro" => false,
|
210
|
+
"xattr-rw" => false,
|
211
|
+
"no-allow-other" => false,
|
212
|
+
"realistic-permissions" => false,
|
213
|
+
"ctime-from-mtime" => false,
|
214
|
+
"hide-hard-links" => false,
|
215
|
+
"multithreaded" => false
|
216
|
+
}.freeze
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
@@ -6,13 +6,13 @@ module VagrantPlugins
|
|
6
6
|
|
7
7
|
def self.bindfs_install(machine)
|
8
8
|
machine.communicate.tap do |comm|
|
9
|
-
comm.sudo(
|
10
|
-
comm.sudo(
|
9
|
+
comm.sudo("apt-get update")
|
10
|
+
comm.sudo("apt-get install -y bindfs")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -5,11 +5,11 @@ module VagrantPlugins
|
|
5
5
|
module BindfsInstalled
|
6
6
|
|
7
7
|
def self.bindfs_installed(machine)
|
8
|
-
machine.communicate.test(
|
8
|
+
machine.communicate.test("bindfs --help")
|
9
9
|
end
|
10
10
|
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Bindfs
|
3
|
+
module Cap
|
4
|
+
module SUSE
|
5
|
+
module BindfsInstall
|
6
|
+
|
7
|
+
def self.bindfs_install(machine)
|
8
|
+
machine.communicate.tap do |comm|
|
9
|
+
comm.sudo("zypper -n install bindfs")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,65 +1,88 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'vagrant/errors'
|
3
|
+
require 'vagrant/util/template_renderer'
|
4
|
+
|
1
5
|
module VagrantPlugins
|
2
6
|
module Bindfs
|
3
|
-
class Config < Vagrant.plugin(
|
7
|
+
class Config < Vagrant.plugin("2", :config)
|
8
|
+
attr_accessor :default_options, :bind_folders
|
4
9
|
|
5
10
|
def initialize
|
6
|
-
@
|
7
|
-
@
|
8
|
-
end
|
11
|
+
@default_options = UNSET_VALUE
|
12
|
+
@bind_folders = {}
|
9
13
|
|
10
|
-
|
11
|
-
@__bind_folders
|
14
|
+
@logger = Log4r::Logger.new('vagrantplugins::bindfs::config')
|
12
15
|
end
|
13
16
|
|
14
|
-
def default_options(
|
15
|
-
@
|
17
|
+
def default_options(new_values = {})
|
18
|
+
@default_options = {} if @default_options == UNSET_VALUE
|
19
|
+
@default_options.merge! new_values
|
16
20
|
end
|
17
21
|
|
18
|
-
def bind_folder(source_path, dest_path, options =
|
19
|
-
options ||= {}
|
22
|
+
def bind_folder(source_path, dest_path, options = {})
|
20
23
|
options[:source_path] = source_path
|
21
24
|
options[:dest_path] = dest_path
|
22
25
|
|
23
|
-
@
|
26
|
+
@bind_folders[options[:dest_path]] = options
|
24
27
|
end
|
25
28
|
|
26
29
|
def merge(other)
|
27
30
|
super.tap do |result|
|
28
|
-
|
29
|
-
result.instance_variable_set(
|
30
|
-
:@__default_options, default_options(other.default_options))
|
31
|
+
result.default_options(default_options(other.default_options))
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
other_folders = other.instance_variable_get(:@__bind_folders)
|
33
|
+
new_folders = bind_folders.dup
|
34
|
+
other_folders = other.bind_folders
|
35
35
|
|
36
36
|
other_folders.each do |id, options|
|
37
37
|
new_folders[id] ||= {}
|
38
|
-
new_folders[id].merge!
|
38
|
+
new_folders[id].merge! options
|
39
39
|
end
|
40
40
|
|
41
|
-
result.
|
41
|
+
result.bind_folders = new_folders
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def finalize!
|
46
|
+
@default_options = {} if @default_options == UNSET_VALUE
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate!(machine)
|
50
|
+
finalize!
|
46
51
|
errors = []
|
47
52
|
|
48
|
-
|
53
|
+
bind_folders.each do |id, options|
|
49
54
|
next if options[:disabled]
|
50
55
|
|
56
|
+
if options[:dest_path].nil? or options[:source_path].nil?
|
57
|
+
errors << I18n.t(
|
58
|
+
"vagrant.config.bindfs.errors.no_path_supplied",
|
59
|
+
path: options[:dest_path]
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
51
63
|
if Pathname.new(options[:dest_path]).relative?
|
52
|
-
errors << I18n.t(
|
53
|
-
|
64
|
+
errors << I18n.t(
|
65
|
+
"vagrant.config.bindfs.errors.destination_path_relative",
|
66
|
+
path: options[:dest_path]
|
67
|
+
)
|
54
68
|
end
|
55
69
|
|
56
70
|
if Pathname.new(options[:source_path]).relative?
|
57
|
-
errors << I18n.t(
|
58
|
-
|
71
|
+
errors << I18n.t(
|
72
|
+
"vagrant.config.bindfs.errors.source_path_relative",
|
73
|
+
path: options[:source_path]
|
74
|
+
)
|
59
75
|
end
|
60
76
|
end
|
61
77
|
|
62
|
-
errors.
|
78
|
+
if errors.any?
|
79
|
+
rendered_errors = Vagrant::Util::TemplateRenderer.render(
|
80
|
+
'config/validation_failed',
|
81
|
+
errors: { 'vagrant-bindfs' => errors }
|
82
|
+
)
|
83
|
+
|
84
|
+
fail Vagrant::Errors::ConfigInvalid, errors: rendered_errors
|
85
|
+
end
|
63
86
|
end
|
64
87
|
end
|
65
88
|
end
|
@@ -8,26 +8,34 @@ module VagrantPlugins
|
|
8
8
|
DESC
|
9
9
|
|
10
10
|
config(:bindfs) do
|
11
|
-
require
|
11
|
+
require "vagrant-bindfs/config"
|
12
12
|
Config
|
13
13
|
end
|
14
14
|
|
15
15
|
guest_capability("debian", "bindfs_install") do
|
16
|
-
require
|
16
|
+
require "vagrant-bindfs/cap/debian/bindfs_install"
|
17
17
|
Cap::Debian::BindfsInstall
|
18
18
|
end
|
19
19
|
|
20
|
+
guest_capability("suse", "bindfs_install") do
|
21
|
+
require "vagrant-bindfs/cap/suse/bindfs_install"
|
22
|
+
Cap::SUSE::BindfsInstall
|
23
|
+
end
|
24
|
+
|
20
25
|
guest_capability("linux", "bindfs_installed") do
|
21
|
-
require
|
26
|
+
require "vagrant-bindfs/cap/linux/bindfs_installed"
|
22
27
|
Cap::Linux::BindfsInstalled
|
23
28
|
end
|
24
29
|
|
25
|
-
require
|
30
|
+
require "vagrant-bindfs/bind"
|
31
|
+
|
26
32
|
%w{up reload}.each do |action|
|
27
33
|
action_hook(:bindfs, "machine_action_#{action}".to_sym) do |hook|
|
28
|
-
target =
|
29
|
-
Vagrant::Action::Builtin::NFS
|
30
|
-
|
34
|
+
target = if Vagrant::Action::Builtin.const_defined? :NFS
|
35
|
+
Vagrant::Action::Builtin::NFS
|
36
|
+
else
|
37
|
+
Vagrant::Action::Builtin::SyncedFolders
|
38
|
+
end
|
31
39
|
|
32
40
|
hook.before(target, Action::Bind)
|
33
41
|
end
|
data/locales/en.yml
CHANGED
@@ -2,18 +2,19 @@ en:
|
|
2
2
|
vagrant:
|
3
3
|
config:
|
4
4
|
bindfs:
|
5
|
-
not_installed:
|
6
|
-
already_mounted: "
|
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
7
|
status:
|
8
|
-
binding_all:
|
9
|
-
binding_entry:
|
8
|
+
binding_all: "Creating bind mounts for selected devices"
|
9
|
+
binding_entry: "Creating bind mount from %{source} to %{dest}"
|
10
10
|
errors:
|
11
|
-
destination_path_relative: "
|
12
|
-
source_path_relative: "
|
13
|
-
source_path_not_exist: "
|
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
14
|
binding_failed: |-
|
15
|
-
bind command
|
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
|
15
|
+
The bind command `%{command}` failed to run!
|
19
16
|
|
17
|
+
Please check options values and compatibility. For a complete documentation,
|
18
|
+
run `sudo bindfs --help` on the VM.
|
19
|
+
|
20
|
+
You can see it online at http://www.cs.helsinki.fi/u/partel/bindfs_docs/bindfs.1.html.
|
metadata
CHANGED
@@ -1,65 +1,61 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-bindfs
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
-
|
6
|
+
authors:
|
7
|
+
- Gaël-Ian Havard
|
8
8
|
- Igor Serebryany
|
9
|
+
- Thomas Boerger
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2014-01-04 00:00:00 Z
|
13
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
description: A Vagrant plugin to automate bindfs mount in the VM. This allow you to
|
16
|
+
change owner, group and permissions on files and, for example, work around NFS share
|
17
|
+
permissions issues.
|
18
|
+
email:
|
18
19
|
- gaelian.havard@gmail.com
|
19
20
|
- igor.serebryany@airbnb.com
|
20
21
|
executables: []
|
21
|
-
|
22
22
|
extensions: []
|
23
|
-
|
24
23
|
extra_rdoc_files: []
|
25
|
-
|
26
|
-
files:
|
24
|
+
files:
|
27
25
|
- MIT-LICENSE
|
28
26
|
- README.md
|
29
27
|
- lib/vagrant-bindfs.rb
|
30
28
|
- lib/vagrant-bindfs/bind.rb
|
31
29
|
- lib/vagrant-bindfs/cap/debian/bindfs_install.rb
|
32
30
|
- lib/vagrant-bindfs/cap/linux/bindfs_installed.rb
|
31
|
+
- lib/vagrant-bindfs/cap/suse/bindfs_install.rb
|
33
32
|
- lib/vagrant-bindfs/config.rb
|
34
33
|
- lib/vagrant-bindfs/errors.rb
|
35
34
|
- lib/vagrant-bindfs/plugin.rb
|
36
35
|
- lib/vagrant-bindfs/version.rb
|
37
36
|
- locales/en.yml
|
38
37
|
homepage: https://github.com/gael-ian/vagrant-bindfs
|
39
|
-
licenses:
|
38
|
+
licenses:
|
40
39
|
- MIT
|
41
40
|
metadata: {}
|
42
|
-
|
43
41
|
post_install_message:
|
44
42
|
rdoc_options: []
|
45
|
-
|
46
|
-
require_paths:
|
43
|
+
require_paths:
|
47
44
|
- lib
|
48
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
-
|
51
|
-
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
57
55
|
requirements: []
|
58
|
-
|
59
56
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.2.
|
57
|
+
rubygems_version: 2.2.2
|
61
58
|
signing_key:
|
62
59
|
specification_version: 4
|
63
60
|
summary: A Vagrant plugin to automate bindfs mount in the VM
|
64
61
|
test_files: []
|
65
|
-
|