vagrant-scp-sync 0.5.10 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/lib/vagrant-scp-sync/action/scp_sync.rb +80 -42
- data/lib/vagrant-scp-sync/command/scp.rb +49 -53
- data/lib/vagrant-scp-sync/errors.rb +41 -9
- data/lib/vagrant-scp-sync/plugin.rb +42 -6
- data/lib/vagrant-scp-sync/synced_folder.rb +4 -3
- data/lib/vagrant-scp-sync/version.rb +1 -1
- data/lib/vagrant-scp-sync.rb +14 -3
- data/locales/en.yml +44 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c034d409b3c2956435b324465f32bb5e24fa49c540c1fb7679915e72a6c8d1f6
|
4
|
+
data.tar.gz: 732a442ca6213677714a1008f5a732e36fe22c244893de2f0d33ec183d849cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 778c512ff8d043a5e4bded18c66b8f35cf3e4f8ad1ceb7d683d99be79d2347cab690a4ab915adae677e448ec6dab1df3531f320232e6b6079f3235a9d8af9bba
|
7
|
+
data.tar.gz: 72e59dc346a18050df0303c6c7ad98637425ad8c54da4914a13b3bb1e63f108ddc1462a1c7a2ddd809fc78bea790c28701b79704ba2dd06d61c65fde997159e4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.5.12](https://github.com/STARTcloud/vagrant-scp-sync/compare/v0.5.11...v0.5.12) (2024-11-20)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* full implentation ([3715346](https://github.com/STARTcloud/vagrant-scp-sync/commit/3715346080fe36ccc08fb401770ef59de13c82ab))
|
9
|
+
* linting ([39b82ae](https://github.com/STARTcloud/vagrant-scp-sync/commit/39b82ae671da035f7bbb3eec693b99f950acc1fc))
|
10
|
+
* linting ([aa71732](https://github.com/STARTcloud/vagrant-scp-sync/commit/aa717326be49ecd3452e9a793c9bba2146a4efc5))
|
11
|
+
* linting ([c6a932b](https://github.com/STARTcloud/vagrant-scp-sync/commit/c6a932b9d476d31ea4bc522bd9356f2a273ca9bd))
|
12
|
+
* linting ([390be27](https://github.com/STARTcloud/vagrant-scp-sync/commit/390be27b4f042ae22e035d2829f236f59cccbced))
|
13
|
+
* linting ([ce4ba83](https://github.com/STARTcloud/vagrant-scp-sync/commit/ce4ba83954f318062886492f4742950b0b726957))
|
14
|
+
* linting ([4befd93](https://github.com/STARTcloud/vagrant-scp-sync/commit/4befd9393ff86006291b293534bdefffac5e413b))
|
15
|
+
|
16
|
+
## [0.5.11](https://github.com/STARTcloud/vagrant-scp-sync/compare/v0.5.10...v0.5.11) (2024-11-20)
|
17
|
+
|
18
|
+
|
19
|
+
### Bug Fixes
|
20
|
+
|
21
|
+
* implentation complete ([987197d](https://github.com/STARTcloud/vagrant-scp-sync/commit/987197d15506d7c11b08af2e279efeb178037b71))
|
22
|
+
* linting ([c531e5b](https://github.com/STARTcloud/vagrant-scp-sync/commit/c531e5b2137781d6c670dc1cc0053d79a63637b6))
|
23
|
+
* linting ([9720ea7](https://github.com/STARTcloud/vagrant-scp-sync/commit/9720ea74d683180f213b62dc45c821b3b3e9c615))
|
24
|
+
* linting ([dbc75c3](https://github.com/STARTcloud/vagrant-scp-sync/commit/dbc75c328c7e5e042d02e8c7472a83e3898b274b))
|
25
|
+
* linting ([fbb7533](https://github.com/STARTcloud/vagrant-scp-sync/commit/fbb7533ee869bd1d761fd33b365b26bcca9557c7))
|
26
|
+
* linting ([70266d1](https://github.com/STARTcloud/vagrant-scp-sync/commit/70266d1a4aafe9e68ed9e1f5f0242268f1f3e5cc))
|
27
|
+
* linting ([3e7facd](https://github.com/STARTcloud/vagrant-scp-sync/commit/3e7facd04a4af7060773e96b6e298a2c0ae0f953))
|
28
|
+
* linting ([da0ef5d](https://github.com/STARTcloud/vagrant-scp-sync/commit/da0ef5d2435ca6cef31fc626891d1144677a34bb))
|
29
|
+
* synced folders reference ([2b8ade9](https://github.com/STARTcloud/vagrant-scp-sync/commit/2b8ade9ef7d896e11851eb004ac687031f8dd1a0))
|
30
|
+
* synced folders refernce ([3efe97c](https://github.com/STARTcloud/vagrant-scp-sync/commit/3efe97c50ea6e18e5aca4876c2fd05003401ddb0))
|
31
|
+
* synced folders refernce ([fa1dfc5](https://github.com/STARTcloud/vagrant-scp-sync/commit/fa1dfc5a04611ac623b84cd02c7c513fb390936e))
|
32
|
+
|
3
33
|
## [0.5.10](https://github.com/STARTcloud/vagrant-scp-sync/compare/v0.5.9...v0.5.10) (2024-11-19)
|
4
34
|
|
5
35
|
|
@@ -7,65 +7,103 @@ module VagrantPlugins
|
|
7
7
|
module ScpSync
|
8
8
|
# This will SCP the files
|
9
9
|
class ScpSyncHelper
|
10
|
-
def self.scp_single(machine, opts)
|
10
|
+
def self.scp_single(machine, opts, scp_path)
|
11
11
|
ssh_info = machine.ssh_info
|
12
12
|
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
13
13
|
|
14
|
-
source_files = opts[:
|
15
|
-
|
16
|
-
|
17
|
-
target_files =
|
18
|
-
|
19
|
-
source_files += '/' unless source_files.end_with?('/')
|
20
|
-
target_files += '/' unless target_files.end_with?('/')
|
14
|
+
source_files = expand_path(opts[:map], machine)
|
15
|
+
has_trailing_slash_source = opts[:map].end_with?('/')
|
16
|
+
sync_source_files = append_wildcard(source_files, has_trailing_slash_source)
|
17
|
+
target_files = expand_path(opts[:to], machine)
|
18
|
+
|
21
19
|
opts[:owner] ||= ssh_info[:username]
|
22
20
|
opts[:group] ||= ssh_info[:username]
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
''
|
29
|
-
end
|
21
|
+
|
22
|
+
ssh_opts = build_ssh_options(ssh_info)
|
23
|
+
scp_opts = build_scp_options(opts)
|
24
|
+
|
25
|
+
delete = scp_opts.include?('--delete')
|
30
26
|
|
31
27
|
if opts[:direction] == :upload || opts[:direction].nil?
|
32
|
-
source =
|
33
|
-
target = "#{username}@#{host}
|
28
|
+
source = sync_source_files
|
29
|
+
target = "#{ssh_info[:username]}@#{ssh_info[:host]}:#{target_files}"
|
30
|
+
make_dir = build_ssh_command(ssh_opts, "sudo mkdir -p #{target_files}", ssh_info)
|
31
|
+
change_ownership = build_ssh_command(ssh_opts, "sudo chown -R #{opts[:owner]}:#{opts[:group]} #{target_files}", ssh_info)
|
32
|
+
change_permissions = build_ssh_command(ssh_opts, "sudo chmod 777 #{target_files}", ssh_info)
|
33
|
+
remove_dir = build_ssh_command(ssh_opts, "sudo rm -rf #{target_files}", ssh_info)
|
34
34
|
elsif opts[:direction] == :download
|
35
|
-
source = "#{username}@#{host}
|
36
|
-
target =
|
35
|
+
source = "#{ssh_info[:username]}@#{ssh_info[:host]}:#{sync_source_files}"
|
36
|
+
target = target_files
|
37
|
+
make_dir = "mkdir -p #{target_files}"
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
40
|
+
synchronize = build_scp_command(scp_path, ssh_opts, source, target)
|
41
|
+
execute_command(machine, remove_dir, delete, nil, opts)
|
42
|
+
execute_command(machine, make_dir, false, nil, opts)
|
43
|
+
execute_command(machine, change_ownership, false, nil, opts)
|
44
|
+
execute_command(machine, change_permissions, false, nil, opts)
|
45
|
+
execute_command(machine, synchronize, true, 'scp_sync_folder', opts)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.expand_path(path, machine)
|
49
|
+
expanded_path = File.expand_path(path, machine.env.root_path)
|
50
|
+
Vagrant::Util::Platform.fs_real_path(expanded_path).to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.append_wildcard(path, has_trailing_slash)
|
54
|
+
has_trailing_slash ? "#{path}/*" : path
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.build_ssh_options(ssh_info)
|
58
|
+
opts = %w[
|
59
|
+
-o StrictHostKeyChecking=no
|
60
|
+
-o UserKnownHostsFile=/dev/null
|
61
|
+
-o LogLevel=ERROR
|
62
|
+
]
|
63
|
+
opts << "-o port=#{ssh_info[:port]}"
|
64
|
+
opts << ssh_info[:private_key_path].map { |k| "-i #{k}" }.join(' ')
|
65
|
+
opts
|
66
|
+
end
|
51
67
|
|
52
|
-
|
53
|
-
|
68
|
+
def self.build_scp_options(opts)
|
69
|
+
opts[:scp__args] ? Array(opts[:scp__args]).dup : ['--verbose']
|
70
|
+
end
|
54
71
|
|
55
|
-
|
72
|
+
def self.build_ssh_command(ssh_opts, command, ssh_info)
|
73
|
+
['ssh', *ssh_opts, "#{ssh_info[:username]}@#{ssh_info[:host]}", command].join(' ')
|
74
|
+
end
|
56
75
|
|
57
|
-
|
76
|
+
def self.build_scp_command(scp_path, ssh_opts, source, target)
|
77
|
+
[scp_path, '-r', *ssh_opts, source, target].join(' ')
|
78
|
+
end
|
58
79
|
|
59
|
-
|
80
|
+
def self.execute_command(machine, command, raise_error, message_key, opts)
|
81
|
+
return if command.nil?
|
60
82
|
|
61
|
-
|
83
|
+
if message_key
|
84
|
+
machine.ui.info(
|
85
|
+
I18n.t(
|
86
|
+
"vagrant_scp_sync.action.#{message_key}",
|
87
|
+
command: command,
|
88
|
+
target_files: opts[:to],
|
89
|
+
source_files: opts[:map]
|
90
|
+
)
|
91
|
+
)
|
92
|
+
end
|
62
93
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
94
|
+
result = Vagrant::Util::Subprocess.execute('sh', '-c', command)
|
95
|
+
|
96
|
+
raise_scp_error(message_key, command, result.stderr) if raise_error && !result.exit_code.zero?
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.raise_scp_error(message_key, command, stderr)
|
100
|
+
raise Errors.const_get("SyncedFolderScpSync#{message_key.split('_').map(&:capitalize).join}Error"),
|
101
|
+
command: command,
|
102
|
+
stderr: stderr
|
68
103
|
end
|
104
|
+
|
105
|
+
private_class_method :expand_path, :append_wildcard, :build_ssh_options, :build_scp_options,
|
106
|
+
:build_ssh_command, :build_scp_command, :execute_command, :raise_scp_error
|
69
107
|
end
|
70
108
|
end
|
71
109
|
end
|
@@ -1,52 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pathname'
|
4
|
+
require 'vagrant/util/subprocess'
|
5
|
+
require 'vagrant/util/which'
|
4
6
|
|
5
7
|
module VagrantPlugins
|
6
8
|
module ScpSync
|
7
9
|
module Command
|
8
10
|
# This class defines SCPSync
|
9
|
-
class
|
11
|
+
class ScpSyncCommand < Vagrant.plugin('2', :command)
|
10
12
|
def self.synopsis
|
11
13
|
'Copies data into a box via SCP'
|
12
14
|
end
|
13
15
|
|
14
16
|
def execute
|
15
|
-
@
|
16
|
-
return if @file2.nil?
|
17
|
+
@source, @target = parse_args
|
17
18
|
|
18
19
|
with_target_vms(host) do |machine|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
raise Vagrant::Errors::SSHNotReady if machine.ssh_info.nil?
|
21
|
+
|
22
|
+
if @source.nil? && @target.nil?
|
23
|
+
folders = machine.config.vm.synced_folders
|
24
|
+
ssh_info = machine.ssh_info
|
25
|
+
scp_path = Vagrant::Util::Which.which('scp')
|
26
|
+
machine.ui.warn(I18n.t('vagrant.scp_ssh_password')) if ssh_info[:private_key_path].empty? && ssh_info[:password]
|
27
|
+
folders.each_value do |folder_opts|
|
28
|
+
next unless folder_opts[:type] == :scp
|
29
|
+
|
30
|
+
VagrantPlugins::ScpSync::ScpSyncHelper.scp_single(machine, folder_opts, scp_path)
|
31
|
+
end
|
26
32
|
else
|
27
|
-
|
28
|
-
|
33
|
+
ssh_info = machine.ssh_info
|
34
|
+
scp_path = Vagrant::Util::Which.which('scp')
|
35
|
+
direction = net_ssh_command(@source)
|
36
|
+
source = format_file_path(machine, @source)
|
37
|
+
target = format_file_path(machine, @target)
|
38
|
+
folder_opts = {
|
39
|
+
type: :scp,
|
40
|
+
map: source,
|
41
|
+
to: target,
|
42
|
+
owner: ssh_info[:username],
|
43
|
+
group: ssh_info[:username],
|
44
|
+
direction: direction,
|
45
|
+
scp__args: ['--delete'],
|
46
|
+
rsync__args: ['--delete'],
|
47
|
+
disabled: false,
|
48
|
+
guestpath: target,
|
49
|
+
hostpath: source
|
50
|
+
}
|
51
|
+
|
52
|
+
VagrantPlugins::ScpSync::ScpSyncHelper.scp_single(machine, folder_opts, scp_path)
|
29
53
|
end
|
30
|
-
|
31
|
-
proxy_command = if @ssh_info[:proxy_command]
|
32
|
-
"-o ProxyCommand='#{@ssh_info[:proxy_command]}'"
|
33
|
-
else
|
34
|
-
''
|
35
|
-
end
|
36
|
-
|
37
|
-
command = [
|
38
|
-
'scp',
|
39
|
-
'-r',
|
40
|
-
'-o StrictHostKeyChecking=no',
|
41
|
-
'-o UserKnownHostsFile=/dev/null',
|
42
|
-
"-o port=#{@ssh_info[:port]}",
|
43
|
-
'-o LogLevel=ERROR',
|
44
|
-
proxy_command,
|
45
|
-
@ssh_info[:private_key_path].map { |k| "-i '#{k}'" }.join(' '),
|
46
|
-
source,
|
47
|
-
target
|
48
|
-
].join(' ')
|
49
|
-
system(command)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -62,14 +66,16 @@ module VagrantPlugins
|
|
62
66
|
o.separator ''
|
63
67
|
end
|
64
68
|
argv = parse_options(opts)
|
65
|
-
return argv if argv && argv.length == 2
|
69
|
+
return argv if argv && (argv.empty? || argv.length == 2)
|
66
70
|
|
67
|
-
@env.ui.info(opts.help, prefix: false)
|
71
|
+
@env.ui.info(opts.help, prefix: false)
|
68
72
|
[nil, nil]
|
69
73
|
end
|
70
74
|
|
75
|
+
require_relative '../action/scp_sync'
|
76
|
+
|
71
77
|
def host
|
72
|
-
host = [@
|
78
|
+
host = [@source, @target].map do |file_spec|
|
73
79
|
file_spec.match(/^([^:]*):/)[1]
|
74
80
|
rescue NoMethodError
|
75
81
|
nil
|
@@ -78,33 +84,23 @@ module VagrantPlugins
|
|
78
84
|
host
|
79
85
|
end
|
80
86
|
|
81
|
-
def net_ssh_command
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
def source_files
|
86
|
-
format_file_path(@file1)
|
87
|
+
def net_ssh_command(source)
|
88
|
+
source.include?(':') ? :download : :upload
|
87
89
|
end
|
88
90
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
else
|
93
|
-
Pathname.new(source_files).basename
|
94
|
-
end
|
91
|
+
def expand_path(path, machine)
|
92
|
+
expanded_path = File.expand_path(path, machine.env.root_path)
|
93
|
+
Vagrant::Util::Platform.fs_real_path(expanded_path).to_s
|
95
94
|
end
|
96
95
|
|
97
|
-
def format_file_path(filepath)
|
96
|
+
def format_file_path(machine, filepath)
|
97
|
+
ssh_info = machine.ssh_info
|
98
98
|
if filepath.include?(':')
|
99
|
-
filepath.split(':').last.gsub('~', "/home/#{
|
99
|
+
filepath.split(':').last.gsub('~', "/home/#{ssh_info[:username]}")
|
100
100
|
else
|
101
101
|
filepath
|
102
102
|
end
|
103
103
|
end
|
104
|
-
|
105
|
-
def target_location_specified?
|
106
|
-
!@file2.end_with?(':')
|
107
|
-
end
|
108
104
|
end
|
109
105
|
end
|
110
106
|
end
|
@@ -2,16 +2,48 @@
|
|
2
2
|
|
3
3
|
require 'vagrant'
|
4
4
|
|
5
|
-
module
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
module VagrantPlugins
|
6
|
+
module ScpSync
|
7
|
+
module Errors
|
8
|
+
# Namespace for Vagrant SCP Sync Errors
|
9
|
+
class VagrantScpSyncError < Vagrant::Errors::VagrantError
|
10
|
+
error_namespace('vagrant_scp_sync.errors')
|
11
|
+
end
|
12
|
+
|
13
|
+
# This Class denotes Errors for SCP Sync
|
14
|
+
class SyncedFolderScpSyncError < VagrantScpSyncError
|
15
|
+
error_key(:scp_sync_error, 'vagrant_scp_sync.errors')
|
16
|
+
end
|
17
|
+
|
18
|
+
# This Class denotes Errors for Manual SCP Sync
|
19
|
+
class SyncedFolderScpSyncScpSyncFolderError < VagrantScpSyncError
|
20
|
+
error_key(:scp_sync_folder_error, 'vagrant_scp_sync.errors')
|
21
|
+
end
|
22
|
+
|
23
|
+
# This Class denotes Delete Dir Errors for SCP Sync
|
24
|
+
class SyncedFolderScpSyncDeleteDirError < VagrantScpSyncError
|
25
|
+
error_key(:scp_sync_error_delete_directory, 'vagrant_scp_sync.errors')
|
26
|
+
end
|
27
|
+
|
28
|
+
# This Class denotes Make Dir Errors for SCP Sync
|
29
|
+
class SyncedFolderScpSyncMakeDirError < VagrantScpSyncError
|
30
|
+
error_key(:scp_sync_error_make_directory, 'vagrant_scp_sync.errors')
|
31
|
+
end
|
32
|
+
|
33
|
+
# This Class denotes Make Dir Errors for SCP Sync
|
34
|
+
class SyncedFolderScpSyncChangePermissionsDirError < VagrantScpSyncError
|
35
|
+
error_key(:scp_sync_error_change_permissions_directory, 'vagrant_scp_sync.errors')
|
36
|
+
end
|
37
|
+
|
38
|
+
# This Class denotes Make Dir Errors for SCP Sync
|
39
|
+
class SyncedFolderScpSyncChangeOwnershipDirError < VagrantScpSyncError
|
40
|
+
error_key(:scp_sync_error_change_ownership_directory, 'vagrant_scp_sync.errors')
|
41
|
+
end
|
11
42
|
|
12
|
-
|
13
|
-
|
14
|
-
|
43
|
+
# This Class denotes that SCP Sync is not found
|
44
|
+
class SCPNotFound < VagrantScpSyncError
|
45
|
+
error_key(:scp_installed_error, 'vagrant_scp_sync.errors')
|
46
|
+
end
|
15
47
|
end
|
16
48
|
end
|
17
49
|
end
|
@@ -17,21 +17,57 @@ module VagrantPlugins
|
|
17
17
|
Copy files to vagrant boxes via scp
|
18
18
|
DESC
|
19
19
|
|
20
|
-
command 'scp' do
|
21
|
-
setup_i18n
|
22
|
-
require_relative 'command'
|
23
|
-
Command
|
24
|
-
end
|
25
|
-
|
26
20
|
synced_folder('scp', 5) do
|
27
21
|
require_relative 'synced_folder'
|
28
22
|
SyncedFolder
|
29
23
|
end
|
30
24
|
|
25
|
+
# This initializes the internationalization strings.
|
31
26
|
def self.setup_i18n
|
32
27
|
I18n.load_path << File.expand_path('locales/en.yml', ScpSync.source_root)
|
33
28
|
I18n.reload!
|
34
29
|
end
|
30
|
+
|
31
|
+
# This sets up our log level to be whatever VAGRANT_LOG is.
|
32
|
+
def self.setup_logging
|
33
|
+
require 'log4r'
|
34
|
+
|
35
|
+
level = nil
|
36
|
+
begin
|
37
|
+
level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
|
38
|
+
rescue NameError
|
39
|
+
# This means that the logging constant wasn't found,
|
40
|
+
# which is fine. We just keep `level` as `nil`. But
|
41
|
+
# we tell the user.
|
42
|
+
level = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
# Some constants, such as "true" resolve to booleans, so the
|
46
|
+
# above error checking doesn't catch it. This will check to make
|
47
|
+
# sure that the log level is an integer, as Log4r requires.
|
48
|
+
level = nil unless level.is_a?(Integer)
|
49
|
+
|
50
|
+
# Set the logging level on all "vagrant" namespaced
|
51
|
+
# logs as long as we have a valid level.
|
52
|
+
|
53
|
+
return unless level
|
54
|
+
|
55
|
+
logger = Log4r::Logger.new('vagrant_scp_sync')
|
56
|
+
logger.outputters = Log4r::Outputter.stderr
|
57
|
+
logger.level = level
|
58
|
+
logger
|
59
|
+
end
|
60
|
+
|
61
|
+
# Setup logging and i18n before any autoloading loads other classes
|
62
|
+
# with logging configured as this prevents inheritance of the log level
|
63
|
+
# from the parent logger.
|
64
|
+
setup_logging
|
65
|
+
setup_i18n
|
66
|
+
|
67
|
+
command('scp') do
|
68
|
+
require_relative 'command/scp'
|
69
|
+
Command::ScpSyncCommand
|
70
|
+
end
|
35
71
|
end
|
36
72
|
end
|
37
73
|
end
|
@@ -18,11 +18,11 @@ module VagrantPlugins
|
|
18
18
|
@logger = Log4r::Logger.new('vagrant_scp_sync')
|
19
19
|
end
|
20
20
|
|
21
|
-
def usable?(_machine,
|
21
|
+
def usable?(_machine, *args)
|
22
22
|
scp_path = Which.which('scp')
|
23
23
|
return true if scp_path
|
24
24
|
|
25
|
-
return false unless raise_error
|
25
|
+
return false unless args.include?(:raise_error) && args[:raise_error]
|
26
26
|
|
27
27
|
raise Vagrant::Errors::SCPNotFound
|
28
28
|
end
|
@@ -31,11 +31,12 @@ module VagrantPlugins
|
|
31
31
|
|
32
32
|
def enable(machine, folders, _opts)
|
33
33
|
ssh_info = machine.ssh_info
|
34
|
+
scp_path = Which.which('scp')
|
34
35
|
|
35
36
|
machine.ui.warn(I18n.t('vagrant.scp_ssh_password')) if ssh_info[:private_key_path].empty? && ssh_info[:password]
|
36
37
|
|
37
38
|
folders.each_value do |folder_opts|
|
38
|
-
ScpSyncHelper.scp_single(machine, folder_opts)
|
39
|
+
ScpSyncHelper.scp_single(machine, folder_opts, scp_path)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
data/lib/vagrant-scp-sync.rb
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'vagrant-scp-sync/plugin'
|
5
|
-
require 'vagrant-scp-sync/errors'
|
3
|
+
require 'pathname'
|
6
4
|
|
7
5
|
module VagrantPlugins
|
8
6
|
# This is used to SCP files to/from Guests and Hosts
|
9
7
|
module ScpSync
|
8
|
+
lib_path = Pathname.new(File.expand_path('vagrant-scp-sync', __dir__))
|
9
|
+
autoload :Errors, lib_path.join('errors')
|
10
10
|
def self.source_root
|
11
11
|
@source_root ||= Pathname.new(File.expand_path('..', __dir__))
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
require 'vagrant'
|
18
|
+
rescue LoadError
|
19
|
+
raise 'The Vagrant vagrant-zones plugin must be run within Vagrant.'
|
20
|
+
end
|
21
|
+
|
22
|
+
raise 'The Vagrant vagrant-zones plugin is only compatible with Vagrant 2+.' if Vagrant::VERSION < '2'
|
23
|
+
|
24
|
+
require 'vagrant-scp-sync/version'
|
25
|
+
require 'vagrant-scp-sync/plugin'
|
data/locales/en.yml
CHANGED
@@ -1,18 +1,58 @@
|
|
1
1
|
en:
|
2
2
|
vagrant_scp_sync:
|
3
|
+
action:
|
4
|
+
scp_sync_folder: "Syncing files: %{source_files} ==> %{target_files}"
|
3
5
|
errors:
|
4
6
|
not_yet_implemented: |-
|
5
7
|
Configuration is not yet implemented
|
8
|
+
scp_sync_error_delete_directory: |-
|
9
|
+
There was an error when attemping to delete the directory for SCP Sync.
|
10
|
+
Target Files: %{target_files}
|
11
|
+
|
12
|
+
Error: %{stderr}
|
13
|
+
Full command causing error:
|
14
|
+
%{command}
|
15
|
+
|
16
|
+
scp_sync_error_change_ownership_directory: |-
|
17
|
+
There was an error when attemping to change the ownership of the directory for SCP Sync.
|
18
|
+
Target Files: %{target_files}
|
19
|
+
|
20
|
+
Error: %{stderr}
|
21
|
+
Full command causing error:
|
22
|
+
%{command}
|
23
|
+
|
24
|
+
scp_sync_error_change_permissions_directory: |-
|
25
|
+
There was an error when attemping to change the permissions of the directory for SCP Sync.
|
26
|
+
Target Files: %{target_files}
|
27
|
+
|
28
|
+
Error: %{stderr}
|
29
|
+
Full command causing error:
|
30
|
+
%{command}
|
31
|
+
|
32
|
+
scp_sync_error_make_directory: |-
|
33
|
+
There was an error when attemping to create the directory for SCP Sync.
|
34
|
+
Target Files: %{target_files}
|
35
|
+
|
36
|
+
Error: %{stderr}
|
37
|
+
Full command causing error:
|
38
|
+
%{command}
|
39
|
+
|
40
|
+
scp_sync_folder_error: |-
|
41
|
+
There was an error when attemping to sync folders using scp.
|
42
|
+
Please inspect the error message below for more info.
|
43
|
+
Error: %{stderr}
|
44
|
+
Full command causing error:
|
45
|
+
%{command}
|
6
46
|
|
7
47
|
scp_sync_error: |-
|
8
48
|
There was an error when attemping to sync folders using scp.
|
9
49
|
Please inspect the error message below for more info.
|
10
50
|
|
11
|
-
|
12
|
-
|
51
|
+
Source Files: %{source_files}
|
52
|
+
Target Files: %{target_files}
|
13
53
|
Error: %{stderr}
|
14
|
-
Full command causing error:
|
54
|
+
Full command causing error:
|
15
55
|
%{command}
|
16
56
|
|
17
57
|
scp_installed_error: |-
|
18
|
-
SCP was not detected as installed
|
58
|
+
SCP was not detected as installed
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-scp-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|