vagrant-sshfs 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,154 @@
1
+ require "vagrant/util/platform"
2
+
3
+ module VagrantPlugins
4
+ module SyncedFolderSSHFS
5
+ class SyncedFolder < Vagrant.plugin("2", :synced_folder)
6
+ @@vagrant_host_machine_ip
7
+
8
+ def initialize(*args)
9
+ super
10
+ @@vagrant_host_machine_ip = nil
11
+ end
12
+
13
+ # This is called early when the synced folder is set to determine
14
+ # if this implementation can be used for this machine. This should
15
+ # return true or false.
16
+ #
17
+ # @param [Machine] machine
18
+ # @param [Boolean] raise_error If true, should raise an exception
19
+ # if it isn't usable.
20
+ # @return [Boolean]
21
+ def usable?(machine, raise_error=false)
22
+ return true #for now
23
+ end
24
+
25
+ # This is called after the machine is booted and after networks
26
+ # are setup.
27
+ #
28
+ # This might be called with new folders while the machine is running.
29
+ # If so, then this should add only those folders without removing
30
+ # any existing ones.
31
+ #
32
+ # No return value.
33
+ def enable(machine, folders, sshfsopts)
34
+ if machine.guest.capability?(:sshfs_installed)
35
+ if !machine.guest.capability(:sshfs_installed)
36
+ can_install = machine.guest.capability?(:sshfs_install)
37
+ if !can_install
38
+ raise VagrantPlugins::SyncedFolderSSHFS::Errors::SSHFSNotInstalledInGuest
39
+ end
40
+ machine.ui.info(I18n.t("vagrant.sshfs.actions.installing"))
41
+ machine.guest.capability(:sshfs_install)
42
+ end
43
+ end
44
+
45
+ folders.each do |id, opts|
46
+
47
+ # If already mounted then there is nothing to do
48
+ if machine.guest.capability(:sshfs_is_folder_mounted, opts)
49
+ machine.ui.info(
50
+ I18n.t("vagrant.sshfs.info.already_mounted",
51
+ folder: opts[:guestpath]))
52
+ next
53
+ end
54
+
55
+ # Find out the host info and auth info for each folder
56
+ get_host_info(machine, opts)
57
+ get_auth_info(machine, opts)
58
+
59
+ # Do the mount
60
+ machine.ui.info(I18n.t("vagrant.sshfs.actions.mounting"))
61
+ machine.guest.capability(:sshfs_mount_folder, opts)
62
+ end
63
+ end
64
+
65
+ # This is called after destroying the machine during a
66
+ # `vagrant destroy` and also prior to syncing folders during
67
+ # a `vagrant up`.
68
+ #
69
+ # No return value.
70
+ #
71
+ # @param [Machine] machine
72
+ # @param [Hash] opts
73
+ def cleanup(machine, opts)
74
+ end
75
+
76
+ protected
77
+
78
+ def get_host_info(machine, opts)
79
+ # opts - the synced folder options hash
80
+ # machine -
81
+
82
+ # If the synced folder entry doesn't have host information in it then
83
+ # detect the vagrant host machine IP and use that
84
+ if not opts.has_key?(:ssh_host) or not opts[:ssh_host]
85
+ opts[:ssh_host] = detect_vagrant_host_ip(machine)
86
+ end
87
+
88
+ # If the synced folder doesn't have host port information in it
89
+ # default to port 22 for ssh
90
+ # detect the vagrant host machine IP and use that
91
+ if not opts.has_key?(:ssh_port) or not opts[:ssh_port]
92
+ opts[:ssh_port] = '22'
93
+ end
94
+ end
95
+
96
+ def detect_vagrant_host_ip(machine)
97
+ # Only run detection if it hasn't been run before
98
+ if not @@vagrant_host_machine_ip
99
+ # Attempt to detect host machine IP by connecting over ssh
100
+ # and then using the $SSH_CONNECTION env variable information to
101
+ # determine the vagrant host IP address
102
+ hostip = ''
103
+ machine.communicate.execute('echo $SSH_CONNECTION') do |type, data|
104
+ if type == :stdout
105
+ hostip = data.split()[0]
106
+ end
107
+ end
108
+ # TODO do some error checking here to make sure hostip was detected
109
+ machine.ui.info(I18n.t("vagrant.sshfs.info.detected_host_ip", ip: hostip))
110
+ @@vagrant_host_machine_ip = hostip
111
+ end
112
+ # Return the detected host IP
113
+ @@vagrant_host_machine_ip
114
+ end
115
+
116
+ def get_auth_info(machine, opts)
117
+ # opts - the synced folder options hash
118
+ # machine -
119
+ prompt_for_password = false
120
+ ssh_info = machine.ssh_info
121
+
122
+ # Detect the username of the current user
123
+ username = `whoami`.strip
124
+
125
+ # If no username provided then default to the current
126
+ # user that is executing vagrant
127
+ if not opts.has_key?(:ssh_username) or not opts[:ssh_username]
128
+ opts[:ssh_username] = username
129
+ end
130
+
131
+ # Check to see if we need to prompt the user for a password.
132
+ # We will prompt if:
133
+ # - User asked us to via prompt_for_password option
134
+ # - User did not provide a password in options and is not fwding ssh agent
135
+ #
136
+ if opts.has_key?(:prompt_for_password) and opts[:prompt_for_password]
137
+ prompt_for_password = opts[:prompt_for_password]
138
+ end
139
+ if not opts.has_key?(:ssh_password) or not opts[:ssh_password]
140
+ if not ssh_info.has_key?(:forward_agent) or not ssh_info[:forward_agent]
141
+ prompt_for_password = true
142
+ end
143
+ end
144
+
145
+ # Now do the prompt
146
+ if prompt_for_password
147
+ opts[:ssh_password] = machine.ui.ask(
148
+ I18n.t("vagrant.sshfs.ask.prompt_for_password", username: opts[:ssh_username]),
149
+ echo: false)
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
@@ -1,5 +1,5 @@
1
- module Vagrant
2
- module SshFS
3
- VERSION = "0.0.8"
1
+ module VagrantPlugins
2
+ module SyncedFolderSSHFS
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,46 @@
1
+ en:
2
+ vagrant:
3
+ sshfs:
4
+ actions:
5
+ installing: Installing SSHFS client...
6
+ mounting: Mounting SSHFS shared folders...
7
+ mounting_folder: |-
8
+ Mounting folder via SSHFS: %{hostpath} => %{guestpath}
9
+ ask:
10
+ prompt_for_password: |-
11
+ SSHFS password for '%{username}':
12
+ info:
13
+ detected_host_ip: |-
14
+ Detected host IP address is '%{ip}'
15
+ already_mounted: |-
16
+ The folder %{folder} in the guest already mounted.
17
+ errors:
18
+ communicator_not_ready: |-
19
+ The machine is reporting that it is not ready to communicate via ssh. Verify
20
+ this machine is properly running.
21
+ sshfs_not_in_guest: |-
22
+ The necessary SSHFS software is not installed in the guest.
23
+ install_failed_arch: |-
24
+ The install of the sshfs client software failed. On Arch this is most likely
25
+ because the package lists are not up to date [1] and partial upgrades are not
26
+ supported [2]. Please update your Arch system or install SSHFS manually.
27
+
28
+ [1] https://wiki.archlinux.org/index.php/pacman#Packages_cannot_be_retrieved_on_installation
29
+ [2] https://wiki.archlinux.org/index.php/System_maintenance#Partial_upgrades_are_unsupported
30
+ mount_failed: |-
31
+ Mounting SSHFS shared folders failed. This is most often caused by either
32
+ an SSH Daemon not running on the host or invalid credentials being provided.
33
+ Please make sure an SSH daemon is running on the host and proper credentials
34
+ were provided to be able to authenticate via SSH.
35
+
36
+ The command and output are:
37
+
38
+ %{command}
39
+
40
+ Stdout from the command:
41
+
42
+ %{stdout}
43
+
44
+ Stderr from the command:
45
+
46
+ %{stderr}
@@ -5,19 +5,22 @@ require 'vagrant-sshfs/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
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."
8
+ spec.version = VagrantPlugins::SyncedFolderSSHFS::VERSION
9
+ spec.authors = ["Dusty Mabe"]
10
+ spec.email = ["dusty@dustymabe.com"]
11
+ spec.description = """
12
+ A Vagrant synced folder plugin that mounts folders via SSHFS.
13
+ This is the successor to Fabio Kreusch's implementation:
14
+ https://github.com/fabiokr/vagrant-sshfs"""
12
15
  spec.summary = spec.description
