valkyrie-sshfs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 420048c4934d57d9d41eaec3a9187bed6969c693
4
+ data.tar.gz: 7af7b8d1a456e047805580439dbc73ecbae8cb8b
5
+ SHA512:
6
+ metadata.gz: e10544ed437af845a03e626ef9f32b122e0142594c30ffaa6d090d85568754f9647ed792777a337076c56da455f03b1186a909ae706bed464c132e8c26fd9b97
7
+ data.tar.gz: 613036cf94b83af0cd5f6aa19a94f8daf7273872e7e348b35250c4763a0345a488c29479b00c60d693a2c4462ec29454f518f996e33d8d00296b2813898a0d8c
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ mountpoint
3
+ .vagrant
4
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ ## vagrant-sshfs 0.0.6 (Oct 14, 2014) ##
2
+
3
+ * Avoids StrictHostKeyChecking by default.
4
+
5
+ *James O'Doherty*
6
+
7
+ ## vagrant-sshfs 0.0.5 (May 26, 2014) ##
8
+
9
+ * Allows to disable the plugin to run on demand.
10
+
11
+ *Stéphane Klein*
12
+
13
+ * Allows to mount a host folder on the guest machine
14
+
15
+ *Adrian Olek*
16
+
17
+ * Checks if the `sshfs` command is available
18
+
19
+ *Fabio Kreusch*
20
+
21
+ * Unmount/mount on vagrant reload
22
+
23
+ *Fabio Kreusch*
24
+
25
+ * Adds sshfs command
26
+
27
+ *Fabio Kreusch*
28
+
29
+ ## vagrant-sshfs 0.0.4 (March 5, 2014) ##
30
+
31
+ * Allows to set a custom ssh username.
32
+
33
+ *Daichi Nakajima*
34
+
35
+ ## vagrant-sshfs 0.0.3 (December 15, 2013) ##
36
+
37
+ * Uses an absolute source for the remote path.
38
+
39
+ *Fabio Kreusch*
40
+
41
+ ## vagrant-sshfs 0.0.2 (November 29, 2013) ##
42
+
43
+ * Revoked on wrong push.
44
+
45
+ *Fabio Kreusch*
46
+
47
+ ## vagrant-sshfs 0.0.1 (September 27, 2013) ##
48
+
49
+ * First release.
50
+
51
+ *Fabio Kreusch*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.4.0'
5
+ end
6
+
7
+ gemspec
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,64 @@
1
+ # valkyrie-sshfs
2
+
3
+ A Vagrant plugin to mount a folder from the box to the host (or vice-versa) using sshfs.
4
+
5
+ This is a fork of the vagrant-sshfs plugin, with a couple tweaks for use on
6
+ Valkyrie.
7
+
8
+ ## Why
9
+
10
+ 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 us since it limits one's ability to change file permissions and ownership. An alternative was to mount a folder in the host machine pointing to a folder in the box with sshfs.
11
+
12
+ ## Installation
13
+
14
+ `vagrant plugin install valkyrie-sshfs`
15
+
16
+ ## Usage
17
+
18
+ In the `Vagrantfile`, add a configuration like this:
19
+
20
+ `config.vsshfs.paths = { "src" => "mountpoint" }`
21
+
22
+ `src` is the source absolute path to the folder in the box, `mountpoint` is the folder in the host machine. `mountpoint` can be an absolute path, or relative to the `Vagrantfile`.
23
+
24
+ By default it will use the Vagrant ssh username. You can change that with the following:
25
+
26
+ `config.vsshfs.username = "theusername"`
27
+
28
+ 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:
29
+
30
+ `config.vsshfs.enabled = false`
31
+
32
+ To manually run it, you can use the `vsshfs` command. Please check `vagrant -h`.
33
+
34
+ ## Issues
35
+
36
+ ### Connection reset by peer
37
+
38
+ 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:
39
+
40
+ ```
41
+ Host 127.0.0.1
42
+ StrictHostKeyChecking no
43
+ ```
44
+
45
+ ### Mounting on guest (box)
46
+
47
+ You need to have `sshfs` installed on guest machine and ssh server on host.
48
+
49
+ To mount a host folder on guest machine add a configuration like this:
50
+
51
+ config.vsshfs.mount_on_guest = true
52
+ config.vsshfs.paths = { "src" => "mountpoint" }
53
+ config.vsshfs.host_addr = '10.0.2.2'
54
+
55
+ `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`.
56
+ `host_addr` is the host machine IP accessible from guest.
57
+
58
+ ## Contributing
59
+
60
+ If you have issues or ideas, please contribute! You can create an issue throught Github, or send a Pull Request.
61
+
62
+ ## Development
63
+
64
+ To try this out, you can run `bundle exec vagrant up` from the source code checkout.
data/Vagrantfile ADDED
@@ -0,0 +1,8 @@
1
+ Vagrant.require_plugin "valkyrie-sshfs"
2
+
3
+ Vagrant.configure("2") do |config|
4
+ config.vm.box = "precise64"
5
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
6
+
7
+ config.vsshfs.paths = { "/home/vagrant/src" => "mountpoint" }
8
+ end
@@ -0,0 +1,22 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Valkyrie SSHFS plugin must be run within Vagrant"
5
+ end
6
+
7
+ require "valkyrie-sshfs/errors"
8
+ require "valkyrie-sshfs/plugin"
9
+ require "valkyrie-sshfs/actions"
10
+ require "valkyrie-sshfs/command"
11
+
12
+ module Vagrant
13
+ module VSshFs
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
@@ -0,0 +1,31 @@
1
+ require 'valkyrie-sshfs/builders/base'
2
+ require 'valkyrie-sshfs/builders/host'
3
+ require 'valkyrie-sshfs/builders/guest'
4
+
5
+ module Vagrant
6
+ module VSshFs
7
+ module Actions
8
+ class Up
9
+ def initialize(app, env)
10
+ @machine = env[:machine]
11
+ end
12
+
13
+ def call(env)
14
+ get_builder(env).mount! if @machine.config.vsshfs.enabled
15
+ end
16
+
17
+ private
18
+
19
+ def get_builder(env)
20
+ if @machine.config.vsshfs.mount_on_guest
21
+ Builders::Guest.new(env[:machine], env[:ui])
22
+ else
23
+ Builders::Host.new(env[:machine], env[:ui])
24
+ end
25
+ end
26
+ end
27
+
28
+ class Reload < Up; end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,47 @@
1
+ module Vagrant
2
+ module VSshFs
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.vsshfs.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.vsshfs.#{key}", *args)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ module Vagrant
2
+ module VSshFs
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.vsshfs.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,89 @@
1
+ require 'fileutils'
2
+
3
+ module Vagrant
4
+ module VSshFs
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
+ extra_options = '-o reconnect -o idmap=user'
19
+ `#{sshfs_bin} #{extra_options} -p #{port} #{username}@#{host}:#{check_src!(src)} #{check_target!(target)} -o IdentityFile=#{private_key} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null `
20
+ end
21
+
22
+ def ssh_info
23
+ machine.ssh_info
24
+ end
25
+
26
+ def username
27
+ machine.config.vsshfs.username ||= ssh_info[:username]
28
+ end
29
+
30
+ def host
31
+ ssh_info[:host]
32
+ end
33
+
34
+ def port
35
+ ssh_info[:port]
36
+ end
37
+
38
+ def private_key
39
+ Array(ssh_info[:private_key_path]).first
40
+ end
41
+
42
+ def sshfs_bin
43
+ bin = `which sshfs`.chomp
44
+
45
+ if bin.empty?
46
+ error("bin_not_found")
47
+ else
48
+ bin
49
+ end
50
+ end
51
+
52
+ def check_src!(src)
53
+ unless machine.communicate.test("test -d #{src}")
54
+ if ask("create_src", src: src) == "y"
55
+ machine.communicate.execute("mkdir -p #{src}")
56
+ info("created_src", src: src)
57
+ else
58
+ error("not_created_src", src: src)
59
+ end
60
+ end
61
+
62
+ src
63
+ end
64
+
65
+ def check_target!(target)
66
+ folder = target_folder(target)
67
+
68
+ # entries return . and .. when empty
69
+ if File.exist?(folder) && Dir.entries(folder).size > 2
70
+ error("non_empty_target", target: folder)
71
+ elsif !File.exist?(folder)
72
+ if ask("create_target", target: folder)[0,1].downcase == "y"
73
+ FileUtils.mkdir_p(folder)
74
+ info("created_target", target: folder)
75
+ else
76
+ error("not_created_target", target: folder)
77
+ end
78
+ end
79
+
80
+ folder
81
+ end
82
+
83
+ def target_folder(target)
84
+ File.expand_path(target)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,27 @@
1
+ module Vagrant
2
+ module VSshFs
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.vsshfs.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
@@ -0,0 +1,23 @@
1
+ module Vagrant
2
+ module VSshFs
3
+ class Config < Vagrant.plugin(2, :config)
4
+ attr_accessor :paths
5
+ attr_accessor :username
6
+ attr_accessor :enabled
7
+ attr_accessor :mount_on_guest
8
+ attr_accessor :host_addr
9
+
10
+ def initialize
11
+ @paths = {}
12
+ @username = nil
13
+ @enabled = true
14
+ end
15
+
16
+ def merge(other)
17
+ super.tap do |result|
18
+ result.paths = @paths.merge(other.paths)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ module Vagrant
2
+ module VSshFs
3
+ class Error < Errors::VagrantError
4
+ error_namespace("vagrant.config.vsshfs.error")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ module Vagrant
2
+ module VSshFs
3
+ class Plugin < Vagrant.plugin("2")
4
+ name "valkyrie-sshfs"
5
+ description "A Vagrant plugin that mounts sshfs in the host machine."
6
+
7
+ config "vsshfs" do
8
+ require "valkyrie-sshfs/config"
9
+ Config
10
+ end
11
+
12
+ action_hook(:vsshfs, :machine_action_up) do |hook|
13
+ hook.append(Vagrant::VSshFs::Actions::Up)
14
+ end
15
+
16
+ action_hook(:vsshfs, :machine_action_reload) do |hook|
17
+ hook.append(Vagrant::VSshFs::Actions::Reload)
18
+ end
19
+
20
+ command "vsshfs" do
21
+ Vagrant::VSshFs::Command
22
+ end
23
+ end
24
+ end
25
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,21 @@
1
+ en:
2
+ vagrant:
3
+ config:
4
+ vsshfs:
5
+ info:
6
+ unmounting: "Unmounting SSHFS for `%{src}`"
7
+ mounting: "Mounting SSHFS for `%{src}` to `%{target}`"
8
+ unmounted: "Unmounted SSHFS for `%{target}`"
9
+ created_src: "Created src `%{src}`"
10
+ created_target: "Created target `%{target}`"
11
+ ask:
12
+ create_src: "Source folder `%{src}` does not exist, create?"
13
+ create_target: "Target folder `%{target}` does not exist, create? (y/n)"
14
+ pass: "Password for `%{user}`:"
15
+ error:
16
+ base: "valkyrie-sshfs failed and couldn't proceed"
17
+ non_empty_target: "Non empty target folder `%{target}`"
18
+ not_created_src: "Source folder `%{src}` was not created"
19
+ not_created_target: "Target folder `%{target}` was not created"
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."
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "valkyrie-sshfs"
5
+ spec.version = '0.0.1'
6
+ spec.authors = ["Christopher Gervais"]
7
+ spec.email = ["chris@poeticsystems.com"]
8
+ spec.description = "A Vagrant plugin that mounts folders with sshfs in the host machine. Adapted from vagrant-sshfs for use with Valkyrie."
9
+ spec.summary = "A Vagrant plugin that mounts folders with sshfs"
10
+ spec.homepage = "https://github.com/GetValkyrie/valkyrie-sshfs"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.3"
19
+ spec.add_development_dependency "rake", '~> 0'
20
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: valkyrie-sshfs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Gervais
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-18 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
+ Adapted from vagrant-sshfs for use with Valkyrie.
43
+ email:
44
+ - chris@poeticsystems.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Vagrantfile
55
+ - lib/valkyrie-sshfs.rb
56
+ - lib/valkyrie-sshfs/actions.rb
57
+ - lib/valkyrie-sshfs/builders/base.rb
58
+ - lib/valkyrie-sshfs/builders/guest.rb
59
+ - lib/valkyrie-sshfs/builders/host.rb
60
+ - lib/valkyrie-sshfs/command.rb
61
+ - lib/valkyrie-sshfs/config.rb
62
+ - lib/valkyrie-sshfs/errors.rb
63
+ - lib/valkyrie-sshfs/plugin.rb
64
+ - locales/en.yml
65
+ - valkyrie-sshfs.gemspec
66
+ homepage: https://github.com/GetValkyrie/valkyrie-sshfs
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.2.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: A Vagrant plugin that mounts folders with sshfs
90
+ test_files: []