-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgizmo.rb
executable file
·50 lines (39 loc) · 1.17 KB
/
gizmo.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
47
48
49
50
#!/usr/bin/ruby
require 'net/scp'
require 'optparse'
require 'json'
require 'rubygems'
require 'bundler'
Bundler.setup(:default)
require './lib/runner'
# capture args
args = {}
OptionParser.new do |opts|
opts.banner = "Usage: gizmo.rb [args] "
opts.on("-h", "--host HOSTNAME", "Target hostname") do |host|
args[:host] = host
end
opts.on("-p", "--port PORT", "Target port") do |port|
args[:port] = port || "22"
end
opts.on("-u", "--user USERNAME", "connect as user") do |user|
args[:user] = user
end
opts.on("-k", "--password PASSWORD", "password to use") do |password|
args[:password] = password
end
end.parse!
manifest_filename = ARGV.pop
# guard against bad args
raise Exception.new("hostname not provided") if args[:host].nil?
raise Exception.new("username not provided") if args[:user].nil?
raise Exception.new("password not provided") if args[:password].nil?
raise Exception.new("manifest file not provided") if manifest_filename.nil?
# load the manifest
manifest = JSON.parse(File.read(manifest_filename))
# load up a gizmo and execute
puts "Gizmo loading up!"
g = Runner.new({:args => args, :manifest => manifest})
g.prepare()
g.run()
g.result()