-
Notifications
You must be signed in to change notification settings - Fork 26
/
init.rb
executable file
·46 lines (37 loc) · 896 Bytes
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env ruby
#
# Android Cluster Toolkit
#
# init.rb - generate devices/pool.rb based on 'adb devices'
#
# (c) 2012-2015 Joshua J. Drake (jduck)
#
bfn = __FILE__
while File.symlink?(bfn)
bfn = File.expand_path(File.readlink(bfn), File.dirname(bfn))
end
$:.unshift(File.join(File.dirname(bfn), 'lib'))
# get a list of devices via 'adb devices'
require 'madb'
adb_devices = adb_scan(true)
device_pool = File.join(File.dirname(bfn), 'lib', 'devices', 'pool.rb')
if File.exists? device_pool
$stderr.puts "[!] devices/pool.rb exists! rm it to start over"
exit(1)
end
template = nil
File.open("#{device_pool}.sample", 'rb') { |f|
template = f.read
}
File.open(device_pool, 'wb') { |f|
f.puts template.split(/^=end$/).first + "=end"
adb_devices.each { |port,serial|
f.puts %Q|
{
:name => 'name', # description
:serial => '#{serial}',
},
|
}
f.puts "]"
}