vagrant-bindfs 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +54 -0
- data/lib/vagrant-bindfs/config.rb +25 -0
- data/lib/vagrant-bindfs/middleware.rb +103 -0
- data/lib/vagrant-bindfs/version.rb +3 -0
- data/lib/vagrant-bindfs.rb +9 -0
- data/lib/vagrant_init.rb +2 -0
- data/locales/en.yml +11 -0
- metadata +86 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Folken Laëneck
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# vagrant-bindfs
|
2
|
+
|
3
|
+
A Vagrant plugin to automate [bindfs](http://code.google.com/p/bindfs/) mount in the VM.
|
4
|
+
This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues.
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Vagrant-bindfs is distributed as a Ruby gem. You can install it as any other gem with `gem install vagrant-bindfs`
|
10
|
+
|
11
|
+
|
12
|
+
## Configure your VM
|
13
|
+
|
14
|
+
In your VagrantFile, you can use `config.bindfs.bind_folder` to configure folders that will be binded on VM startup.
|
15
|
+
Its basic syntax is `config.bindfs.bind_folder "source/dir", "mount/point"`.
|
16
|
+
|
17
|
+
bind_folder support following arguments...
|
18
|
+
|
19
|
+
- `:user` (defaults to 'vagrant')
|
20
|
+
- `:group` (defaults to 'vagrant')
|
21
|
+
- `:perms` (defaults to 'u=rwD:g=rD:o=rD')
|
22
|
+
- `:mirror`
|
23
|
+
- `:'mirror-only'`
|
24
|
+
- `:'no-allow-other'`
|
25
|
+
- `:'create-for-user'`
|
26
|
+
- `:'create-for-group'`
|
27
|
+
- `:'create-with-perms'`
|
28
|
+
|
29
|
+
... and following flags (all disabled by default, vagrant-bindfs rely on bindfs own defaults) :
|
30
|
+
|
31
|
+
- `:'create-as-user'`
|
32
|
+
- `:'create-as-mounter'`
|
33
|
+
- `:'chown-normal'`
|
34
|
+
- `:'chown-ignore'`
|
35
|
+
- `:'chown-deny'`
|
36
|
+
- `:'chgrp-normal'`
|
37
|
+
- `:'chgrp-ignore'`
|
38
|
+
- `:'chgrp-deny'`
|
39
|
+
- `:'chmod-normal'`
|
40
|
+
- `:'chmod-ignore'`
|
41
|
+
- `:'chmod-deny'`
|
42
|
+
- `:'chmod-allow-x'`
|
43
|
+
- `:'xattr-none'`
|
44
|
+
- `:'xattr-ro'`
|
45
|
+
- `:'xattr-rw'`
|
46
|
+
- `:'ctime-from-mtime'`
|
47
|
+
|
48
|
+
Ex: `config.bindfs.bind_folder "source/dir", "mount/point", :perms => "u=rw:g=r:o=r", :create_as_user => true`.
|
49
|
+
|
50
|
+
You can overwrite default options _via_ `config.bindfs.default_options`.
|
51
|
+
|
52
|
+
See [bindfs man page](http://www.cs.helsinki.fi/u/partel/bindfs_docs/bindfs.1.html) for details.
|
53
|
+
|
54
|
+
vagrant-bindfs does not check compatibility between given arguments but warn you when a binding command fail or when bindfs is not installed on your virtual machine.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VagrantBindfs
|
2
|
+
# A configuration class to configure defaults which are used for
|
3
|
+
# the `vagrant-bindfs` plugin.
|
4
|
+
class Config < Vagrant::Config::Base
|
5
|
+
configures :bindfs
|
6
|
+
|
7
|
+
attr_accessor :default_options
|
8
|
+
attr_reader :binded_folders
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@binded_folders = []
|
12
|
+
@default_options = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def bind_folder(path, bindpath, opts=nil)
|
16
|
+
@binded_folders << {
|
17
|
+
:path => path,
|
18
|
+
:bindpath => bindpath
|
19
|
+
}.merge(opts || {})
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate(errors)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,103 @@
|
|
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=rwD:g=rD:o=rD',
|
11
|
+
:mirror => nil,
|
12
|
+
:'mirror-only' => nil,
|
13
|
+
:'no-allow-other' => nil,
|
14
|
+
:'create-for-user' => nil,
|
15
|
+
:'create-for-group' => nil,
|
16
|
+
:'create-with-perms' => nil,
|
17
|
+
}
|
18
|
+
|
19
|
+
# Flags
|
20
|
+
@@flags = {
|
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
|
+
@env = env
|
46
|
+
@app.call(env)
|
47
|
+
bind_folders unless binded_folders.empty?
|
48
|
+
end
|
49
|
+
|
50
|
+
def binded_folders
|
51
|
+
@env.env.config.bindfs.binded_folders
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_options
|
55
|
+
@@options.merge(@@flags).merge(@env.env.config.bindfs.default_options || {})
|
56
|
+
end
|
57
|
+
|
58
|
+
def bind_folders
|
59
|
+
@env["vm"].ssh.execute do |ssh|
|
60
|
+
|
61
|
+
# Check if bindfs is installed on VM
|
62
|
+
begin
|
63
|
+
ssh.exec!("sudo bindfs --help")
|
64
|
+
rescue Vagrant::Errors::VagrantError => e
|
65
|
+
@env.ui.error e
|
66
|
+
@env.ui.error I18n.t("vagrant.actions.vm.bind_folders.bindfs_not_installed")
|
67
|
+
return
|
68
|
+
end
|
69
|
+
|
70
|
+
@env.ui.info I18n.t("vagrant.actions.vm.bind_folders.binding")
|
71
|
+
binded_folders.each do |opts|
|
72
|
+
|
73
|
+
path = opts.delete(:path)
|
74
|
+
bindpath = opts.delete(:bindpath)
|
75
|
+
opts = default_options.merge(opts)
|
76
|
+
|
77
|
+
args = []
|
78
|
+
opts.each do |key, value|
|
79
|
+
if @@flags.key?(key)
|
80
|
+
args << "--#{key.to_s}" if !!value
|
81
|
+
else
|
82
|
+
args << "--#{key.to_s}=#{value}" if !value.nil?
|
83
|
+
end
|
84
|
+
end
|
85
|
+
args = " #{args.join(" ")}"
|
86
|
+
|
87
|
+
begin
|
88
|
+
ssh.exec!("sudo mkdir -p #{bindpath}")
|
89
|
+
ssh.exec!("sudo bindfs#{args} #{path} #{bindpath}")
|
90
|
+
@env.ui.info I18n.t("vagrant.actions.vm.bind_folders.binding_entry",
|
91
|
+
:path => path,
|
92
|
+
:bindpath => bindpath
|
93
|
+
)
|
94
|
+
rescue Vagrant::Errors::VagrantError => e
|
95
|
+
@env.ui.error e
|
96
|
+
@env.ui.error I18n.t("vagrant.actions.vm.bind_folders.bindfs_command_fail")
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'vagrant-bindfs/config'
|
3
|
+
require 'vagrant-bindfs/middleware'
|
4
|
+
|
5
|
+
# Insert Bindfs before the NFS middleware in the ":start" Action stack
|
6
|
+
Vagrant::Action[:start].insert Vagrant::Action::VM::NFS, VagrantBindfs::Middleware
|
7
|
+
|
8
|
+
# Add custom translations to the load path
|
9
|
+
I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
|
data/lib/vagrant_init.rb
ADDED
data/locales/en.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
en:
|
2
|
+
vagrant:
|
3
|
+
actions:
|
4
|
+
vm:
|
5
|
+
bind_folders:
|
6
|
+
bindfs_not_installed: bindfs seems to not being installed on the virtual machine
|
7
|
+
binding: Binding folders...
|
8
|
+
binding_entry: "-- %{path} bind to %{bindpath}"
|
9
|
+
bindfs_command_fail: |-
|
10
|
+
Please check options values and compatibility.
|
11
|
+
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
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-bindfs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- "Folken La\xC3\xABneck"
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-02 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: vagrant
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 6
|
31
|
+
- 0
|
32
|
+
version: 0.6.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
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.
|
36
|
+
email:
|
37
|
+
- folken.laeneck@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- lib/vagrant-bindfs.rb
|
46
|
+
- lib/vagrant_init.rb
|
47
|
+
- lib/vagrant-bindfs/config.rb
|
48
|
+
- lib/vagrant-bindfs/middleware.rb
|
49
|
+
- lib/vagrant-bindfs/version.rb
|
50
|
+
- locales/en.yml
|
51
|
+
- README.md
|
52
|
+
- LICENSE.txt
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: https://github.com/folken-laeneck/vagrant-bindfs
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: A Vagrant plugin to automate bindfs mount in the VM
|
85
|
+
test_files: []
|
86
|
+
|