13
- spec.homepage = "https://github.com/fabiokr/vagrant-sshfs"
14
- spec.license = "MIT"
16
+ spec.homepage = ""
17
+ spec.license = "GPL"
15
18
 
16
- spec.files = `git ls-files`.split($/)
19
+ spec.files = `git ls-files -z`.split("\x0")
17
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
22
  spec.require_paths = ["lib"]
20
23
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
23
26
  end
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.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - fabiokr
7
+ - Dusty Mabe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,57 +16,58 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
41
- description: A Vagrant plugin that mounts folders with sshfs in the host machine.
40
+ version: '10.0'
41
+ description: "\n A Vagrant synced folder plugin that mounts folders via SSHFS.
42
+ \n This is the successor to Fabio Kreusch's implementation:\n https://github.com/fabiokr/vagrant-sshfs"
42
43
  email:
43
- - fabiokr@gmail.com
44
+ - dusty@dustymabe.com
44
45
  executables: []
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
48
- - ".gitignore"
49
- - CHANGELOG.md
50
49
  - Gemfile
51
- - Gemfile.lock
52
- - LICENSE.txt
50
+ - LICENSE
53
51
  - README.md
54
- - Vagrantfile
52
+ - Rakefile
55
53
  - lib/vagrant-sshfs.rb
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
54
+ - lib/vagrant-sshfs/cap/arch/sshfs_client.rb
55
+ - lib/vagrant-sshfs/cap/debian/sshfs_client.rb
56
+ - lib/vagrant-sshfs/cap/fedora/sshfs_client.rb
57
+ - lib/vagrant-sshfs/cap/linux/sshfs_client.rb
58
+ - lib/vagrant-sshfs/cap/linux/sshfs_mount.rb
59
+ - lib/vagrant-sshfs/cap/redhat/sshfs_client.rb
60
+ - lib/vagrant-sshfs/cap/suse/sshfs_client.rb
60
61
  - lib/vagrant-sshfs/command.rb
