-
Notifications
You must be signed in to change notification settings - Fork 26
/
mdo
executable file
·79 lines (62 loc) · 1.71 KB
/
mdo
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env ruby
#
# Android Cluster Toolkit
#
# mdo - execute an ADB command on the selected device(s)
#
# (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'))
require 'devices'
load_connected()
require 'madb'
# process args
if not parse_global_options() or ARGV.length < 1
$stderr.puts "usage: mdo [-1v] -d <device names or serials separated by commas> <parameters to adb client>"
exit(1)
end
# validate the adb command line
cmd = ARGV.first
if cmd == 'wait-for-device'
ARGV.shift
cmd = ARGV.first
end
case cmd
when 'bugreport', 'get-state', 'get-serialno', 'get-devpath', 'reboot', 'reboot-bootloader', 'root', 'remount', 'jdwp'
# allow for all usage patterns
when 'shell'
if ARGV.length < 2 and $one_line
$stderr.puts "[!] the #{cmd} command requires an argument when used in single-line mode"
exit(1)
end
when 'push', 'install'
if ARGV.length < 2
$stderr.puts "[!] the #{cmd} command requires an argument"
exit(1)
end
when 'pull'
if $do_all or $selected_devices.length > 1
$stderr.puts "[!] use ./mpull to pull from multiple devices"
exit(1)
elsif ARGV.length < 2
$stderr.puts "[!] the #{cmd} command requires an argument"
exit(1)
end
when 'logcat'
if $do_all or $selected_devices.length > 1
$stderr.puts "[!] specify a single device for logcat"
exit(1)
end
if $one_line
$stderr.puts "[!] single-line mode is not compatible with logcat"
end
else
$stderr.puts "[!] unsupported command: #{cmd}"
exit(1)
end
# run the commands
multi_adb()