vagrant-bindfs 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2010 Folken Laëneck
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2012 Folken Laëneck
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -11,8 +11,25 @@ Vagrant-bindfs is distributed as a Ruby gem. You can install it as any other gem
11
11
 
12
12
  ## Configure your VM
13
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"`.
14
+ In your VagrantFile, you can use `config.bindfs.bind_folder` to configure folders that will be binded on VM startup.
15
+
16
+ # In your Vagrantfile
17
+ Vagrant::Config.run do |config|
18
+
19
+ [...] # Your VM configuration
20
+
21
+ # Basic usage
22
+ config.bindfs.bind_folder "source/dir", "mount/point"
23
+
24
+ # Advanced options
25
+ config.bindfs.bind_folder "source/dir", "mount/point", :perms => "u=rw:g=r:o=r", :create_as_user => true
26
+
27
+ # Complete example for a NFS shared folder
28
+ config.vm.network :hostonly, "33.33.33.10" # (required to use NFS shared folder)
29
+ config.vm.share_folder "nfs-share", "/vagrant-nfs", "host/source/dir", :nfs => true
30
+ config.bindfs.bind_folder "/vagrant-nfs", "guest/mount/point"
31
+
32
+ end
16
33
 
17
34
  bind_folder support following arguments...
18
35
 
@@ -45,7 +62,7 @@ bind_folder support following arguments...
45
62
  - `:'xattr-rw'`
46
63
  - `:'ctime-from-mtime'`
47
64
 
48
- Ex: `config.bindfs.bind_folder "source/dir", "mount/point", :perms => "u=rw:g=r:o=r", :create_as_user => true`.
65
+ Ex: ``.
49
66
 
50
67
  You can overwrite default options _via_ `config.bindfs.default_options`.
51
68
 
@@ -2,24 +2,25 @@ module VagrantBindfs
2
2
  # A configuration class to configure defaults which are used for
3
3
  # the `vagrant-bindfs` plugin.
4
4
  class Config < Vagrant::Config::Base
5
- configures :bindfs
6
5
 
7
- attr_accessor :default_options
8
- attr_reader :binded_folders
9
-
10
- def initialize
11
- @binded_folders = []
12
- @default_options = nil
6
+ attr_writer :default_options,
7
+ :binded_folders
8
+
9
+ def default_options
10
+ @default_options || {}
11
+ end
12
+
13
+ def binded_folders
14
+ @binded_folders || []
13
15
  end
14
16
 
15
- def bind_folder(path, bindpath, opts=nil)
17
+ def bind_folder(path, bindpath, opts = {})
18
+ @binded_folders = [] unless instance_variable_defined?(:@binded_folders)
16
19
  @binded_folders << {
17
- :path => path,
20
+ :path => path,
18
21
  :bindpath => bindpath
19
- }.merge(opts || {})
20
- end
21
-
22
- def validate(errors)
22
+ }.merge(opts)
23
23
  end
24
+
24
25
  end
25
26
  end
@@ -0,0 +1,5 @@
1
+ module VagrantBindfs
2
+ class Error < Vagrant::Errors::VagrantError
3
+ error_namespace("vagrant.guest.linux.bindfs")
4
+ end
5
+ end
@@ -42,62 +42,51 @@ module VagrantBindfs
42
42
  end
43
43
 
44
44
  def call(env)
45
- @env = env
46
45
  @app.call(env)
47
- bind_folders unless binded_folders.empty?
46
+ @env = env
47
+
48
+ bind_folders if !binded_folders.empty? and bindfs_supported?
48
49
  end
49
50
 
50
51
  def binded_folders
51
- @env.env.config.bindfs.binded_folders
52
+ @env[:vm].config.bindfs.binded_folders
52
53
  end
53
54
 
54
55
  def default_options
55
- @@options.merge(@@flags).merge(@env.env.config.bindfs.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(" ")}" ]
56
76
  end
57
77
 
58
78
  def bind_folders
