vagrant-sshfs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +23 -0
- data/README.md +27 -0
- data/Vagrantfile +7 -0
- data/lib/vagrant-sshfs/actions.rb +119 -0
- data/lib/vagrant-sshfs/config.rb +17 -0
- data/lib/vagrant-sshfs/errors.rb +7 -0
- data/lib/vagrant-sshfs/plugin.rb +17 -0
- data/lib/vagrant-sshfs/version.rb +5 -0
- data/lib/vagrant-sshfs.rb +22 -0
- data/locales/en.yml +17 -0
- data/vagrant-sshfs.gemspec +23 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9649700d1265ecdc898d9024e70bb09f8a305a3f
|
4
|
+
data.tar.gz: 247f6c8331af219fcb9851276a59f06ec5a8cf28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 550760e3094176dc379e85daef499d8086b32a054324733190f4bdc86d2bcf88698d363c86cf2814964eeec92515ef74c6f377742f3c883d959453155d031294
|
7
|
+
data.tar.gz: b067dbda53d44fafc86cf23f47f368c7d2b3773130015f8e1c7f3e4c7dea731d627ef45ceba766d3a5cc5297b863ea20cf52207e762d3d8c8120590f30552dcb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/mitchellh/vagrant.git
|
3
|
+
revision: 7e400d00a3c5a0fdf2809c8b5001a035415a607b
|
4
|
+
tag: v1.2.2
|
5
|
+
specs:
|
6
|
+
vagrant (1.2.2)
|
7
|
+
childprocess (~> 0.3.7)
|
8
|
+
erubis (~> 2.7.0)
|
9
|
+
i18n (~> 0.6.0)
|
10
|
+
json (>= 1.5.1, < 1.8.0)
|
11
|
+
log4r (~> 1.1.9)
|
12
|
+
net-scp (~> 1.1.0)
|
13
|
+
net-ssh (~> 2.6.6)
|
14
|
+
|
15
|
+
PATH
|
16
|
+
remote: .
|
17
|
+
specs:
|
18
|
+
vagrant-sshfs (0.0.1)
|
19
|
+
|
20
|
+
GEM
|
21
|
+
remote: https://rubygems.org/
|
22
|
+
specs:
|
23
|
+
childprocess (0.3.9)
|
24
|
+
ffi (~> 1.0, >= 1.0.11)
|
25
|
+
diff-lcs (1.2.4)
|
26
|
+
erubis (2.7.0)
|
27
|
+
ffi (1.9.0)
|
28
|
+
i18n (0.6.5)
|
29
|
+
json (1.7.7)
|
30
|
+
log4r (1.1.10)
|
31
|
+
net-scp (1.1.2)
|
32
|
+
net-ssh (>= 2.6.5)
|
33
|
+
net-ssh (2.6.8)
|
34
|
+
rake (10.1.0)
|
35
|
+
rspec (2.14.1)
|
36
|
+
rspec-core (~> 2.14.0)
|
37
|
+
rspec-expectations (~> 2.14.0)
|
38
|
+
rspec-mocks (~> 2.14.0)
|
39
|
+
rspec-core (2.14.5)
|
40
|
+
rspec-expectations (2.14.3)
|
41
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
42
|
+
rspec-mocks (2.14.3)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
bundler (~> 1.3)
|
49
|
+
rake
|
50
|
+
rspec
|
51
|
+
vagrant!
|
52
|
+
vagrant-sshfs!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2013 Fabio Kreusch
|
2
|
+
https://github.com/fabiokr/vagrant-sshfs
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# vagrant-sshfs
|
2
|
+
|
3
|
+
A Vagrant plugin to mount a folder from the box to the host using sshfs.
|
4
|
+
|
5
|
+
## Why
|
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 the a folder in the box with sshfs.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
`vagrant plugin install vagrant-sshfs`
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
In the `Vagrantfile`, add a configuration like this:
|
16
|
+
|
17
|
+
`config.sshfs.paths = { "src" => "mountpoint" }`
|
18
|
+
|
19
|
+
`src` is the source folder in the box, `mountpoint` is the folder in the host machine. `src` is relative to the vagrant use home folder, usually `/home/vagrant`. `mountpoint` is relative to the `Vagrantfile`.
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
If you have issues or ideas, please contribute! You can create an issue throught Github, or send a Pull Request.
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
To try this out, you can run `bundle exec vagrant up` from the source code checkout.
|
data/Vagrantfile
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module SshFS
|
5
|
+
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
|
+
`sshfs -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key}`
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def paths
|
21
|
+
machine.config.sshfs.paths
|
22
|
+
end
|
23
|
+
|
24
|
+
def ssh_info
|
25
|
+
machine.ssh_info
|
26
|
+
end
|
27
|
+
|
28
|
+
def username
|
29
|
+
ssh_info[:username]
|
30
|
+
end
|
31
|
+
|
32
|
+
def host
|
33
|
+
ssh_info[:host]
|
34
|
+
end
|
35
|
+
|
36
|
+
def port
|
37
|
+
ssh_info[:port]
|
38
|
+
end
|
39
|
+
|
40
|
+
def private_key
|
41
|
+
ssh_info[:private_key_path]
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_src!(src)
|
45
|
+
folder = src_folder(src)
|
46
|
+
|
47
|
+
unless machine.communicate.test("test -d #{folder}")
|
48
|
+
if ask("create_src", src: folder) == "y"
|
49
|
+
machine.communicate.execute("mkdir -p #{folder}")
|
50
|
+
info("created_src", src: folder)
|
51
|
+
else
|
52
|
+
error("not_created_src", src: folder)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
folder
|
57
|
+
end
|
58
|
+
|
59
|
+
def src_folder(src)
|
60
|
+
"/home/#{username}/#{src}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_target!(target)
|
64
|
+
folder = target_folder(target)
|
65
|
+
|
66
|
+
# entries return . and .. when empty
|
67
|
+
if File.exist?(folder) && Dir.entries(folder).size > 2
|
68
|
+
error("non_empty_target", target: folder)
|
69
|
+
elsif !File.exist?(folder)
|
70
|
+
if ask("create_target", target: folder) == "y"
|
71
|
+
FileUtils.mkdir_p(folder)
|
72
|
+
info("created_target", target: folder)
|
73
|
+
else
|
74
|
+
error("not_created_target", target: folder)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
folder
|
79
|
+
end
|
80
|
+
|
81
|
+
def target_folder(target)
|
82
|
+
File.expand_path(target)
|
83
|
+
end
|
84
|
+
|
85
|
+
def machine
|
86
|
+
@env[:machine]
|
87
|
+
end
|
88
|
+
|
89
|
+
def info(key, *args)
|
90
|
+
@env[:ui].info(i18n("info.#{key}", *args))
|
91
|
+
end
|
92
|
+
|
93
|
+
def ask(key, *args)
|
94
|
+
@env[:ui].ask(i18n("ask.#{key}", *args), :new_line => true)
|
95
|
+
end
|
96
|
+
|
97
|
+
def error(key, *args)
|
98
|
+
@env[:ui].error(i18n("error.#{key}", *args))
|
99
|
+
raise Error, :base
|
100
|
+
end
|
101
|
+
|
102
|
+
def i18n(key, *args)
|
103
|
+
I18n.t("vagrant.config.sshfs.#{key}", *args)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class Up
|
108
|
+
def initialize(app, env)
|
109
|
+
@app = app
|
110
|
+
@machine = env[:machine]
|
111
|
+
end
|
112
|
+
|
113
|
+
def call(env)
|
114
|
+
Builder.new(env).mount!
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module SshFS
|
3
|
+
class Config < Vagrant.plugin(2, :config)
|
4
|
+
attr_accessor :paths
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@paths = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def merge(other)
|
11
|
+
super.tap do |result|
|
12
|
+
result.paths = @paths.merge(other.paths)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module SshFS
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
4
|
+
name "vagrant-sshfs"
|
5
|
+
description "A Vagrant plugin that mounts sshfs in the host machine."
|
6
|
+
|
7
|
+
config "sshfs" do
|
8
|
+
require "vagrant-sshfs/config"
|
9
|
+
Config
|
10
|
+
end
|
11
|
+
|
12
|
+
action_hook(:sshfs, :machine_action_up) do |hook|
|
13
|
+
hook.append(Vagrant::SshFS::Actions::Up)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant bindfs plugin must be run within Vagrant"
|
5
|
+
end
|
6
|
+
|
7
|
+
require "vagrant-sshfs/version"
|
8
|
+
require "vagrant-sshfs/errors"
|
9
|
+
require "vagrant-sshfs/plugin"
|
10
|
+
require "vagrant-sshfs/actions"
|
11
|
+
|
12
|
+
module Vagrant
|
13
|
+
module SshFS
|
14
|
+
# Returns the path to the source of this plugin
|
15
|
+
def self.source_root
|
16
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
17
|
+
end
|
18
|
+
|
19
|
+
I18n.load_path << File.expand_path('locales/en.yml', source_root)
|
20
|
+
I18n.reload!
|
21
|
+
end
|
22
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
en:
|
2
|
+
vagrant:
|
3
|
+
config:
|
4
|
+
sshfs:
|
5
|
+
info:
|
6
|
+
mounting: "Mounting SSHFS for `%{src}` to `%{target}`"
|
7
|
+
unmounted: "Unmounted SSHFS for `%{target}`"
|
8
|
+
created_src: "Created src `%{src}`"
|
9
|
+
created_target: "Created target `%{target}`"
|
10
|
+
ask:
|
11
|
+
create_src: "Source folder `%{src}` does not exist, create?"
|
12
|
+
create_target: "Target folder `%{target}` does not exist, create?"
|
13
|
+
error:
|
14
|
+
base: "vagrant-sshfs failed and couldn't proceed"
|
15
|
+
non_empty_target: "Non empty target folder `%{target}`"
|
16
|
+
not_created_src: "Source folder `%{src}` was not created"
|
17
|
+
not_created_target: "Target folder `%{target}` was not created"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-sshfs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-sshfs"
|
8
|
+
spec.version = Vagrant::SshFS::VERSION
|
9
|
+
spec.authors = ["fabiokr"]
|
10
|
+
spec.email = ["fabiokr@gmail.com"]
|
11
|
+
spec.description = "A Vagrant plugin that mounts folders with sshfs in the host machine."
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/fabiokr/vagrant-sshfs"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-sshfs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- fabiokr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A Vagrant plugin that mounts folders with sshfs in the host machine.
|
42
|
+
email:
|
43
|
+
- fabiokr@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Vagrantfile
|
54
|
+
- lib/vagrant-sshfs.rb
|
55
|
+
- lib/vagrant-sshfs/actions.rb
|
56
|
+
- lib/vagrant-sshfs/config.rb
|
57
|
+
- lib/vagrant-sshfs/errors.rb
|
58
|
+
- lib/vagrant-sshfs/plugin.rb
|
59
|
+
- lib/vagrant-sshfs/version.rb
|
60
|
+
- locales/en.yml
|
61
|
+
- vagrant-sshfs.gemspec
|
62
|
+
homepage: https://github.com/fabiokr/vagrant-sshfs
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.1.3
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: A Vagrant plugin that mounts folders with sshfs in the host machine.
|
86
|
+
test_files: []
|
87
|
+
has_rdoc:
|