vagrant-sshfs 0.0.4 → 0.0.5.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e635dbf5bc509348d441188e6999f0c3f2112d2
4
- data.tar.gz: 390602f96bed49a4745c22f96e17550086c1cb20
3
+ metadata.gz: 8ecfea9cb249194e1e907464e021f17a49e5a876
4
+ data.tar.gz: ca924db4c82d1223c6ecd6caa93f8703d1001227
5
5
  SHA512:
6
- metadata.gz: b0e4854d3fb65f849a4e61aad7f1baa680fe7db6b3c6fc904fe23658e6571b3f7674bea843cf140473a0707959bad5fd7cdb490ac23a56193b0e414b3afd94ac
7
- data.tar.gz: bbce98be457d3b52513f86cfe8722dc3a73867b50f384a5fdb061417aff26a08a4ffa527aa46261999ef08b4006166a136a25bb1c018118ea8edcdc398428d57
6
+ metadata.gz: 1e10705226d1af4aab7033e44ccad80a12d0f09abe33aadea1ddbef0001ac3705f50856f48064e5b0ba4d789cbaef3a63304c0fe380603463c29d6125e360898
7
+ data.tar.gz: 16379fff339b38c6770f145db15919411d16f5fd4ee17cf0e444a33f035979ce7007130acd2b2e470e9b2839cdcc7c986010b0fc69c54cfab36a370f494d4223
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## vagrant-sshfs 0.0.5 ##
2
+
3
+ * Allows to disable the plugin to run on demand.
4
+
5
+ *Stéphane Klein*
6
+
7
+ * Allows to mount a host folder on the guest machine
8
+
9
+ *Adrian Olek*
10
+
1
11
  ## vagrant-sshfs 0.0.4 (March 5, 2014) ##
2
12
 
3
13
  * Allows to set a custom ssh username.
data/Gemfile.lock CHANGED
@@ -14,7 +14,7 @@ GIT
14
14
  PATH
15
15
  remote: .
16
16
  specs:
17
- vagrant-sshfs (0.0.2)
17
+ vagrant-sshfs (0.0.5.beta1)
18
18
 
19
19
  GEM
20
20
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -22,6 +22,34 @@ By default it will use the Vagrant ssh username. You can change that with the fo
22
22
 
23
23
  `config.sshfs.username = "theusername"`
24
24
 
25
+ The plugin is enabled by default, so it will run everytime the machine starts. In case that is not desired, you can disabled that with the following configuration:
26
+
27
+ `config.sshfs.enabled = false`
28
+
29
+ ## Issues
30
+
31
+ ### Connection reset by peer
32
+
33
+ In case you are getting "Connection reset by peer" errors, it might be the case that you already have a host configuration under your `~/.ssh/know_hosts` for the given ip, and you are using the same ip with a different machine. If that is the case, you can set a `StrictHostKeyChecking no` under that ip to skip the check:
34
+
35
+ ```
36
+ Host 127.0.0.1
37
+ StrictHostKeyChecking no
38
+ ```
39
+
40
+ ### Mounting on guest (box)
41
+
42
+ You need to have `sshfs` installed on guest machine and ssh server on host.
43
+
44
+ To mount a host folder on guest machine add a configuration like this:
45
+
46
+ config.sshfs.mount_on_guest = true
47
+ config.sshfs.paths = { "src" => "mountpoint" }
48
+ config.sshfs.host_addr = '10.0.2.2'
49
+
50
+ `src` is the source absolute path to the folder in the host machine, `mountpoint` is the folder in the guest. `src` can be an absolute path, or relative to the `Vagrantfile`.
51
+ `host_addr` is the host machine IP accessible from guest.
52
+
25
53
  ## Contributing
26
54
 
27
55
  If you have issues or ideas, please contribute! You can create an issue throught Github, or send a Pull Request.
data/Vagrantfile CHANGED
@@ -2,6 +2,7 @@ Vagrant.require_plugin "vagrant-sshfs"
2
2
 
3
3
  Vagrant.configure("2") do |config|
4
4
  config.vm.box = "precise64"
5
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
5
6
 
6
7
  config.sshfs.paths = { "/home/vagrant/src" => "mountpoint" }
7
8
  end
@@ -11,16 +11,47 @@ module Vagrant
11
11
  def mount!
12
12
  paths.each do |src, target|
13
13
  info("mounting", src: src, target: target)
14
- `sshfs -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key}`
14
+ mount(src, target)
15
15
  end
16
16
  end
17
17
 
18
- private
18
+ def mount
19
+ raise NotImplementedError
20
+ end
19
21
 
20
22
  def paths
21
23
  machine.config.sshfs.paths
22
24
  end
23
25
 
