Skip to content

Commit

Permalink
finish multiconnect over via
Browse files Browse the repository at this point in the history
  • Loading branch information
jschmid1 committed Mar 13, 2015
1 parent bc4faf3 commit fb566ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/ssh/manager/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(opts = {})
@options = opts
end

def check_term(ip, user)
def check_term(ip, user, via)
if CONFIG['terminal'] == "xfce4-terminal" || CONFIG['terminal'] == "gnome-terminal"
if CONFIG['tabbed'] == 'true'
command = "--title=#{user}@#{ip} --tab --command="
Expand All @@ -24,7 +24,11 @@ def check_term(ip, user)
#TODO: add title --title='connection name to identify '
#TODO: bug when no terminal is open => wants to open 2 terms
#TODO: dnslookup
%x(#{CONFIG['terminal']} #{command}"ssh #{user}@#{ip}")
if via.nil? or via.empty?
%x(#{CONFIG['terminal']} #{command}"ssh #{user}@#{ip}")
else
%x(#{CONFIG['terminal']} #{command}"ssh -A -t #{via} ssh -A -t #{user}@#{ip}")
end
elsif CONFIG['terminal'] == "xterm" || CONFIG['terminal'] == "urxvt"
%x(#{CONFIG['terminal']} -e "ssh #{user}@#{ip}")
else
Expand All @@ -38,12 +42,12 @@ def connect_to(id)
if via.nil?
@ip = DATABASE.get_connection_data[id.to_i-1][0]
@user = DATABASE.get_connection_data[id.to_i-1][1]
check_term(@ip, @user)
check_term(@ip, @user, via)
else
@ip = DATABASE.get_connection_data[id.to_i-1][0]
@user = DATABASE.get_connection_data[id.to_i-1][1]
via = DATABASE.get_connection_data[id.to_i-1][-1]
%x(gnome-terminal --command="ssh -A -t #{via} ssh -A -t #{@user}@#{@ip}")
check_term(@ip, @user, via)
end
#TODO: check for options
#TODO: if db[secure_login] = false => http://linuxcommando.blogspot.de/2008/10/how-to-disable-ssh-host-key-checking.html
Expand Down Expand Up @@ -151,7 +155,7 @@ def search_for(term)
def multiple_connection(term)
DATABASE.search_for(term).each do |x|
x.all.each do |dataset|
check_term(dataset[:ip], dataset[:user])
check_term(dataset[:ip], dataset[:user], dataset[:connect_via])
#TODO: Add terminalposition
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ssh/manager/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module SSH
module Manager
VERSION = "1.0.3"
VERSION = "1.0.6"
end
end

0 comments on commit fb566ae

Please sign in to comment.