59
- @env["vm"].ssh.execute do |ssh|
79
+ @env[:ui].info I18n.t("vagrant.guest.linux.bindfs.status.binding")
80
+ binded_folders.each do |opts|
81
+
82
+ path, bindpath, args = normalize_options opts
60
83
 
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
84
+ @env[:vm].channel.sudo("mkdir -p #{bindpath}")
85
+ @env[:vm].channel.sudo("sudo bindfs#{args} #{path} #{bindpath}", :error_class => Error, :error_key => :bindfs_command_fail)
86
+ @env[:ui].info I18n.t("vagrant.guest.linux.bindfs.status.binding_entry", :path => path, :bindpath => bindpath)
69
87
 
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
88
  end
101
89
  end
90
+
102
91
  end
103
92
  end
@@ -1,3 +1,3 @@
1
1
  module VagrantBindfs
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -1,10 +1,14 @@
1
1
  require 'vagrant'
2
+ require 'vagrant-bindfs/error'
2
3
  require 'vagrant-bindfs/config'
3
4
  require 'vagrant-bindfs/middleware'
4
5
 
6
+ # Register Bindfs config
7
+ Vagrant.config_keys.register(:bindfs) { VagrantBindfs::Config }
8
+
5
9
  # Insert Bindfs before the NFS middleware in the ":start" and ":up" Action stack
6
- Vagrant::Action[:start].insert Vagrant::Action::VM::NFS, VagrantBindfs::Middleware
7
- Vagrant::Action[:up].insert Vagrant::Action::VM::NFS, VagrantBindfs::Middleware
10
+ Vagrant.actions[:start].insert Vagrant::Action::VM::NFS, VagrantBindfs::Middleware
11
+ Vagrant.actions[:up].insert Vagrant::Action::VM::NFS, VagrantBindfs::Middleware
8
12
 
9
13
  # Add custom translations to the load path
10
14
  I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
data/locales/en.yml CHANGED
@@ -1,11 +1,13 @@
1
1
  en:
2
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
3
+ guest:
4
+ linux:
5
+ bindfs:
6
+ errors:
7
+ not_installed: bindfs seems to not being installed on the virtual machine
8
+ bindfs_command_fail: |-
9
+ Please check options values and compatibility.
10
+ 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
11
+ status:
12
+ binding: Binding folders...
13
+ binding_entry: "-- %{path} bind to %{bindpath}"
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-bindfs
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 11
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 7
9
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Folken La\xC3\xABneck"
@@ -14,8 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-02-08 00:00:00 +01:00
18
- default_executable:
18
+ date: 2012-02-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: vagrant
@@ -25,11 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
+ hash: 51
28
29
  segments:
29
30
  - 0
30
- - 6
31
- - 0
32
- version: 0.6.0
31
+ - 9
32
+ - 4
33
+ version: 0.9.4
33
34
  type: :runtime
34
35
  version_requirements: *id001
35
36
  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.
@@ -42,15 +43,15 @@ extensions: []
42
43
  extra_rdoc_files: []
43
44
 
44
45
  files:
45
- - lib/vagrant-bindfs.rb
46
- - lib/vagrant_init.rb
46
+ - lib/vagrant-bindfs/version.rb
47
+ - lib/vagrant-bindfs/error.rb
47
48
  - lib/vagrant-bindfs/config.rb
48
49
  - lib/vagrant-bindfs/middleware.rb
49
- - lib/vagrant-bindfs/version.rb
50
+ - lib/vagrant_init.rb
51
+ - lib/vagrant-bindfs.rb
50
52
  - locales/en.yml
51
53
  - README.md
52
54
  - LICENSE.txt
53
- has_rdoc: true
54
55
  homepage: https://github.com/folken-laeneck/vagrant-bindfs
55
56
  licenses: []
56
57
 
@@ -64,6 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - ">="
66
67
  - !ruby/object:Gem::Version
68
+ hash: 3
67
69
  segments:
68
70
  - 0
69
71
  version: "0"
@@ -72,13 +74,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
74
  requirements:
73
75
  - - ">="
74
76
  - !ruby/object:Gem::Version
77
+ hash: 3
75
78
  segments:
76
79
  - 0
77
80
  version: "0"
78
81
  requirements: []
79
82
 
80
83
  rubyforge_project:
81
- rubygems_version: 1.3.7
84
+ rubygems_version: 1.8.6
82
85
  signing_key:
83
86
  specification_version: 3
84
87
  summary: A Vagrant plugin to automate bindfs mount in the VM