awsssh 3.1.1 → 3.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +3 -0
- data/lib/awsssh/version.rb +4 -1
- data/lib/awsssh.rb +107 -15
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63fc20c89f4fb29698b19c85f5f3faefa956da28
|
4
|
+
data.tar.gz: 82ad7ed3e5164de3c3b12f38cc11497c641742a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce77896d5dd582c39c5df4a12f937c83c3d3765b465e45af9e1e8d07f21522ccfb8121291289de6bc56bbfbeed922a80d579172df36c6d97a065c924cc43236b
|
7
|
+
data.tar.gz: a3845ae88eea0f101ed8c725e30a97b414b7450317c12c5ff631ecbc8e4fe0ee46ce5ae3fdf14197011a3b7a87af88d12e069677065c35a5eba390c7a6ef898f
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private --protected lib/**/*.rb - README.md
|
data/README.md
CHANGED
data/lib/awsssh/version.rb
CHANGED
data/lib/awsssh.rb
CHANGED
@@ -8,8 +8,16 @@ require "json"
|
|
8
8
|
|
9
9
|
|
10
10
|
module Awsssh
|
11
|
+
##
|
12
|
+
# Main awsssh class
|
13
|
+
# @since 1.0.0
|
11
14
|
class Awsssh < Thor
|
12
15
|
|
16
|
+
##
|
17
|
+
# overwrite initializer
|
18
|
+
# @since 3.0.0
|
19
|
+
# @private
|
20
|
+
#
|
13
21
|
def initialize(*args)
|
14
22
|
super
|
15
23
|
@text_colors = {
|
@@ -23,6 +31,12 @@ module Awsssh
|
|
23
31
|
check_version
|
24
32
|
end
|
25
33
|
|
34
|
+
##
|
35
|
+
# List all profiles
|
36
|
+
# @since 3.0.0
|
37
|
+
# @example
|
38
|
+
# awsssh list_profiles
|
39
|
+
#
|
26
40
|
desc "list_profiles", "List all your avavible profiles"
|
27
41
|
def list_profiles()
|
28
42
|
credentials = open_credantial_file
|
@@ -33,6 +47,15 @@ module Awsssh
|
|
33
47
|
end
|
34
48
|
end
|
35
49
|
|
50
|
+
##
|
51
|
+
# List all server for a profile
|
52
|
+
#
|
53
|
+
# @!method list_server(profile)
|
54
|
+
# @since 3.0.0
|
55
|
+
# @param profile [String] Profile name
|
56
|
+
# @example
|
57
|
+
# awsssh list_server PROFILE
|
58
|
+
#
|
36
59
|
desc "list_server PROFILE", "List all Server for given profile"
|
37
60
|
method_option :all, :type => :boolean, :aliases => "-a", :default => false, :desc => "Show all Server"
|
38
61
|
def list_server(profile)
|
@@ -65,23 +88,21 @@ module Awsssh
|
|
65
88
|
end
|
66
89
|
puts ""
|
67
90
|
end
|
68
|
-
|
69
|
-
print "Would you like to connect to any server directly? Please enter Server number (Enter to exit): "
|
70
|
-
server_to_connect = STDIN.gets.chomp
|
71
|
-
if server_to_connect.to_i != 0 and !server_online[server_to_connect.to_i].nil?
|
72
|
-
puts "connecting to #{server_online[server_to_connect.to_i]}"
|
73
|
-
puts
|
74
|
-
puts
|
75
|
-
connect_server server_online[server_to_connect.to_i]
|
76
|
-
elsif server_to_connect.to_i > server_online.length+1
|
77
|
-
puts "No Server sellected"
|
78
|
-
puts
|
79
|
-
else
|
80
|
-
break;
|
81
|
-
end
|
82
|
-
end
|
91
|
+
select_server(server_online)
|
83
92
|
end
|
84
93
|
|
94
|
+
##
|
95
|
+
# Connect to SERVERNAME
|
96
|
+
#
|
97
|
+
# @!method connect (hostname)
|
98
|
+
# @since 3.0.0
|
99
|
+
# @param hostname [String] Hostname
|
100
|
+
# @param profile [String] Profile name (optional)
|
101
|
+
# @example Without profile
|
102
|
+
# awsssh connect SERVERNAME
|
103
|
+
# @example With profile
|
104
|
+
# awsssh connect SERVERNAME --profile PROFILE
|
105
|
+
#
|
85
106
|
desc "connect SERVERNAME", "Connect to Hostname"
|
86
107
|
method_option :profile, :desc => "specify a profile - see `awsssh list_profiles`"
|
87
108
|
def connect (hostname)
|
@@ -108,13 +129,22 @@ module Awsssh
|
|
108
129
|
end
|
109
130
|
end
|
110
131
|
|
132
|
+
##
|
133
|
+
# Version
|
134
|
+
# @since 3.0.0
|
135
|
+
# @example
|
136
|
+
# awsssh version
|
111
137
|
desc "version", "Version"
|
112
138
|
def version
|
113
139
|
puts "version #{VERSION}"
|
114
140
|
end
|
115
141
|
|
116
142
|
|
143
|
+
##
|
144
|
+
# Help overwrite
|
117
145
|
# @private
|
146
|
+
# @since 3.0.0
|
147
|
+
#
|
118
148
|
def help(command = nil, subcommand = false)
|
119
149
|
super
|
120
150
|
puts "For more information visit https://github.com/sethiele/awsssh"
|
@@ -125,6 +155,51 @@ module Awsssh
|
|
125
155
|
|
126
156
|
private
|
127
157
|
|
158
|
+
##
|
159
|
+
# Select to connect to a server directly
|
160
|
+
# @since 3.2.0
|
161
|
+
# @param server_list [Sting<Array>] List of all server
|
162
|
+
#
|
163
|
+
def select_server(server_list)
|
164
|
+
while true
|
165
|
+
puts "Would you like to connect to any server directly?"
|
166
|
+
if check_in_tmux
|
167
|
+
puts "Please select server"
|
168
|
+
puts "Select multible server by enter server number comma seperated."
|
169
|
+
print "Server numer(s) (Enter to exit): "
|
170
|
+
else
|
171
|
+
puts "Please select a server"
|
172
|
+
puts "(you could connect to multible server if you run awsssh in tmux)"
|
173
|
+
print "Server numer (Enter to exit): "
|
174
|
+
end
|
175
|
+
server_selection = STDIN.gets.chomp.split(",").map{|n| n.strip.to_i if n.strip.to_i != 0}
|
176
|
+
server_to_connect = server_selection.reject{ |a| a.nil? || a > server_list.length+1}
|
177
|
+
if server_to_connect.length > 1 && check_in_tmux
|
178
|
+
session = "awsssh-connect"
|
179
|
+
`tmux -2 new-session -d -s #{session}`
|
180
|
+
server_to_connect.each_with_index do |server, index|
|
181
|
+
puts "connect to #{server_list[server]}"
|
182
|
+
`tmux send -t #{session} "ssh #{server_list[server]}" ENTER`
|
183
|
+
# `tmux send -t #{session} "ls -la" ENTER`
|
184
|
+
`tmux split-window -t #{session}:.1`
|
185
|
+
`tmux select-layout -t #{session} tiled`
|
186
|
+
end
|
187
|
+
`tmux send -t #{session} "exit" ENTER`
|
188
|
+
`tmux set-window-option -t #{session} synchronize-panes on`
|
189
|
+
`tmux select-window -t #{session}:1`
|
190
|
+
`tmux switch -t #{session}`
|
191
|
+
elsif server_to_connect.length == 1
|
192
|
+
puts "connect one to #{server_list[server_to_connect.first]}"
|
193
|
+
connect_server server_list[server_to_connect.first]
|
194
|
+
else
|
195
|
+
puts "No Server sellected"
|
196
|
+
puts
|
197
|
+
break
|
198
|
+
end
|
199
|
+
exit 0
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
128
203
|
##
|
129
204
|
# open and check credential file
|
130
205
|
#
|
@@ -168,11 +243,20 @@ module Awsssh
|
|
168
243
|
return nil
|
169
244
|
end
|
170
245
|
|
246
|
+
##
|
247
|
+
# connect to server via system ssh
|
248
|
+
# @since 3.1.0
|
249
|
+
# @param hostname [String] Server hostname or ssh conf alias
|
250
|
+
#
|
171
251
|
def connect_server(hostname)
|
172
252
|
exec "ssh #{hostname}"
|
173
253
|
exit 0
|
174
254
|
end
|
175
255
|
|
256
|
+
##
|
257
|
+
# check for updates every 2h and display a message if there is a newer version
|
258
|
+
# @since 3.1.1
|
259
|
+
#
|
176
260
|
def check_version
|
177
261
|
temp_file = "/tmp/awsssh_version_check"
|
178
262
|
if File.exists?(temp_file)
|
@@ -200,5 +284,13 @@ module Awsssh
|
|
200
284
|
end
|
201
285
|
end
|
202
286
|
end
|
287
|
+
|
288
|
+
##
|
289
|
+
# Check if is in TMUX env
|
290
|
+
# @since 3.2.0
|
291
|
+
# @return [Boolean] in TMUX or not
|
292
|
+
def check_in_tmux
|
293
|
+
!ENV['TMUX'].nil?
|
294
|
+
end
|
203
295
|
end
|
204
296
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awsssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Thiele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,6 +163,7 @@ extra_rdoc_files: []
|
|
163
163
|
files:
|
164
164
|
- ".gitignore"
|
165
165
|
- ".travis.yml"
|
166
|
+
- ".yardopts"
|
166
167
|
- Gemfile
|
167
168
|
- LICENSE.txt
|
168
169
|
- README.md
|
@@ -192,9 +193,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
193
|
version: '0'
|
193
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
195
|
requirements:
|
195
|
-
- - "
|
196
|
+
- - ">"
|
196
197
|
- !ruby/object:Gem::Version
|
197
|
-
version:
|
198
|
+
version: 1.3.1
|
198
199
|
requirements: []
|
199
200
|
rubyforge_project:
|
200
201
|
rubygems_version: 2.2.2
|