61
- - lib/vagrant-sshfs/config.rb
62
62
  - lib/vagrant-sshfs/errors.rb
63
63
  - lib/vagrant-sshfs/plugin.rb
64
+ - lib/vagrant-sshfs/synced_folder.rb
64
65
  - lib/vagrant-sshfs/version.rb
65
- - locales/en.yml
66
+ - locales/synced_folder_sshfs.yml
66
67
  - vagrant-sshfs.gemspec
67
- homepage: https://github.com/fabiokr/vagrant-sshfs
68
+ homepage: ''
68
69
  licenses:
69
- - MIT
70
+ - GPL
70
71
  metadata: {}
71
72
  post_install_message:
72
73
  rdoc_options: []
@@ -84,9 +85,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  version: '0'
85
86
  requirements: []
86
87
  rubyforge_project:
87
- rubygems_version: 2.2.3
88
+ rubygems_version: 2.4.8
88
89
  signing_key:
89
90
  specification_version: 4
90
- summary: A Vagrant plugin that mounts folders with sshfs in the host machine.
91
+ summary: 'A Vagrant synced folder plugin that mounts folders via SSHFS. This is the
92
+ successor to Fabio Kreusch''s implementation: https://github.com/fabiokr/vagrant-sshfs'
91
93
  test_files: []
