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.
- checksums.yaml +4 -4
- data/Gemfile +10 -3
- data/LICENSE +340 -0
- data/README.md +116 -34
- data/Rakefile +2 -0
- data/lib/vagrant-sshfs.rb +4 -6
- data/lib/vagrant-sshfs/cap/arch/sshfs_client.rb +29 -0
- data/lib/vagrant-sshfs/cap/debian/sshfs_client.rb +15 -0
- data/lib/vagrant-sshfs/cap/fedora/sshfs_client.rb +15 -0
- data/lib/vagrant-sshfs/cap/linux/sshfs_client.rb +11 -0
- data/lib/vagrant-sshfs/cap/linux/sshfs_mount.rb +90 -0
- data/lib/vagrant-sshfs/cap/redhat/sshfs_client.rb +36 -0
- data/lib/vagrant-sshfs/cap/suse/sshfs_client.rb +15 -0
- data/lib/vagrant-sshfs/command.rb +37 -17
- data/lib/vagrant-sshfs/errors.rb +19 -4
- data/lib/vagrant-sshfs/plugin.rb +63 -23
- data/lib/vagrant-sshfs/synced_folder.rb +154 -0
- data/lib/vagrant-sshfs/version.rb +3 -3
- data/locales/synced_folder_sshfs.yml +46 -0
- data/vagrant-sshfs.gemspec +12 -9
- metadata +28 -27
- data/.gitignore +0 -5
- data/CHANGELOG.md +0 -65
- data/Gemfile.lock +0 -40
- data/LICENSE.txt +0 -23
- data/Vagrantfile +0 -8
- data/lib/vagrant-sshfs/actions.rb +0 -43
- data/lib/vagrant-sshfs/builders/base.rb +0 -54
- data/lib/vagrant-sshfs/builders/guest.rb +0 -41
- data/lib/vagrant-sshfs/builders/host.rb +0 -93
- data/lib/vagrant-sshfs/config.rb +0 -27
- data/locales/en.yml +0 -21
data/LICENSE.txt
DELETED
@@ -1,23 +0,0 @@
|
|
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/Vagrantfile
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'vagrant-sshfs/builders/base'
|
2
|
-
require 'vagrant-sshfs/builders/host'
|
3
|
-
require 'vagrant-sshfs/builders/guest'
|
4
|
-
|
5
|
-
module Vagrant
|
6
|
-
module SshFS
|
7
|
-
module Actions
|
8
|
-
class Base
|
9
|
-
def initialize(app, env)
|
10
|
-
@machine = env[:machine]
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def get_builder(env)
|
16
|
-
if @machine.config.sshfs.mount_on_guest
|
17
|
-
Builders::Guest.new(env[:machine], env[:ui])
|
18
|
-
else
|
19
|
-
Builders::Host.new(env[:machine], env[:ui])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Up < Base
|
25
|
-
def call(env)
|
26
|
-
get_builder(env).mount! if @machine.config.sshfs.enabled
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Destroy < Base
|
31
|
-
def call(env)
|
32
|
-
get_builder(env).unmount! if @machine.config.sshfs.enabled
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Reload < Up; end
|
37
|
-
class Provision < Up; end
|
38
|
-
class Suspend < Destroy; end
|
39
|
-
class Resume < Up; end
|
40
|
-
class Halt < Destroy; end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,54 +0,0 @@
|
|
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
|
-
unmount!
|
13
|
-
|
14
|
-
paths.each do |src, target|
|
15
|
-
info("mounting", src: src, target: target)
|
16
|
-
mount(src, target)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def unmount!
|
21
|
-
paths.each do |src, target|
|
22
|
-
info("unmounting", src: target)
|
23
|
-
unmount(target)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def mount
|
28
|
-
raise NotImplementedError
|
29
|
-
end
|
30
|
-
|
31
|
-
def paths
|
32
|
-
machine.config.sshfs.paths
|
33
|
-
end
|
34
|
-
|
35
|
-
def info(key, *args)
|
36
|
-
ui.info(i18n("info.#{key}", *args))
|
37
|
-
end
|
38
|
-
|
39
|
-
def ask(key, *args)
|
40
|
-
ui.ask(i18n("ask.#{key}", *args), :new_line => true)
|
41
|
-
end
|
42
|
-
|
43
|
-
def error(key, *args)
|
44
|
-
ui.error(i18n("error.#{key}", *args))
|
45
|
-
raise Error, :base
|
46
|
-
end
|
47
|
-
|
48
|
-
def i18n(key, *args)
|
49
|
-
I18n.t("vagrant.config.sshfs.#{key}", *args)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,41 +0,0 @@
|
|
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
|
@@ -1,93 +0,0 @@
|
|
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
|
-
`killall -9 sshfs 2>/dev/null`
|
12
|
-
`umount -f #{target}`
|
13
|
-
else
|
14
|
-
`fusermount -u -q #{target}`
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def mount(src, target)
|
19
|
-
`#{sshfs_bin} -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.sshfs.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 machine.config.sshfs.prompt_create_folders == false || ask("create_src", src: src) == "y"
|
55
|
-
if machine.config.sshfs.sudo
|
56
|
-
machine.communicate.execute("sudo su -c 'mkdir -p #{src}'")
|
57
|
-
else
|
58
|
-
machine.communicate.execute("mkdir -p #{src}")
|
59
|
-
end
|
60
|
-
info("created_src", src: src)
|
61
|
-
else
|
62
|
-
error("not_created_src", src: src)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
src
|
67
|
-
end
|
68
|
-
|
69
|
-
def check_target!(target)
|
70
|
-
folder = target_folder(target)
|
71
|
-
|
72
|
-
# entries return . and .. when empty
|
73
|
-
if File.exist?(folder) && Dir.entries(folder).size > 2
|
74
|
-
error("non_empty_target", target: folder)
|
75
|
-
elsif !File.exist?(folder)
|
76
|
-
if machine.config.sshfs.prompt_create_folders == false || ask("create_target", target: folder) == "y"
|
77
|
-
FileUtils.mkdir_p(folder)
|
78
|
-
info("created_target", target: folder)
|
79
|
-
else
|
80
|
-
error("not_created_target", target: folder)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
folder
|
85
|
-
end
|
86
|
-
|
87
|
-
def target_folder(target)
|
88
|
-
File.expand_path(target)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
data/lib/vagrant-sshfs/config.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module SshFS
|
3
|
-
class Config < Vagrant.plugin(2, :config)
|
4
|
-
attr_accessor :paths
|
5
|
-
attr_accessor :username
|
6
|
-
attr_accessor :enabled
|
7
|
-
attr_accessor :prompt_create_folders
|
8
|
-
attr_accessor :sudo
|
9
|
-
attr_accessor :mount_on_guest
|
10
|
-
attr_accessor :host_addr
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@paths = {}
|
14
|
-
@username = nil
|
15
|
-
@enabled = true
|
16
|
-
@prompt_create_folders = false
|
17
|
-
@sudo = true
|
18
|
-
end
|
19
|
-
|
20
|
-
def merge(other)
|
21
|
-
super.tap do |result|
|
22
|
-
result.paths = @paths.merge(other.paths)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/locales/en.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
vagrant:
|
3
|
-
config:
|
4
|
-
sshfs:
|
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? (y/n)"
|
13
|
-
create_target: "Target folder `%{target}` does not exist, create? (y/n)"
|
14
|
-
pass: "Password for `%{user}`:"
|
15
|
-
error:
|
16
|
-
base: "vagrant-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."
|