owssh 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/owssh.rb +19 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5246505c2bfaca65a38d84873f926f898dbf7be0
4
- data.tar.gz: f6485d1a241af713286c2cae25889846853caacb
3
+ metadata.gz: 14a2d860d3a2648cec43c800594c5c5d5013dd90
4
+ data.tar.gz: 5d80f0cb09a39460e001cf76b3f6e278a9273de6
5
5
  SHA512:
6
- metadata.gz: e0ef6475bee232565cba57d6945a3c9093f317a1f4304bcaf913885759b70c4d73fbfff7007209d10e459e71b1043c8571573e3626c8fe03bf85d0239fa01902
7
- data.tar.gz: 4a9db8b017f544bb78550f355c3d86344b3d356151780e5ea5a7d5429d8e6812ebbd92842492c4bcb208e234360bbca525cf3da502146112f0623f893b24234b
6
+ metadata.gz: d55539670799752744f78aabc641ff8b9cd6d9325f50c5dd9914215e66161553bbe73d9d93b9ef9d717e3c2835cd7563296b8e412dccb817bb14445e4bc75937
7
+ data.tar.gz: 5733a0b9ab0072a482442860299c0bc69d6a02f7e1ba8d6e2d5ad6803504e98a4b780d6ca605bfaeddfc8c7040c24034297c2dd482b03882594d71e3692624a3
data/lib/owssh.rb CHANGED
@@ -110,6 +110,7 @@ class Owssh
110
110
  exit
111
111
  end
112
112
  elsif $stacks.has_key?(ARGV[0].downcase.to_s) then
113
+ # SSH to the host
113
114
  if ARGV[1].nil? then
114
115
  puts "Please enter an instance name. I.E. rails-app3"
115
116
  exit
@@ -120,12 +121,29 @@ class Owssh
120
121
  $instances["#{instance["Hostname"]}"] = instance["PublicIp"]
121
122
  end
122
123
  if $instances.has_key?(ARGV[1]) then
124
+ # Open interactive SSH connnection
123
125
  if ARGV[2].nil? then
124
126
  puts "Opening connection to #{ARGV[1]}..."
125
127
  exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]}")
126
- else
128
+ elsif ARGV[3].nil? then
129
+ # Run command through SSH on host
127
130
  puts "Running comand #{ARGV[2]} on host #{ARGV[1]}..."
128
131
  exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]} '#{ARGV[2]}'")
132
+ else
133
+ $first_instance = ""
134
+ $instances.each do |instance_name, data|
135
+ unless (instance_name =~ /#{ARGV[1].to_s}(.*)/).nil?
136
+ $first_instance = instance_name
137
+ break
138
+ end
139
+ end
140
+ if $first_instance == "" then
141
+ puts "Could not find suitable host of type #{ARGV[1]}"
142
+ exit
143
+ else
144
+ puts "Running comand #{ARGV[2]} on first host of type #{ARGV[1]} which is #{$first_instance}..."
145
+ exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$first_instance.to_s} '#{ARGV[2]}'")
146
+ end
129
147
  end
130
148
  else
131
149
  puts "Instance with name '#{ARGV[1]}' not found"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Hutchins