26
+ def machine
27
+ @env[:machine]
28
+ end
29
+
30
+ def info(key, *args)
31
+ @env[:ui].info(i18n("info.#{key}", *args))
32
+ end
33
+
34
+ def ask(key, *args)
35
+ @env[:ui].ask(i18n("ask.#{key}", *args), :new_line => true)
36
+ end
37
+
38
+ def error(key, *args)
39
+ @env[:ui].error(i18n("error.#{key}", *args))
40
+ raise Error, :base
41
+ end
42
+
43
+ def i18n(key, *args)
44
+ I18n.t("vagrant.config.sshfs.#{key}", *args)
45
+ end
46
+ end
47
+
48
+ class HostBuilder < Builder
49
+ private
50
+
51
+ def mount(src, target)
52
+ `sshfs -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key}`
53
+ end
54
+
24
55
  def ssh_info
25
56
  machine.ssh_info
26
57
  end
@@ -75,26 +106,33 @@ module Vagrant
75
106
  def target_folder(target)
76
107
  File.expand_path(target)
77
108
  end
109
+ end
78
110
 
79
- def machine
80
- @env[:machine]
81
- end
111
+ class GuestBuilder < Builder
112
+ private
82
113
 
83
- def info(key, *args)
84
- @env[:ui].info(i18n("info.#{key}", *args))
114
+ def mount(src, target)
115
+ source = File.expand_path(src)
116
+
117
+ status = machine.communicate.execute(
118
+ "echo \"#{password}\" | sshfs -o allow_other -o password_stdin #{username}@#{host}:#{source} #{target}",
119
+ :sudo => true, :error_check => false)
120
+
121
+ if status != 0
122
+ error('not_mounted', src: source, target: target)
123
+ end
85
124
  end
86
125
 
87
- def ask(key, *args)
88
- @env[:ui].ask(i18n("ask.#{key}", *args), :new_line => true)
126
+ def host
127
+ machine.config.sshfs.host_addr
89
128
  end
90
129
 
91
- def error(key, *args)
92
- @env[:ui].error(i18n("error.#{key}", *args))
93
- raise Error, :base
130
+ def username
131
+ `whoami`.strip
94
132
  end
95
133
 
96
- def i18n(key, *args)
97
- I18n.t("vagrant.config.sshfs.#{key}", *args)
134
+ def password
135
+ Shellwords.escape(@env[:ui].ask(i18n("ask.pass", :user => "#{username}@#{host}"), :echo => false))
98
136
  end
99
137
  end
100
138
 
@@ -105,7 +143,15 @@ module Vagrant
105
143
  end
106
144
 
107
145
  def call(env)
108
- Builder.new(env).mount!
146
+ get_builder(env).mount! if @machine.config.sshfs.enabled
147
+ end
148
+
149
+ def get_builder(env)
150
+ if @machine.config.sshfs.mount_on_guest
151
+ GuestBuilder.new(env)
152
+ else
153
+ HostBuilder.new(env)
154
+ end
109
155
  end
110
156
  end
111
157
  end
@@ -3,10 +3,14 @@ module Vagrant
3
3
  class Config < Vagrant.plugin(2, :config)
4
4
  attr_accessor :paths
5
5
  attr_accessor :username
6
+ attr_accessor :enabled
7
+ attr_accessor :mount_on_guest
8
+ attr_accessor :host_addr
6
9
 
7
10
  def initialize
8
11
  @paths = {}
9
12
  @username = nil
13
+ @enabled = true
10
14
  end
11
15
 
12
16
  def merge(other)
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module SshFS
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5.beta1"
4
4
  end
5
5
  end
data/lib/vagrant-sshfs.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  begin
2
2
  require "vagrant"
3
3
  rescue LoadError
4
- raise "The Vagrant bindfs plugin must be run within Vagrant"
4
+ raise "The Vagrant sshfs plugin must be run within Vagrant"
5
5
  end
6
6
 
7
7
  require "vagrant-sshfs/version"
data/locales/en.yml CHANGED
@@ -10,8 +10,10 @@ en:
10
10
  ask:
11
11
  create_src: "Source folder `%{src}` does not exist, create?"
12
12
  create_target: "Target folder `%{target}` does not exist, create?"
13
+ pass: "Password for `%{user}`:"
13
14
  error:
14
15
  base: "vagrant-sshfs failed and couldn't proceed"
15
16
  non_empty_target: "Non empty target folder `%{target}`"
16
17
  not_created_src: "Source folder `%{src}` was not created"
17
18
  not_created_target: "Target folder `%{target}` was not created"
19
+ not_mounted: "Error when mounting `%{src}` to `%{target}`"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-sshfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fabiokr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-05 00:00:00.000000000 Z
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,9 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ">="
78
+ - - ">"
79
79
  - !ruby/object:Gem::Version
80
- version: '0'
80
+ version: 1.3.1
81
81
  requirements: []
82
82
  rubyforge_project:
83
83
  rubygems_version: 2.1.11