vagrant-zscp 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vagrant/zscp/command/zscp.rb +19 -9
- data/lib/vagrant/zscp/helper.rb +26 -25
- data/lib/vagrant/zscp/synced_folder.rb +18 -9
- data/lib/vagrant/zscp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee8d2e66e30169da939693caa5428aaeafa891ad
|
4
|
+
data.tar.gz: e4052fffc46eb13cdc53103a7cee168bcc473100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d774f621e4f1510ac6aa47b21a21f645725a2a280b2ef8be830886deb657c115d822c0899cfe9e24bf78d0c50634d5e53f68d175004ba450de52e54c684da380
|
7
|
+
data.tar.gz: 999f6640564ffaf8e5898a8fa1bbd00098a32b6f722567344a510b1e666eed0aceec140663dc40730e1c468be2e18897ce650a401a765854d3c6549eb80a0182
|
@@ -43,22 +43,32 @@ module Vagrant
|
|
43
43
|
# Get the SSH info for this machine so we can access it
|
44
44
|
ssh_info = machine.ssh_info
|
45
45
|
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
sync_threads << Thread.new(id, folder_opts) do |id, folder_opts|
|
50
|
-
ZscpHelper.scp(machine, ssh_info, folder_opts)
|
51
|
-
end
|
46
|
+
# Clean up every synced folder first
|
47
|
+
foreach_folder(folders) do |folder_opts|
|
48
|
+
ZscpHelper.cleanup(machine, ssh_info, folder_opts)
|
52
49
|
end
|
53
50
|
|
54
|
-
|
55
|
-
|
51
|
+
# Clean up every synced folder first
|
52
|
+
foreach_folder(folders) do |folder_opts|
|
53
|
+
ZscpHelper.scp(machine, ssh_info, folder_opts)
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
59
57
|
return error ? 1 : 0
|
60
58
|
end
|
59
|
+
|
60
|
+
def foreach_folder(folders, &block)
|
61
|
+
sync_threads = []
|
62
|
+
folders.each do |id, folder_opts|
|
63
|
+
sync_threads << Thread.new(folder_opts) do |folder_opts|
|
64
|
+
block.call(folder_opts)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
sync_threads.each do |t|
|
68
|
+
t.join
|
69
|
+
end
|
70
|
+
end
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
64
|
-
end
|
74
|
+
end
|
data/lib/vagrant/zscp/helper.rb
CHANGED
@@ -3,11 +3,18 @@ module Vagrant
|
|
3
3
|
# This is a helper that abstracts out the functionality of scping
|
4
4
|
# folders so that it can be called from anywhere.
|
5
5
|
class ZscpHelper
|
6
|
+
def self.cleanup(machine, ssh_info, opts)
|
7
|
+
guestpath = opts[:guestpath]
|
8
|
+
machine.ui.info("Removing remote #{guestpath}")
|
9
|
+
remotely_execute(ssh_info, "sudo rm -rf #{guestpath};")
|
10
|
+
end
|
11
|
+
|
6
12
|
def self.scp(machine, ssh_info, opts)
|
7
13
|
guestpath = opts[:guestpath]
|
8
|
-
hostpath = opts[:hostpath]
|
9
|
-
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
14
|
+
hostpath = File.expand_path(opts[:hostpath], machine.env.root_path)
|
10
15
|
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
16
|
+
hostpath += "/" if !hostpath.end_with?("/")
|
17
|
+
|
11
18
|
if (opts[:zscp_include])
|
12
19
|
included_files = opts[:zscp_include].join(' ')
|
13
20
|
else
|
@@ -17,33 +24,27 @@ module Vagrant
|
|
17
24
|
username = ssh_info[:username]
|
18
25
|
host = ssh_info[:host]
|
19
26
|
|
20
|
-
if !hostpath.end_with?("/")
|
21
|
-
hostpath += "/"
|
22
|
-
end
|
23
|
-
|
24
27
|
machine.ui.info("Sending #{hostpath} to #{guestpath}")
|
25
|
-
|
26
|
-
remotely_execute(ssh_info, "sudo rm -rf #{guestpath}; sudo mkdir -p #{guestpath}; sudo chown #{username}:$(id -gn) #{guestpath}")
|
28
|
+
remotely_execute(ssh_info, "sudo mkdir -p #{guestpath}; sudo chown #{username}:$(id -gn #{username}) #{guestpath}")
|
27
29
|
|
28
|
-
|
30
|
+
temp_file = `mktemp -t 'temp.XXXX.tar.gz'`.strip
|
31
|
+
machine.ui.info("Compressing #{hostpath} into #{temp_file}")
|
32
|
+
system("tar -czhf #{temp_file} -C #{hostpath} #{included_files}")
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
"#{username}@#{host}:#{guestpath}"
|
42
|
-
].join(' ')
|
43
|
-
system(command)
|
34
|
+
machine.ui.info("Copying #{temp_file} to #{guestpath}")
|
35
|
+
command = [
|
36
|
+
"scp",
|
37
|
+
'-o StrictHostKeyChecking=no',
|
38
|
+
'-o UserKnownHostsFile=/dev/null',
|
39
|
+
"-o port=#{ssh_info[:port]}",
|
40
|
+
"-i '#{ssh_info[:private_key_path][0]}'",
|
41
|
+
"#{temp_file}",
|
42
|
+
"#{username}@#{host}:#{guestpath}"
|
43
|
+
].join(' ')
|
44
|
+
system(command)
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
machine.ui.info("Extracting remotely #{guestpath}/temp.*.tar.gz")
|
47
|
+
remotely_execute(ssh_info, "tar -xzf #{guestpath}/temp.*.tar.gz -C #{guestpath}; rm #{guestpath}/temp.*.tar.gz")
|
47
48
|
machine.ui.info("#{guestpath} synchronised")
|
48
49
|
end
|
49
50
|
|
@@ -21,18 +21,27 @@ module Vagrant
|
|
21
21
|
def enable(machine, folders, opts)
|
22
22
|
ssh_info = machine.ssh_info
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
# Clean up every synced folder first
|
25
|
+
foreach_folder(folders) do |folder_opts|
|
26
|
+
ZscpHelper.cleanup(machine, ssh_info, folder_opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Clean up every synced folder first
|
30
|
+
foreach_folder(folders) do |folder_opts|
|
31
|
+
ZscpHelper.scp(machine, ssh_info, folder_opts)
|
32
|
+
end
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
def foreach_folder(folders, &block)
|
36
|
+
sync_threads = []
|
37
|
+
folders.each do |id, folder_opts|
|
38
|
+
sync_threads << Thread.new(folder_opts) do |folder_opts|
|
39
|
+
block.call(folder_opts)
|
34
40
|
end
|
35
41
|
end
|
42
|
+
sync_threads.each do |t|
|
43
|
+
t.join
|
44
|
+
end
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
data/lib/vagrant/zscp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-zscp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Hebert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|