92
- has_rdoc:
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .bundle
2
- mountpoint
3
- .vagrant
4
- *.gem
5
- .idea
data/CHANGELOG.md DELETED
@@ -1,65 +0,0 @@
1
- ## vagrant-sshfs 0.0.8 (Jun 2, 2015) ##
2
-
3
- * Fixed unicode character issue
4
-
5
- *seasick*
6
-
7
- ## vagrant-sshfs 0.0.7 (Dec 8, 2014) ##
8
-
9
- * Smooth folders creation.
10
- * Unmount on machine Destroy/Halt/Suspend
11
- * Remount on machine Resume/Provision/Suspend
12
-
13
- *dmatora*
14
-
15
- ## vagrant-sshfs 0.0.6 (Oct 14, 2014) ##
16
-
17
- * Avoids StrictHostKeyChecking by default.
18
-
19
- *James O'Doherty*
20
-
21
- ## vagrant-sshfs 0.0.5 (May 26, 2014) ##
22
-
23
- * Allows to disable the plugin to run on demand.
24
-
25
- *Stéphane Klein*
26
-
27
- * Allows to mount a host folder on the guest machine
28
-
29
- *Adrian Olek*
30
-
31
- * Checks if the `sshfs` command is available
32
-
33
- *Fabio Kreusch*
34
-
35
- * Unmount/mount on vagrant reload
36
-
37
- *Fabio Kreusch*
38
-
39
- * Adds sshfs command
40
-
41
- *Fabio Kreusch*
42
-
43
- ## vagrant-sshfs 0.0.4 (March 5, 2014) ##
44
-
45
- * Allows to set a custom ssh username.
46
-
47
- *Daichi Nakajima*
48
-
49
- ## vagrant-sshfs 0.0.3 (December 15, 2013) ##
50
-
51
- * Uses an absolute source for the remote path.
52
-
53
- *Fabio Kreusch*
54
-
55
- ## vagrant-sshfs 0.0.2 (November 29, 2013) ##
56
-
57
- * Revoked on wrong push.
58
-
59
- *Fabio Kreusch*
60
-
61
- ## vagrant-sshfs 0.0.1 (September 27, 2013) ##
62
-
63
- * First release.
64
-
65
- *Fabio Kreusch*
data/Gemfile.lock DELETED
@@ -1,40 +0,0 @@
1
- GIT
2
- remote: git://github.com/mitchellh/vagrant.git
3
- revision: 059de113a705f84ff165a4df049d38a2abcc60a8
4
- tag: v1.4.0
5
- specs:
6
- vagrant (1.4.0)
7
- childprocess (~> 0.3.7)
8
- erubis (~> 2.7.0)
9
- i18n (~> 0.6.0)
10
- log4r (~> 1.1.9)
11
- net-scp (~> 1.1.0)
12
- net-ssh (>= 2.6.6, < 2.8.0)
13
-
14
- PATH
15
- remote: .
16
- specs:
17
- vagrant-sshfs (0.0.6)
18
-
19
- GEM
20
- remote: https://rubygems.org/
21
- specs:
22
- childprocess (0.3.9)
23
- ffi (~> 1.0, >= 1.0.11)
24
- erubis (2.7.0)
25
- ffi (1.9.3)
26
- i18n (0.6.9)
27
- log4r (1.1.10)
28
- net-scp (1.1.2)
29
- net-ssh (>= 2.6.5)
30
- net-ssh (2.7.0)
31
- rake (10.1.0)
32
-
33
- PLATFORMS
34
- ruby
35
-
36
- DEPENDENCIES
37
- bundler (~> 1.3)
38
- rake
39
- vagrant!
40
- vagrant-sshfs!