vagrant-sshfs 0.0.5.beta1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +13 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/vagrant-sshfs/actions.rb +9 -137
- data/lib/vagrant-sshfs/builders/base.rb +47 -0
- data/lib/vagrant-sshfs/builders/guest.rb +41 -0
- data/lib/vagrant-sshfs/builders/host.rb +88 -0
- data/lib/vagrant-sshfs/command.rb +27 -0
- data/lib/vagrant-sshfs/plugin.rb +8 -0
- data/lib/vagrant-sshfs/version.rb +1 -1
- data/lib/vagrant-sshfs.rb +1 -0
- data/locales/en.yml +3 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 921e3c064e20e4bcaea2002e138e70ba527521bf
|
4
|
+
data.tar.gz: d0028070356c7fe9d526d171ea7dd9658676ea6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0c4a7d229e4312a01004f39849f66039e71a060b44898cba3b8964ea3818cfa62dd9d10785e22625c020c3945b463afd92390cfa70059e7cd25260a4ef66fc5
|
7
|
+
data.tar.gz: 04be9b79e623f81d163fc3ec2491836a98959c30b4c2f355b8bf6c543db5c8628246129d2017670d5c5ae6c9ef4edbf8069906aaf21b3e111f15322556259f82
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## vagrant-sshfs 0.0.5 ##
|
1
|
+
## vagrant-sshfs 0.0.5 (May 26, 2014) ##
|
2
2
|
|
3
3
|
* Allows to disable the plugin to run on demand.
|
4
4
|
|
@@ -8,6 +8,18 @@
|
|
8
8
|
|
9
9
|
*Adrian Olek*
|
10
10
|
|
11
|
+
* Checks if the `sshfs` command is available
|
12
|
+
|
13
|
+
*Fabio Kreusch*
|
14
|
+
|
15
|
+
* Unmount/mount on vagrant reload
|
16
|
+
|
17
|
+
*Fabio Kreusch*
|
18
|
+
|
19
|
+
* Adds sshfs command
|
20
|
+
|
21
|
+
*Fabio Kreusch*
|
22
|
+
|
11
23
|
## vagrant-sshfs 0.0.4 (March 5, 2014) ##
|
12
24
|
|
13
25
|
* Allows to set a custom ssh username.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ A Vagrant plugin to mount a folder from the box to the host using sshfs.
|
|
4
4
|
|
5
5
|
## Why
|
6
6
|
|
7
|
-
Common solutions for sharing folders with Vagrant include synced folder, which is pretty slow when dealing with many files, and NFS. NFS didn't work for me because of encrypted disk restrictions. An alternative was to mount a folder in the host machine pointing
|
7
|
+
Common solutions for sharing folders with Vagrant include synced folder, which is pretty slow when dealing with many files, and NFS. NFS didn't work for me because of encrypted disk restrictions. An alternative was to mount a folder in the host machine pointing to a folder in the box with sshfs.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -26,6 +26,8 @@ The plugin is enabled by default, so it will run everytime the machine starts. I
|
|
26
26
|
|
27
27
|
`config.sshfs.enabled = false`
|
28
28
|
|
29
|
+
To manually run it, you can use the `sshfs` command. Please check `vagrant -h`.
|
30
|
+
|
29
31
|
## Issues
|
30
32
|
|
31
33
|
### Connection reset by peer
|
@@ -1,144 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'vagrant-sshfs/builders/base'
|
2
|
+
require 'vagrant-sshfs/builders/host'
|
3
|
+
require 'vagrant-sshfs/builders/guest'
|
2
4
|
|
3
5
|
module Vagrant
|
4
6
|
module SshFS
|
5
7
|
module Actions
|
6
|
-
class Builder
|
7
|
-
def initialize(env)
|
8
|
-
@env = env
|
9
|
-
end
|
10
|
-
|
11
|
-
def mount!
|
12
|
-
paths.each do |src, target|
|
13
|
-
info("mounting", src: src, target: target)
|
14
|
-
mount(src, target)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def mount
|
19
|
-
raise NotImplementedError
|
20
|
-
end
|
21
|
-
|
22
|
-
def paths
|
23
|
-
machine.config.sshfs.paths
|
24
|
-
end
|
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
|
-
|
55
|
-
def ssh_info
|
56
|
-
machine.ssh_info
|
57
|
-
end
|
58
|
-
|
59
|
-
def username
|
60
|
-
machine.config.sshfs.username ||= ssh_info[:username]
|
61
|
-
end
|
62
|
-
|
63
|
-
def host
|
64
|
-
ssh_info[:host]
|
65
|
-
end
|
66
|
-
|
67
|
-
def port
|
68
|
-
ssh_info[:port]
|
69
|
-
end
|
70
|
-
|
71
|
-
def private_key
|
72
|
-
Array(ssh_info[:private_key_path]).first
|
73
|
-
end
|
74
|
-
|
75
|
-
def check_src!(src)
|
76
|
-
unless machine.communicate.test("test -d #{src}")
|
77
|
-
if ask("create_src", src: src) == "y"
|
78
|
-
machine.communicate.execute("mkdir -p #{src}")
|
79
|
-
info("created_src", src: src)
|
80
|
-
else
|
81
|
-
error("not_created_src", src: src)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
src
|
86
|
-
end
|
87
|
-
|
88
|
-
def check_target!(target)
|
89
|
-
folder = target_folder(target)
|
90
|
-
|
91
|
-
# entries return . and .. when empty
|
92
|
-
if File.exist?(folder) && Dir.entries(folder).size > 2
|
93
|
-
error("non_empty_target", target: folder)
|
94
|
-
elsif !File.exist?(folder)
|
95
|
-
if ask("create_target", target: folder) == "y"
|
96
|
-
FileUtils.mkdir_p(folder)
|
97
|
-
info("created_target", target: folder)
|
98
|
-
else
|
99
|
-
error("not_created_target", target: folder)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
folder
|
104
|
-
end
|
105
|
-
|
106
|
-
def target_folder(target)
|
107
|
-
File.expand_path(target)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class GuestBuilder < Builder
|
112
|
-
private
|
113
|
-
|
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
|
124
|
-
end
|
125
|
-
|
126
|
-
def host
|
127
|
-
machine.config.sshfs.host_addr
|
128
|
-
end
|
129
|
-
|
130
|
-
def username
|
131
|
-
`whoami`.strip
|
132
|
-
end
|
133
|
-
|
134
|
-
def password
|
135
|
-
Shellwords.escape(@env[:ui].ask(i18n("ask.pass", :user => "#{username}@#{host}"), :echo => false))
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
8
|
class Up
|
140
9
|
def initialize(app, env)
|
141
|
-
@app = app
|
142
10
|
@machine = env[:machine]
|
143
11
|
end
|
144
12
|
|
@@ -146,14 +14,18 @@ module Vagrant
|
|
146
14
|
get_builder(env).mount! if @machine.config.sshfs.enabled
|
147
15
|
end
|
148
16
|
|
17
|
+
private
|
18
|
+
|
149
19
|
def get_builder(env)
|
150
20
|
if @machine.config.sshfs.mount_on_guest
|
151
|
-
|
21
|
+
Builders::Guest.new(env[:machine], env[:ui])
|
152
22
|
else
|
153
|
-
|
23
|
+
Builders::Host.new(env[:machine], env[:ui])
|
154
24
|
end
|
155
25
|
end
|
156
26
|
end
|
27
|
+
|
28
|
+
class Reload < Up; end
|
157
29
|
end
|
158
30
|
end
|
159
31
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module SshFS
|
3
|
+
module Builders
|
4
|
+
class Base
|
5
|
+
attr_reader :machine, :ui
|
6
|
+
|
7
|
+
def initialize(machine, ui)
|
8
|
+
@machine, @ui = machine, ui
|
9
|
+
end
|
10
|
+
|
11
|
+
def mount!
|
12
|
+
paths.each do |src, target|
|
13
|
+
info("unmounting", src: target)
|
14
|
+
unmount(target)
|
15
|
+
info("mounting", src: src, target: target)
|
16
|
+
mount(src, target)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def mount
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
def paths
|
25
|
+
machine.config.sshfs.paths
|
26
|
+
end
|
27
|
+
|
28
|
+
def info(key, *args)
|
29
|
+
ui.info(i18n("info.#{key}", *args))
|
30
|
+
end
|
31
|
+
|
32
|
+
def ask(key, *args)
|
33
|
+
ui.ask(i18n("ask.#{key}", *args), :new_line => true)
|
34
|
+
end
|
35
|
+
|
36
|
+
def error(key, *args)
|
37
|
+
ui.error(i18n("error.#{key}", *args))
|
38
|
+
raise Error, :base
|
39
|
+
end
|
40
|
+
|
41
|
+
def i18n(key, *args)
|
42
|
+
I18n.t("vagrant.config.sshfs.#{key}", *args)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module SshFS
|
3
|
+
module Builders
|
4
|
+
class Guest < Base
|
5
|
+
private
|
6
|
+
|
7
|
+
def unmount(target)
|
8
|
+
if machine.communicate.execute("which fusermount", error_check: false) == 0
|
9
|
+
machine.communicate.execute("fusermount -u -q #{target}", error_check: false)
|
10
|
+
else
|
11
|
+
machine.communicate.execute("umount #{target}", error_check: false)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def mount(src, target)
|
16
|
+
source = File.expand_path(src)
|
17
|
+
|
18
|
+
status = machine.communicate.execute(
|
19
|
+
"echo \"#{password}\" | sshfs -o allow_other -o password_stdin #{username}@#{host}:#{source} #{target}",
|
20
|
+
:sudo => true, :error_check => false)
|
21
|
+
|
22
|
+
if status != 0
|
23
|
+
error('not_mounted', src: source, target: target)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def host
|
28
|
+
machine.config.sshfs.host_addr
|
29
|
+
end
|
30
|
+
|
31
|
+
def username
|
32
|
+
`whoami`.strip
|
33
|
+
end
|
34
|
+
|
35
|
+
def password
|
36
|
+
Shellwords.escape(ui.ask(i18n("ask.pass", :user => "#{username}@#{host}"), :echo => false))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module SshFS
|
5
|
+
module Builders
|
6
|
+
class Host < Base
|
7
|
+
private
|
8
|
+
|
9
|
+
def unmount(target)
|
10
|
+
if `which fusermount`.empty?
|
11
|
+
`umount #{target}`
|
12
|
+
else
|
13
|
+
`fusermount -u -q #{target}`
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def mount(src, target)
|
18
|
+
`#{sshfs_bin} -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key}`
|
19
|
+
end
|
20
|
+
|
21
|
+
def ssh_info
|
22
|
+
machine.ssh_info
|
23
|
+
end
|
24
|
+
|
25
|
+
def username
|
26
|
+
machine.config.sshfs.username ||= ssh_info[:username]
|
27
|
+
end
|
28
|
+
|
29
|
+
def host
|
30
|
+
ssh_info[:host]
|
31
|
+
end
|
32
|
+
|
33
|
+
def port
|
34
|
+
ssh_info[:port]
|
35
|
+
end
|
36
|
+
|
37
|
+
def private_key
|
38
|
+
Array(ssh_info[:private_key_path]).first
|
39
|
+
end
|
40
|
+
|
41
|
+
def sshfs_bin
|
42
|
+
bin = `which sshfs`.chomp
|
43
|
+
|
44
|
+
if bin.empty?
|
45
|
+
error("bin_not_found")
|
46
|
+
else
|
47
|
+
bin
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_src!(src)
|
52
|
+
unless machine.communicate.test("test -d #{src}")
|
53
|
+
if ask("create_src", src: src) == "y"
|
54
|
+
machine.communicate.execute("mkdir -p #{src}")
|
55
|
+
info("created_src", src: src)
|
56
|
+
else
|
57
|
+
error("not_created_src", src: src)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
src
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_target!(target)
|
65
|
+
folder = target_folder(target)
|
66
|
+
|
67
|
+
# entries return . and .. when empty
|
68
|
+
if File.exist?(folder) && Dir.entries(folder).size > 2
|
69
|
+
error("non_empty_target", target: folder)
|
70
|
+
elsif !File.exist?(folder)
|
71
|
+
if ask("create_target", target: folder) == "y"
|
72
|
+
FileUtils.mkdir_p(folder)
|
73
|
+
info("created_target", target: folder)
|
74
|
+
else
|
75
|
+
error("not_created_target", target: folder)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
folder
|
80
|
+
end
|
81
|
+
|
82
|
+
def target_folder(target)
|
83
|
+
File.expand_path(target)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module SshFS
|
3
|
+
class Command < Vagrant.plugin(2, :command)
|
4
|
+
def self.synopsis
|
5
|
+
"mounts sshfs shared folders"
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute
|
9
|
+
with_target_vms do |machine|
|
10
|
+
get_builder(machine).mount!
|
11
|
+
end
|
12
|
+
|
13
|
+
0
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def get_builder(machine)
|
19
|
+
if machine.config.sshfs.mount_on_guest
|
20
|
+
Builders::Guest.new(machine, @env.ui)
|
21
|
+
else
|
22
|
+
Builders::Host.new(machine, @env.ui)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/vagrant-sshfs/plugin.rb
CHANGED
@@ -12,6 +12,14 @@ module Vagrant
|
|
12
12
|
action_hook(:sshfs, :machine_action_up) do |hook|
|
13
13
|
hook.append(Vagrant::SshFS::Actions::Up)
|
14
14
|
end
|
15
|
+
|
16
|
+
action_hook(:sshfs, :machine_action_reload) do |hook|
|
17
|
+
hook.append(Vagrant::SshFS::Actions::Reload)
|
18
|
+
end
|
19
|
+
|
20
|
+
command "sshfs" do
|
21
|
+
Vagrant::SshFS::Command
|
22
|
+
end
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/vagrant-sshfs.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -3,6 +3,7 @@ en:
|
|
3
3
|
config:
|
4
4
|
sshfs:
|
5
5
|
info:
|
6
|
+
unmounting: "Unmounting SSHFS for `%{src}`"
|
6
7
|
mounting: "Mounting SSHFS for `%{src}` to `%{target}`"
|
7
8
|
unmounted: "Unmounted SSHFS for `%{target}`"
|
8
9
|
created_src: "Created src `%{src}`"
|
@@ -16,4 +17,5 @@ en:
|
|
16
17
|
non_empty_target: "Non empty target folder `%{target}`"
|
17
18
|
not_created_src: "Source folder `%{src}` was not created"
|
18
19
|
not_created_target: "Target folder `%{target}` was not created"
|
19
|
-
not_mounted: "Error when mounting `%{src}` to `%{target}`"
|
20
|
+
not_mounted: "Error when mounting `%{src}` to `%{target}`"
|
21
|
+
bin_not_found: "Could not find sshfs bin in the host machine. Please make sure it is installed."
|
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.5
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fabiokr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,6 +54,10 @@ files:
|
|
54
54
|
- Vagrantfile
|
55
55
|
- lib/vagrant-sshfs.rb
|
56
56
|
- lib/vagrant-sshfs/actions.rb
|
57
|
+
- lib/vagrant-sshfs/builders/base.rb
|
58
|
+
- lib/vagrant-sshfs/builders/guest.rb
|
59
|
+
- lib/vagrant-sshfs/builders/host.rb
|
60
|
+
- lib/vagrant-sshfs/command.rb
|
57
61
|
- lib/vagrant-sshfs/config.rb
|
58
62
|
- lib/vagrant-sshfs/errors.rb
|
59
63
|
- lib/vagrant-sshfs/plugin.rb
|
@@ -75,12 +79,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
79
|
version: '0'
|
76
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
81
|
requirements:
|
78
|
-
- - "
|
82
|
+
- - ">="
|
79
83
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
84
|
+
version: '0'
|
81
85
|
requirements: []
|
82
86
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.2.2
|
84
88
|
signing_key:
|
85
89
|
specification_version: 4
|
86
90
|
summary: A Vagrant plugin that mounts folders with sshfs in the host machine.
|