apiotics 0.2.11 → 0.2.12
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/apiotics/hardware.rb +47 -75
- data/lib/apiotics/portal.rb +2 -2
- data/lib/apiotics/version.rb +1 -1
- data/lib/generators/apiotics/script/templates/set_wifi.rake +7 -4
- 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: cf59743178c67ba8fc5651aae6497cd2142dc4f2
|
4
|
+
data.tar.gz: 51ea2c76b6b5c304680703b300b4121b029a2298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f585a1105d7d12f2761f9b52c2fa7a4cfd6720c55664dab61372d34bbec1c57cc53cf089a103e83c359e2548708f92410708adc74216937c77b94cc97a4380
|
7
|
+
data.tar.gz: 81306f49643f01775a86e47390b98e76f9f9a48c5d4d12d011ed35a8f8006b7e2607149ac8e07acf88f17918f2caa1df080f37164d48bd8b07680b03245d094d
|
data/lib/apiotics/hardware.rb
CHANGED
@@ -310,11 +310,11 @@ module Apiotics
|
|
310
310
|
downloaded = false
|
311
311
|
unless system == nil
|
312
312
|
if system == "mac"
|
313
|
-
if File.exist?("#{download_directory}/
|
313
|
+
if File.exist?("#{download_directory}/brand_and_burn.mac.sh")
|
314
314
|
downloaded = true
|
315
315
|
end
|
316
316
|
elsif system == "linux"
|
317
|
-
if File.exist?("#{download_directory}/
|
317
|
+
if File.exist?("#{download_directory}/brand_and_burn.sh")
|
318
318
|
downloaded = true
|
319
319
|
end
|
320
320
|
end
|
@@ -327,11 +327,11 @@ module Apiotics
|
|
327
327
|
`rm #{download_directory}/sd_scripts.tgz`
|
328
328
|
end
|
329
329
|
if system == "mac"
|
330
|
-
if File.exist?("#{download_directory}/
|
330
|
+
if File.exist?("#{download_directory}/brand_and_burn.mac.sh")
|
331
331
|
status = download_directory
|
332
332
|
end
|
333
333
|
elsif system == "linux"
|
334
|
-
if File.exist?("#{download_directory}/
|
334
|
+
if File.exist?("#{download_directory}/brand_and_burn.sh")
|
335
335
|
status = download_directory
|
336
336
|
end
|
337
337
|
end
|
@@ -339,11 +339,16 @@ module Apiotics
|
|
339
339
|
return status
|
340
340
|
end
|
341
341
|
|
342
|
-
def self.get_sd_image(download_directory, worker_name)
|
342
|
+
def self.get_sd_image(download_directory, worker_name, config)
|
343
343
|
Dir.chdir download_directory
|
344
|
-
|
344
|
+
worker_directory = download_directory.to_s + "/#{worker_name.downcase}"
|
345
|
+
Dir.mkdir worker_directory unless Dir.exist?(worker_directory)
|
346
|
+
image_name = "#{worker_name.downcase}-#{config['device_name'].underscore}-#{config['device_version']}"
|
347
|
+
image_name = image_name.gsub(" ", "_")
|
348
|
+
image_path = "#{worker_directory}/#{image_name}.img.gz"
|
345
349
|
unless File.exist?(image_path)
|
346
|
-
|
350
|
+
`rm #{worker_directory}/*`
|
351
|
+
Apiotics::Portal.get_sd_image(worker_directory, worker_name, image_name)
|
347
352
|
#zip_path = "#{download_directory}/#{worker_name}.img.gz"
|
348
353
|
#`gunzip -c #{zip_path} > #{image_path}`
|
349
354
|
#`rm #{zip_path}`
|
@@ -380,96 +385,63 @@ module Apiotics
|
|
380
385
|
config_file_path
|
381
386
|
end
|
382
387
|
|
383
|
-
def self.
|
388
|
+
def self.brand_and_burn_sd_image(download_directory, image_path, wifi_settings, config_file_path)
|
384
389
|
status = false
|
385
390
|
Dir.chdir download_directory
|
386
|
-
|
391
|
+
script_path = nil
|
387
392
|
if Hardware.mac == true
|
388
|
-
|
393
|
+
script_path = "#{download_directory}/brand_and_burn.mac.sh"
|
389
394
|
elsif Hardware.linux == true
|
390
|
-
|
395
|
+
script_path = "#{download_directory}/brand_and_burn.sh"
|
391
396
|
end
|
392
|
-
if
|
397
|
+
if script_path != nil
|
393
398
|
#puts "Please wait..."
|
394
|
-
puts "Running #{
|
395
|
-
IO.popen("#{
|
399
|
+
puts "Running sudo -S #{script_path} brand_and_burn #{image_path} no_disk #{wifi_settings["ssid"]} #{wifi_settings["password"]} #{wifi_settings["security_mode"]} #{config_file_path} 0 dhcp"
|
400
|
+
IO.popen("sudo -S #{script_path} brand_and_burn #{image_path} no_disk #{wifi_settings["ssid"]} #{wifi_settings["password"]} #{wifi_settings["security_mode"]} #{config_file_path} 0 dhcp") do |io|
|
396
401
|
while (line = io.gets) do
|
397
402
|
puts line
|
398
403
|
end
|
399
404
|
end
|
400
405
|
status = true
|
401
406
|
else
|
402
|
-
puts "Unrecognized system
|
407
|
+
puts "Unrecognized operating system, exiting."
|
403
408
|
end
|
404
409
|
status
|
405
410
|
end
|
406
411
|
|
407
|
-
def self.
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
end
|
431
|
-
return small_disk
|
432
|
-
end
|
433
|
-
|
434
|
-
def self.burn_sd_image(download_directory, image_path, disk)
|
435
|
-
Dir.chdir download_directory
|
436
|
-
img_path = image_path.chomp(".img.gz") + "_branded.img.gz"
|
437
|
-
puts "Burning #{image_path}..."
|
438
|
-
if Hardware.mac == true
|
439
|
-
execute_path = download_directory.to_s + "/burn_image_to_disk.mac.sh"
|
440
|
-
elsif Hardware.linux == true
|
441
|
-
execute_path = download_directory.to_s + "/burn_image_to_disk.sh"
|
442
|
-
else
|
443
|
-
execute_path = nil
|
444
|
-
end
|
445
|
-
if execute_path == nil
|
446
|
-
puts "This computer is not running a recognized OS. Exiting."
|
447
|
-
else
|
448
|
-
puts "Running sudo #{execute_path} #{image_path}"
|
449
|
-
#pwd = STDIN.getpass("Password:")
|
450
|
-
IO.popen("sudo -S #{execute_path} #{img_path}") do |io|
|
451
|
-
while (line = io.gets) do
|
452
|
-
puts line
|
453
|
-
end
|
454
|
-
end
|
455
|
-
end
|
456
|
-
end
|
412
|
+
#def self.burn_sd_image(download_directory, image_path)
|
413
|
+
# Dir.chdir download_directory
|
414
|
+
# img_path = image_path.chomp(".img.gz") + "_branded.img.gz"
|
415
|
+
# puts "Burning #{image_path}..."
|
416
|
+
# if Hardware.mac == true
|
417
|
+
# execute_path = download_directory.to_s + "/burn_image_to_disk.mac.sh"
|
418
|
+
# elsif Hardware.linux == true
|
419
|
+
# execute_path = download_directory.to_s + "/burn_image_to_disk.sh"
|
420
|
+
# else
|
421
|
+
# execute_path = nil
|
422
|
+
# end
|
423
|
+
# if execute_path == nil
|
424
|
+
# puts "This computer is not running a recognized OS. Exiting."
|
425
|
+
# else
|
426
|
+
# puts "Running sudo #{execute_path} #{image_path}"
|
427
|
+
# #pwd = STDIN.getpass("Password:")
|
428
|
+
# IO.popen("sudo -S #{execute_path} #{img_path}") do |io|
|
429
|
+
# while (line = io.gets) do
|
430
|
+
# puts line
|
431
|
+
# end
|
432
|
+
# end
|
433
|
+
# end
|
434
|
+
#end
|
457
435
|
|
458
436
|
def self.sd_card(worker_name, name, config)
|
437
|
+
#puts "Grab a coffee, this may take a few minutes..."
|
459
438
|
download_directory = Apiotics::Hardware.check_sd_card_scripts
|
460
439
|
if download_directory != nil
|
461
|
-
image_path = Apiotics::Hardware.get_sd_image(download_directory, worker_name)
|
440
|
+
image_path = Apiotics::Hardware.get_sd_image(download_directory, worker_name, config)
|
462
441
|
wifi_settings = Apiotics::Hardware.fetch_wifi
|
463
442
|
if wifi_settings != nil
|
464
443
|
config_file_path = Apiotics::Hardware.sd_config_file(worker_name, name, download_directory)
|
465
|
-
|
466
|
-
disk = Apiotics::Hardware.find_smallest_disk
|
467
|
-
if disk != "no_disk"
|
468
|
-
Apiotics::Hardware.burn_sd_image(download_directory, image_path, disk)
|
469
|
-
else
|
470
|
-
puts "No plausible SD card disk found. Please insert an SD card into your computer. Exiting."
|
471
|
-
end
|
472
|
-
end
|
444
|
+
Apiotics::Hardware.brand_and_burn_sd_image(download_directory, image_path, wifi_settings, config_file_path)
|
473
445
|
else
|
474
446
|
puts "No WiFi settings found. Please run rake firmware:wifi[ssid,password,security_mode] to set your default wifi settings"
|
475
447
|
end
|
@@ -500,7 +472,7 @@ module Apiotics
|
|
500
472
|
}
|
501
473
|
args.keys.each do |key|
|
502
474
|
if args[key] == nil
|
503
|
-
args[key] = ""
|
475
|
+
args[key] = "NONE"
|
504
476
|
end
|
505
477
|
end
|
506
478
|
|
data/lib/apiotics/portal.rb
CHANGED
@@ -268,8 +268,8 @@ module Apiotics
|
|
268
268
|
|
269
269
|
##
|
270
270
|
|
271
|
-
def self.get_sd_image(download_directory, worker_name)
|
272
|
-
filename = "#{download_directory}/#{
|
271
|
+
def self.get_sd_image(download_directory, worker_name, image_name)
|
272
|
+
filename = "#{download_directory}/#{image_name}.img.gz"
|
273
273
|
response = HTTParty.post("#{Apiotics.configuration.portal}api/download", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key, :worker => worker_name}).body
|
274
274
|
response = JSON.parse(response)
|
275
275
|
url = response["url"]
|
data/lib/apiotics/version.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
namespace :firmware do
|
2
2
|
desc "Set Wifi details for a device (if applicable). Use rake firmware:wifi[ssid, password, security_mode] to set the wifi details for a device."
|
3
3
|
task :wifi, [:ssid, :password, :security_mode] => [:environment] do |task, args|
|
4
|
-
security_modes = ["WEP", "WPA", "WPA2"]
|
4
|
+
security_modes = ["WEP", "WPA", "WPA2", "NONE"]
|
5
|
+
password = args[:password] || 'NONE'
|
5
6
|
if args[:security_mode] != nil
|
6
7
|
unless security_modes.include?(args[:security_mode])
|
7
8
|
puts "#{args[:security_mode]} is not a supported WiFi security mode. The supported security modes are: #{security_modes.to_s}"
|
8
9
|
else
|
9
|
-
Apiotics::Hardware.wifi(args[:ssid],
|
10
|
+
Apiotics::Hardware.wifi(args[:ssid], password, args[:security_mode])
|
10
11
|
end
|
11
12
|
else
|
12
|
-
Apiotics::Hardware.wifi(args[:ssid],
|
13
|
+
Apiotics::Hardware.wifi(args[:ssid], password, "NONE")
|
13
14
|
end
|
14
15
|
end
|
15
|
-
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiotics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MicroArx Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|