aspera-cli 4.5.0 → 4.8.0
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
- checksums.yaml.gz.sig +1 -0
- data/README.md +1894 -1574
- data/bin/ascli +21 -1
- data/bin/asession +38 -34
- data/docs/test_env.conf +14 -3
- data/examples/aoc.rb +17 -15
- data/examples/dascli +26 -0
- data/examples/faspex4.rb +42 -35
- data/examples/proxy.pac +1 -1
- data/examples/transfer.rb +38 -37
- data/lib/aspera/aoc.rb +245 -205
- data/lib/aspera/ascmd.rb +111 -90
- data/lib/aspera/ats_api.rb +16 -14
- data/lib/aspera/cli/basic_auth_plugin.rb +19 -18
- data/lib/aspera/cli/extended_value.rb +50 -39
- data/lib/aspera/cli/formater.rb +161 -135
- data/lib/aspera/cli/info.rb +18 -0
- data/lib/aspera/cli/listener/line_dump.rb +4 -2
- data/lib/aspera/cli/listener/logger.rb +3 -1
- data/lib/aspera/cli/listener/progress.rb +20 -21
- data/lib/aspera/cli/listener/progress_multi.rb +29 -31
- data/lib/aspera/cli/main.rb +194 -183
- data/lib/aspera/cli/manager.rb +213 -206
- data/lib/aspera/cli/plugin.rb +71 -49
- data/lib/aspera/cli/plugins/alee.rb +8 -7
- data/lib/aspera/cli/plugins/aoc.rb +675 -558
- data/lib/aspera/cli/plugins/ats.rb +116 -109
- data/lib/aspera/cli/plugins/bss.rb +35 -34
- data/lib/aspera/cli/plugins/config.rb +722 -542
- data/lib/aspera/cli/plugins/console.rb +28 -22
- data/lib/aspera/cli/plugins/cos.rb +28 -37
- data/lib/aspera/cli/plugins/faspex.rb +281 -227
- data/lib/aspera/cli/plugins/faspex5.rb +129 -84
- data/lib/aspera/cli/plugins/node.rb +426 -232
- data/lib/aspera/cli/plugins/orchestrator.rb +106 -98
- data/lib/aspera/cli/plugins/preview.rb +196 -191
- data/lib/aspera/cli/plugins/server.rb +131 -126
- data/lib/aspera/cli/plugins/shares.rb +49 -36
- data/lib/aspera/cli/plugins/sync.rb +27 -28
- data/lib/aspera/cli/transfer_agent.rb +84 -79
- data/lib/aspera/cli/version.rb +3 -1
- data/lib/aspera/colors.rb +37 -28
- data/lib/aspera/command_line_builder.rb +84 -63
- data/lib/aspera/cos_node.rb +68 -34
- data/lib/aspera/data_repository.rb +4 -2
- data/lib/aspera/environment.rb +61 -46
- data/lib/aspera/fasp/agent_base.rb +36 -31
- data/lib/aspera/fasp/agent_connect.rb +44 -37
- data/lib/aspera/fasp/agent_direct.rb +101 -104
- data/lib/aspera/fasp/agent_httpgw.rb +91 -90
- data/lib/aspera/fasp/agent_node.rb +36 -33
- data/lib/aspera/fasp/agent_trsdk.rb +28 -31
- data/lib/aspera/fasp/error.rb +3 -1
- data/lib/aspera/fasp/error_info.rb +81 -54
- data/lib/aspera/fasp/installation.rb +171 -151
- data/lib/aspera/fasp/listener.rb +2 -0
- data/lib/aspera/fasp/parameters.rb +105 -111
- data/lib/aspera/fasp/parameters.yaml +305 -249
- data/lib/aspera/fasp/resume_policy.rb +20 -20
- data/lib/aspera/fasp/transfer_spec.rb +27 -0
- data/lib/aspera/fasp/uri.rb +31 -29
- data/lib/aspera/faspex_gw.rb +95 -118
- data/lib/aspera/hash_ext.rb +12 -13
- data/lib/aspera/id_generator.rb +11 -9
- data/lib/aspera/keychain/encrypted_hash.rb +73 -57
- data/lib/aspera/keychain/macos_security.rb +27 -29
- data/lib/aspera/log.rb +40 -39
- data/lib/aspera/nagios.rb +24 -22
- data/lib/aspera/node.rb +38 -30
- data/lib/aspera/oauth.rb +217 -248
- data/lib/aspera/open_application.rb +9 -7
- data/lib/aspera/persistency_action_once.rb +15 -14
- data/lib/aspera/persistency_folder.rb +15 -18
- data/lib/aspera/preview/file_types.rb +266 -270
- data/lib/aspera/preview/generator.rb +94 -92
- data/lib/aspera/preview/image_error.png +0 -0
- data/lib/aspera/preview/options.rb +20 -17
- data/lib/aspera/preview/utils.rb +99 -102
- data/lib/aspera/preview/video_error.png +0 -0
- data/lib/aspera/{proxy_auto_config.erb.js → proxy_auto_config.js} +23 -31
- data/lib/aspera/proxy_auto_config.rb +114 -21
- data/lib/aspera/rest.rb +144 -142
- data/lib/aspera/rest_call_error.rb +3 -2
- data/lib/aspera/rest_error_analyzer.rb +31 -31
- data/lib/aspera/rest_errors_aspera.rb +18 -16
- data/lib/aspera/secret_hider.rb +68 -0
- data/lib/aspera/ssh.rb +20 -16
- data/lib/aspera/sync.rb +57 -54
- data/lib/aspera/temp_file_manager.rb +20 -14
- data/lib/aspera/timer_limiter.rb +10 -8
- data/lib/aspera/uri_reader.rb +14 -15
- data/lib/aspera/web_auth.rb +85 -80
- data.tar.gz.sig +0 -0
- metadata +169 -40
- metadata.gz.sig +2 -0
- data/bin/dascli +0 -13
- data/docs/Makefile +0 -63
- data/docs/README.erb.md +0 -4221
- data/docs/README.md +0 -13
- data/docs/diagrams.txt +0 -49
- data/docs/doc_tools.rb +0 -58
- data/lib/aspera/cli/plugins/shares2.rb +0 -114
- data/lib/aspera/fasp/default.rb +0 -17
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'English'
|
|
1
4
|
require 'singleton'
|
|
2
5
|
require 'aspera/log'
|
|
3
6
|
require 'aspera/environment'
|
|
@@ -6,6 +9,7 @@ require 'xmlsimple'
|
|
|
6
9
|
require 'zlib'
|
|
7
10
|
require 'base64'
|
|
8
11
|
require 'fileutils'
|
|
12
|
+
require 'openssl'
|
|
9
13
|
|
|
10
14
|
module Aspera
|
|
11
15
|
module Fasp
|
|
@@ -18,73 +22,101 @@ module Aspera
|
|
|
18
22
|
# Installation.instance.ascp_path=""
|
|
19
23
|
class Installation
|
|
20
24
|
include Singleton
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
# known product names
|
|
26
|
+
PRODUCT_CONNECT = 'Aspera Connect'
|
|
27
|
+
PRODUCT_CLI_V1 = 'Aspera CLI'
|
|
28
|
+
PRODUCT_DRIVE = 'Aspera Drive'
|
|
29
|
+
PRODUCT_ENTSRV = 'Enterprise Server'
|
|
25
30
|
# protobuf generated files from sdk
|
|
26
|
-
EXT_RUBY_PROTOBUF='_pb.rb'
|
|
27
|
-
RB_SDK_FOLDER='lib'
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
EXT_RUBY_PROTOBUF = '_pb.rb'
|
|
32
|
+
RB_SDK_FOLDER = 'lib'
|
|
33
|
+
ONE_YEAR_SECONDS = 365 * 24 * 60 * 60
|
|
34
|
+
DEFAULT_ASPERA_CONF = <<~END_OF_CONFIG_FILE
|
|
35
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
36
|
+
<CONF version="2">
|
|
37
|
+
<default>
|
|
38
|
+
<file_system>
|
|
39
|
+
<resume_suffix>.aspera-ckpt</resume_suffix>
|
|
40
|
+
<partial_file_suffix>.partial</partial_file_suffix>
|
|
41
|
+
</file_system>
|
|
42
|
+
</default>
|
|
43
|
+
</CONF>
|
|
44
|
+
END_OF_CONFIG_FILE
|
|
45
|
+
DUMMY_CERT_INFO='/C=US/ST=California/L=Emeryville/O=Aspera Inc./OU=Corporate/CN=Aspera Inc./emailAddress=info@asperasoft.com'
|
|
46
|
+
private_constant :PRODUCT_CONNECT,:PRODUCT_CLI_V1,:PRODUCT_DRIVE,:PRODUCT_ENTSRV,:EXT_RUBY_PROTOBUF,:RB_SDK_FOLDER,
|
|
47
|
+
:ONE_YEAR_SECONDS,:DEFAULT_ASPERA_CONF,:DUMMY_CERT_INFO
|
|
30
48
|
# set ascp executable path
|
|
31
49
|
def ascp_path=(v)
|
|
32
|
-
@path_to_ascp=v
|
|
50
|
+
@path_to_ascp = v
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def ascp_path
|
|
54
|
+
path(:ascp)
|
|
33
55
|
end
|
|
34
56
|
|
|
35
57
|
def sdk_ruby_folder
|
|
36
|
-
ruby_pb_folder=File.join(
|
|
58
|
+
ruby_pb_folder = File.join(sdk_folder,RB_SDK_FOLDER)
|
|
37
59
|
FileUtils.mkdir_p(ruby_pb_folder) unless Dir.exist?(ruby_pb_folder)
|
|
38
60
|
return ruby_pb_folder
|
|
39
61
|
end
|
|
40
62
|
|
|
41
63
|
# location of SDK files
|
|
42
|
-
def
|
|
43
|
-
@
|
|
44
|
-
|
|
64
|
+
def sdk_folder=(v)
|
|
65
|
+
@sdk_dir = v
|
|
66
|
+
sdk_folder
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# backward compatibility in sample program
|
|
70
|
+
alias_method :folder=, :sdk_folder=
|
|
71
|
+
|
|
72
|
+
# @return the path to folder where SDK is installed
|
|
73
|
+
def sdk_folder
|
|
74
|
+
raise 'SDK path was ot initialized' if @sdk_dir.nil?
|
|
75
|
+
FileUtils.mkdir_p(@sdk_dir) unless Dir.exist?(@sdk_dir)
|
|
76
|
+
@sdk_dir
|
|
45
77
|
end
|
|
46
78
|
|
|
47
79
|
# find ascp in named product (use value : FIRST_FOUND='FIRST' to just use first one)
|
|
48
80
|
# or select one from installed_products()
|
|
49
81
|
def use_ascp_from_product(product_name)
|
|
50
82
|
if product_name.eql?(FIRST_FOUND)
|
|
51
|
-
pl=installed_products.first
|
|
83
|
+
pl = installed_products.first
|
|
52
84
|
raise "no FASP installation found\nPlease check manual on how to install FASP." if pl.nil?
|
|
53
85
|
else
|
|
54
|
-
pl=installed_products.
|
|
86
|
+
pl = installed_products.find{|i|i[:name].eql?(product_name)}
|
|
55
87
|
raise "no such product installed: #{product_name}" if pl.nil?
|
|
56
88
|
end
|
|
57
|
-
self.ascp_path=pl[:ascp_path]
|
|
89
|
+
self.ascp_path = pl[:ascp_path]
|
|
58
90
|
Log.log.debug("ascp_path=#{@path_to_ascp}")
|
|
59
91
|
end
|
|
60
92
|
|
|
61
93
|
# @return the list of installed products in format of product_locations
|
|
62
94
|
def installed_products
|
|
63
95
|
if @found_products.nil?
|
|
64
|
-
scan_locations=product_locations.clone
|
|
96
|
+
scan_locations = product_locations.clone
|
|
65
97
|
# add SDK as first search path
|
|
66
98
|
scan_locations.unshift({
|
|
67
|
-
:
|
|
68
|
-
:
|
|
69
|
-
:
|
|
99
|
+
expected: 'SDK',
|
|
100
|
+
app_root: sdk_folder,
|
|
101
|
+
sub_bin: ''
|
|
70
102
|
})
|
|
71
103
|
# search installed products: with ascp
|
|
72
|
-
@found_products=scan_locations.select! do |item|
|
|
104
|
+
@found_products = scan_locations.select! do |item|
|
|
73
105
|
# skip if not main folder
|
|
74
106
|
next false unless Dir.exist?(item[:app_root])
|
|
75
107
|
Log.log.debug("Found #{item[:app_root]}")
|
|
76
108
|
sub_bin = item[:sub_bin] || BIN_SUBFOLDER
|
|
77
|
-
item[:ascp_path]=File.join(item[:app_root],sub_bin,ascp_filename)
|
|
109
|
+
item[:ascp_path] = File.join(item[:app_root],sub_bin,ascp_filename)
|
|
78
110
|
# skip if no ascp
|
|
79
111
|
next false unless File.exist?(item[:ascp_path])
|
|
80
112
|
# read info from product info file if present
|
|
81
|
-
product_info_file="#{item[:app_root]}/#{PRODUCT_INFO}"
|
|
113
|
+
product_info_file = "#{item[:app_root]}/#{PRODUCT_INFO}"
|
|
82
114
|
if File.exist?(product_info_file)
|
|
83
|
-
res_s=XmlSimple.xml_in(File.read(product_info_file),{'ForceArray'=>false})
|
|
84
|
-
item[:name]=res_s['name']
|
|
85
|
-
item[:version]=res_s['version']
|
|
115
|
+
res_s = XmlSimple.xml_in(File.read(product_info_file),{'ForceArray' => false})
|
|
116
|
+
item[:name] = res_s['name']
|
|
117
|
+
item[:version] = res_s['version']
|
|
86
118
|
else
|
|
87
|
-
item[:name]=item[:expected]
|
|
119
|
+
item[:name] = item[:expected]
|
|
88
120
|
end
|
|
89
121
|
true # select this version
|
|
90
122
|
end
|
|
@@ -93,7 +125,7 @@ module Aspera
|
|
|
93
125
|
end
|
|
94
126
|
|
|
95
127
|
# all ascp files (in SDK)
|
|
96
|
-
FILES=[
|
|
128
|
+
FILES = %i[ascp ascp4 ssh_bypass_key_dsa ssh_bypass_key_rsa aspera_license aspera_conf fallback_cert fallback_key].freeze
|
|
97
129
|
|
|
98
130
|
# get path of one resource file of currently activated product
|
|
99
131
|
# keys and certs are generated locally... (they are well known values, arch. independant)
|
|
@@ -101,51 +133,49 @@ module Aspera
|
|
|
101
133
|
case k
|
|
102
134
|
when :ascp,:ascp4
|
|
103
135
|
use_ascp_from_product(FIRST_FOUND) if @path_to_ascp.nil?
|
|
104
|
-
file
|
|
136
|
+
file = @path_to_ascp
|
|
105
137
|
# note that there might be a .exe at the end
|
|
106
|
-
file=file.gsub('ascp','ascp4') if k.eql?(:ascp4)
|
|
138
|
+
file = file.gsub('ascp','ascp4') if k.eql?(:ascp4)
|
|
107
139
|
when :transferd
|
|
108
|
-
file=transferd_filepath
|
|
140
|
+
file = transferd_filepath
|
|
109
141
|
when :ssh_bypass_key_dsa
|
|
110
|
-
file=File.join(
|
|
142
|
+
file = File.join(sdk_folder,'aspera_bypass_dsa.pem')
|
|
111
143
|
File.write(file,get_key('dsa',1)) unless File.exist?(file)
|
|
112
144
|
File.chmod(0400,file)
|
|
113
145
|
when :ssh_bypass_key_rsa
|
|
114
|
-
file=File.join(
|
|
146
|
+
file = File.join(sdk_folder,'aspera_bypass_rsa.pem')
|
|
115
147
|
File.write(file,get_key('rsa',2)) unless File.exist?(file)
|
|
116
148
|
File.chmod(0400,file)
|
|
117
149
|
when :aspera_license
|
|
118
|
-
file=File.join(
|
|
119
|
-
|
|
150
|
+
file = File.join(sdk_folder,'aspera-license')
|
|
151
|
+
unless File.exist?(file)
|
|
152
|
+
clear=[
|
|
153
|
+
Zlib::Inflate.inflate(DataRepository.instance.data(6)),
|
|
154
|
+
"==SIGNATURE==\n",
|
|
155
|
+
Base64.strict_encode64(DataRepository.instance.data(7))
|
|
156
|
+
]
|
|
157
|
+
File.write(file,Base64.strict_encode64(clear.join))
|
|
158
|
+
end
|
|
120
159
|
File.chmod(0400,file)
|
|
121
160
|
when :aspera_conf
|
|
122
|
-
file=File.join(
|
|
123
|
-
File.write(file
|
|
124
|
-
<CONF version="2">
|
|
125
|
-
<default>
|
|
126
|
-
<file_system>
|
|
127
|
-
<resume_suffix>.aspera-ckpt</resume_suffix>
|
|
128
|
-
<partial_file_suffix>.partial</partial_file_suffix>
|
|
129
|
-
</file_system>
|
|
130
|
-
</default>
|
|
131
|
-
</CONF>
|
|
132
|
-
}) unless File.exist?(file)
|
|
161
|
+
file = File.join(sdk_folder,'aspera.conf')
|
|
162
|
+
File.write(file,DEFAULT_ASPERA_CONF) unless File.exist?(file)
|
|
133
163
|
File.chmod(0400,file)
|
|
134
164
|
when :fallback_cert,:fallback_key
|
|
135
|
-
file_key=File.join(
|
|
136
|
-
file_cert=File.join(
|
|
137
|
-
if !File.exist?(file_key)
|
|
165
|
+
file_key = File.join(sdk_folder,'aspera_fallback_key.pem')
|
|
166
|
+
file_cert = File.join(sdk_folder,'aspera_fallback_cert.pem')
|
|
167
|
+
if !File.exist?(file_key) || !File.exist?(file_cert)
|
|
138
168
|
require 'openssl'
|
|
139
169
|
# create new self signed certificate for http fallback
|
|
140
170
|
private_key = OpenSSL::PKey::RSA.new(1024)
|
|
141
171
|
cert = OpenSSL::X509::Certificate.new
|
|
142
|
-
cert.subject = cert.issuer = OpenSSL::X509::Name.parse(
|
|
172
|
+
cert.subject = cert.issuer = OpenSSL::X509::Name.parse(DUMMY_CERT_INFO)
|
|
143
173
|
cert.not_before = Time.now
|
|
144
|
-
cert.not_after = Time.now +
|
|
174
|
+
cert.not_after = Time.now + ONE_YEAR_SECONDS
|
|
145
175
|
cert.public_key = private_key.public_key
|
|
146
176
|
cert.serial = 0x0
|
|
147
177
|
cert.version = 2
|
|
148
|
-
cert.sign(private_key, OpenSSL::Digest
|
|
178
|
+
cert.sign(private_key, OpenSSL::Digest.new('SHA1'))
|
|
149
179
|
File.write(file_key,private_key.to_pem)
|
|
150
180
|
File.write(file_cert,cert.to_pem)
|
|
151
181
|
File.chmod(0400,file_key)
|
|
@@ -161,13 +191,13 @@ module Aspera
|
|
|
161
191
|
|
|
162
192
|
# @return the file path of local connect where API's URI can be read
|
|
163
193
|
def connect_uri
|
|
164
|
-
connect=get_product_folders(PRODUCT_CONNECT)
|
|
165
|
-
folder=File.join(connect[:run_root],VARRUN_SUBFOLDER)
|
|
194
|
+
connect = get_product_folders(PRODUCT_CONNECT)
|
|
195
|
+
folder = File.join(connect[:run_root],VARRUN_SUBFOLDER)
|
|
166
196
|
['','s'].each do |ext|
|
|
167
|
-
uri_file=File.join(folder,"http#{ext}.uri")
|
|
197
|
+
uri_file = File.join(folder,"http#{ext}.uri")
|
|
168
198
|
Log.log.debug("checking connect port file: #{uri_file}")
|
|
169
199
|
if File.exist?(uri_file)
|
|
170
|
-
return File.open(uri_file)
|
|
200
|
+
return File.open(uri_file, &:gets).strip
|
|
171
201
|
end
|
|
172
202
|
end
|
|
173
203
|
raise "no connect uri file found in #{folder}"
|
|
@@ -175,17 +205,17 @@ module Aspera
|
|
|
175
205
|
|
|
176
206
|
# @ return path to configuration file of aspera CLI
|
|
177
207
|
def cli_conf_file
|
|
178
|
-
connect=get_product_folders(PRODUCT_CLI_V1)
|
|
208
|
+
connect = get_product_folders(PRODUCT_CLI_V1)
|
|
179
209
|
return File.join(connect[:app_root],BIN_SUBFOLDER,'.aspera_cli_conf')
|
|
180
210
|
end
|
|
181
211
|
|
|
182
212
|
# default bypass key phrase
|
|
183
213
|
def bypass_pass
|
|
184
|
-
return
|
|
214
|
+
return format('%08x-%04x-%04x-%04x-%04x%08x',*DataRepository.instance.data(3).unpack('NnnnnN'))
|
|
185
215
|
end
|
|
186
216
|
|
|
187
217
|
def bypass_keys
|
|
188
|
-
return [
|
|
218
|
+
return %i[ssh_bypass_key_dsa ssh_bypass_key_rsa].map{|i|Installation.instance.path(i)}
|
|
189
219
|
end
|
|
190
220
|
|
|
191
221
|
# use in plugin `config`
|
|
@@ -195,14 +225,14 @@ module Aspera
|
|
|
195
225
|
|
|
196
226
|
# Check that specified path is ascp and get version
|
|
197
227
|
def get_exe_version(exe_path,vers_arg)
|
|
198
|
-
raise
|
|
228
|
+
raise 'ERROR: nil arg' if exe_path.nil?
|
|
199
229
|
return nil unless File.exist?(exe_path)
|
|
200
|
-
exe_version=nil
|
|
201
|
-
cmd_out
|
|
202
|
-
raise "An error occured when testing #{ascp_filename}: #{cmd_out}" unless
|
|
230
|
+
exe_version = nil
|
|
231
|
+
cmd_out = %x("#{exe_path}" #{vers_arg})
|
|
232
|
+
raise "An error occured when testing #{ascp_filename}: #{cmd_out}" unless $CHILD_STATUS == 0
|
|
203
233
|
# get version from ascp, only after full extract, as windows requires DLLs (SSL/TLS/etc...)
|
|
204
|
-
m=cmd_out.match(/ version ([0-9
|
|
205
|
-
exe_version=m[1] unless m.nil?
|
|
234
|
+
m = cmd_out.match(/ version ([0-9.]+)/)
|
|
235
|
+
exe_version = m[1] unless m.nil?
|
|
206
236
|
return exe_version
|
|
207
237
|
end
|
|
208
238
|
|
|
@@ -211,97 +241,89 @@ module Aspera
|
|
|
211
241
|
# @return ascp version (from execution)
|
|
212
242
|
def install_sdk(sdk_url)
|
|
213
243
|
require 'zip'
|
|
214
|
-
sdk_zip_path=File.join(Dir.tmpdir,'sdk.zip')
|
|
244
|
+
sdk_zip_path = File.join(Dir.tmpdir,'sdk.zip')
|
|
215
245
|
if sdk_url.start_with?('file:')
|
|
216
246
|
# require specific file scheme: the path part is "relative", or absolute if there are 4 slash
|
|
217
247
|
raise 'use format: file:///<path>' unless sdk_url.start_with?('file:///')
|
|
218
|
-
sdk_zip_path=sdk_url.gsub(%r{^file:///},'')
|
|
248
|
+
sdk_zip_path = sdk_url.gsub(%r{^file:///},'')
|
|
219
249
|
else
|
|
220
250
|
Aspera::Rest.new(base_url: sdk_url, redirect_max: 3).call(operation: 'GET',save_to_file: sdk_zip_path)
|
|
221
251
|
end
|
|
222
252
|
# rename old install
|
|
223
|
-
if !
|
|
224
|
-
Log.log.warn(
|
|
225
|
-
File.rename(
|
|
253
|
+
if !Dir.empty?(sdk_folder)
|
|
254
|
+
Log.log.warn('Previous install exists, renaming folder.')
|
|
255
|
+
File.rename(sdk_folder,"#{sdk_folder}.#{Time.now.strftime('%Y%m%d%H%M%S')}")
|
|
226
256
|
# TODO: delete old archives ?
|
|
227
257
|
end
|
|
228
258
|
# SDK is organized by architecture
|
|
229
|
-
arch_filter="#{Environment.architecture}/"
|
|
259
|
+
arch_filter = "#{Environment.architecture}/"
|
|
230
260
|
# extract files from archive
|
|
231
261
|
Zip::File.open(sdk_zip_path) do |zip_file|
|
|
232
262
|
zip_file.each do |entry|
|
|
233
263
|
# skip folder entries
|
|
234
264
|
next if entry.name.end_with?('/')
|
|
235
|
-
dest_folder=nil
|
|
265
|
+
dest_folder = nil
|
|
236
266
|
# binaries
|
|
237
|
-
dest_folder=
|
|
267
|
+
dest_folder = sdk_folder if entry.name.include?(arch_filter)
|
|
238
268
|
# ruby adapters
|
|
239
|
-
dest_folder=sdk_ruby_folder if entry.name.end_with?(EXT_RUBY_PROTOBUF)
|
|
240
|
-
if
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
end
|
|
269
|
+
dest_folder = sdk_ruby_folder if entry.name.end_with?(EXT_RUBY_PROTOBUF)
|
|
270
|
+
next if dest_folder.nil?
|
|
271
|
+
File.open(File.join(dest_folder,File.basename(entry.name)), 'wb') do |output_stream|
|
|
272
|
+
IO.copy_stream(entry.get_input_stream, output_stream)
|
|
244
273
|
end
|
|
245
274
|
end
|
|
246
275
|
end
|
|
247
276
|
File.unlink(sdk_zip_path) rescue nil # Windows may give error
|
|
248
277
|
# ensure license file are generated so that ascp invokation for version works
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
ascp_path=File.join(
|
|
278
|
+
path(:aspera_license)
|
|
279
|
+
path(:aspera_conf)
|
|
280
|
+
ascp_path = File.join(sdk_folder,ascp_filename)
|
|
252
281
|
raise "No #{ascp_filename} found in SDK archive" unless File.exist?(ascp_path)
|
|
253
282
|
FileUtils.chmod(0755,ascp_path)
|
|
254
283
|
FileUtils.chmod(0755,ascp_path.gsub('ascp','ascp4'))
|
|
255
|
-
ascp_version=get_ascp_version(File.join(
|
|
256
|
-
trd_path=transferd_filepath
|
|
284
|
+
ascp_version = get_ascp_version(File.join(sdk_folder,ascp_filename))
|
|
285
|
+
trd_path = transferd_filepath
|
|
257
286
|
Log.log.warn("No #{trd_path} in SDK archive") unless File.exist?(trd_path)
|
|
258
287
|
FileUtils.chmod(0755,trd_path) if File.exist?(trd_path)
|
|
259
|
-
transferd_version=get_exe_version(trd_path,'version')
|
|
260
|
-
sdk_version = transferd_version||ascp_version
|
|
261
|
-
File.write(File.join(
|
|
288
|
+
transferd_version = get_exe_version(trd_path,'version')
|
|
289
|
+
sdk_version = transferd_version || ascp_version
|
|
290
|
+
File.write(File.join(sdk_folder,PRODUCT_INFO),"<product><name>IBM Aspera SDK</name><version>#{sdk_version}</version></product>")
|
|
262
291
|
return sdk_version
|
|
263
292
|
end
|
|
264
293
|
|
|
265
294
|
private
|
|
266
295
|
|
|
267
|
-
BIN_SUBFOLDER='bin'
|
|
268
|
-
ETC_SUBFOLDER='etc'
|
|
269
|
-
VARRUN_SUBFOLDER=File.join('var','run')
|
|
296
|
+
BIN_SUBFOLDER = 'bin'
|
|
297
|
+
ETC_SUBFOLDER = 'etc'
|
|
298
|
+
VARRUN_SUBFOLDER = File.join('var','run')
|
|
270
299
|
# product information manifest: XML (part of aspera product)
|
|
271
|
-
PRODUCT_INFO='product-info.mf'
|
|
300
|
+
PRODUCT_INFO = 'product-info.mf'
|
|
272
301
|
# policy for product selection
|
|
273
|
-
FIRST_FOUND='FIRST'
|
|
302
|
+
FIRST_FOUND = 'FIRST'
|
|
274
303
|
|
|
275
304
|
private_constant :BIN_SUBFOLDER,:ETC_SUBFOLDER,:VARRUN_SUBFOLDER,:PRODUCT_INFO
|
|
276
305
|
|
|
277
306
|
def initialize
|
|
278
|
-
@path_to_ascp=nil
|
|
279
|
-
@
|
|
280
|
-
@found_products=nil
|
|
307
|
+
@path_to_ascp = nil
|
|
308
|
+
@sdk_dir = nil
|
|
309
|
+
@found_products = nil
|
|
281
310
|
end
|
|
282
311
|
|
|
283
312
|
# @return folder paths for specified applications
|
|
284
313
|
# @param name Connect or CLI
|
|
285
314
|
def get_product_folders(name)
|
|
286
|
-
found=installed_products.select{|i|i[:expected].eql?(name)
|
|
315
|
+
found = installed_products.select{|i|i[:expected].eql?(name) || i[:name].eql?(name)}
|
|
287
316
|
raise "Product: #{name} not found, please install." if found.empty?
|
|
288
317
|
return found.first
|
|
289
318
|
end
|
|
290
319
|
|
|
291
|
-
# @return the path to folder where SDK is installed
|
|
292
|
-
def folder_path
|
|
293
|
-
raise "Undefined path to SDK" if @sdk_folder.nil?
|
|
294
|
-
FileUtils.mkdir_p(@sdk_folder) unless Dir.exist?(@sdk_folder)
|
|
295
|
-
@sdk_folder
|
|
296
|
-
end
|
|
297
|
-
|
|
298
320
|
# filename for ascp with optional extension (Windows)
|
|
299
321
|
def ascp_filename
|
|
300
|
-
return 'ascp'+Environment.exe_extension
|
|
322
|
+
return 'ascp' + Environment.exe_extension
|
|
301
323
|
end
|
|
302
324
|
|
|
303
325
|
def transferd_filepath
|
|
304
|
-
return File.join(
|
|
326
|
+
return File.join(sdk_folder,'asperatransferd' + Environment.exe_extension)
|
|
305
327
|
end
|
|
306
328
|
|
|
307
329
|
# @return product folders depending on OS fields
|
|
@@ -313,50 +335,50 @@ module Aspera
|
|
|
313
335
|
def product_locations
|
|
314
336
|
case Aspera::Environment.os
|
|
315
337
|
when Aspera::Environment::OS_WINDOWS; return [{
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
338
|
+
expected: PRODUCT_CONNECT,
|
|
339
|
+
app_root: File.join(ENV['LOCALAPPDATA'],'Programs','Aspera','Aspera Connect'),
|
|
340
|
+
log_root: File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect','var','log'),
|
|
341
|
+
run_root: File.join(ENV['LOCALAPPDATA'],'Aspera','Aspera Connect')
|
|
342
|
+
},{
|
|
343
|
+
expected: PRODUCT_CLI_V1,
|
|
344
|
+
app_root: File.join('C:','Program Files','Aspera','cli'),
|
|
345
|
+
log_root: File.join('C:','Program Files','Aspera','cli','var','log')
|
|
346
|
+
},{
|
|
347
|
+
expected: PRODUCT_ENTSRV,
|
|
348
|
+
app_root: File.join('C:','Program Files','Aspera','Enterprise Server'),
|
|
349
|
+
log_root: File.join('C:','Program Files','Aspera','Enterprise Server','var','log')
|
|
350
|
+
}]
|
|
329
351
|
when Aspera::Environment::OS_X; return [{
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
else; return [{
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
352
|
+
expected: PRODUCT_CONNECT,
|
|
353
|
+
app_root: File.join(Dir.home,'Applications','Aspera Connect.app'),
|
|
354
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera_Connect'),
|
|
355
|
+
run_root: File.join(Dir.home,'Library','Application Support','Aspera','Aspera Connect'),
|
|
356
|
+
sub_bin: File.join('Contents','Resources')
|
|
357
|
+
},{
|
|
358
|
+
expected: PRODUCT_CLI_V1,
|
|
359
|
+
app_root: File.join(Dir.home,'Applications','Aspera CLI'),
|
|
360
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera')
|
|
361
|
+
},{
|
|
362
|
+
expected: PRODUCT_ENTSRV,
|
|
363
|
+
app_root: File.join('','Library','Aspera'),
|
|
364
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera')
|
|
365
|
+
},{
|
|
366
|
+
expected: PRODUCT_DRIVE,
|
|
367
|
+
app_root: File.join('','Applications','Aspera Drive.app'),
|
|
368
|
+
log_root: File.join(Dir.home,'Library','Logs','Aspera_Drive'),
|
|
369
|
+
sub_bin: File.join('Contents','Resources')
|
|
370
|
+
}]
|
|
371
|
+
else; return [{ # other: Linux and Unix family
|
|
372
|
+
expected: PRODUCT_CONNECT,
|
|
373
|
+
app_root: File.join(Dir.home,'.aspera','connect'),
|
|
374
|
+
run_root: File.join(Dir.home,'.aspera','connect')
|
|
375
|
+
},{
|
|
376
|
+
expected: PRODUCT_CLI_V1,
|
|
377
|
+
app_root: File.join(Dir.home,'.aspera','cli')
|
|
378
|
+
},{
|
|
379
|
+
expected: PRODUCT_ENTSRV,
|
|
380
|
+
app_root: File.join('','opt','aspera')
|
|
381
|
+
}]
|
|
360
382
|
end
|
|
361
383
|
end
|
|
362
384
|
|
|
@@ -364,11 +386,9 @@ module Aspera
|
|
|
364
386
|
# @param type rsa or dsa
|
|
365
387
|
# @param id in repository 1 for dsa, 2 for rsa
|
|
366
388
|
def get_key(type,id)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
hf.insert(1,bin).join("\n")
|
|
389
|
+
# generate PEM from DER
|
|
390
|
+
OpenSSL::PKey.const_get(type.upcase).new(DataRepository.instance.data(id)).to_pem
|
|
370
391
|
end
|
|
371
|
-
|
|
372
392
|
end # Installation
|
|
373
393
|
end
|
|
374
394
|
end
|