ssh-manager 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 103b68fe6312ce929a945d39d18a5ccb420b26c4
4
- data.tar.gz: 9344a6da7e8c824744f5f6e39c50144e20a84baf
3
+ metadata.gz: e4c65127691cc262a53e1b6be85f842ba415e349
4
+ data.tar.gz: 7058ae0879a2d78f69f8cbaa7dfc53317059e111
5
5
  SHA512:
6
- metadata.gz: 7dcc80434c9f0ae484247f78c4d514b996c13f97e8d5607db5ecbe4fdd6c07bdd546dbcd05d7ecc5d6a1b6cca7a7b52dc52ede41336011e47f3feaa8fbc58f37
7
- data.tar.gz: b7b158e35c70408d92cc79d58bd166abbafd7baaa96d6957de8f0f047a1e903aea1e0e5505f3a0503b17b0deab6f506c16d6265a88d3eb1d4f7fe471ef7ce744
6
+ metadata.gz: 00fc8b45dab4c90ec36791c0491f6c036fe6ec43b67f51f61053e6ad492905f3ff3c60502a3cad06d7f3b57aa76f27cd91b00391ac2d30e78037ff7c3124b88e
7
+ data.tar.gz: 8c423a6806e02655fb5696b35842a6377d228933ab4393eece72f96255154072db8679086bca25e481c87c30108db869680facdc9a5a2d9c50d8eb39565928da
data/config/settings.yml CHANGED
@@ -1,2 +1,3 @@
1
- terminal : "xterm"
1
+ terminal : "xfce4-terminal"
2
2
  deletion_interval : "never"
3
+ tabbed: 'false'
data/config/sshm.db CHANGED
Binary file
@@ -2,6 +2,7 @@ require_relative 'db'
2
2
  require 'yaml'
3
3
  FileUtils.cp ("#{File.dirname(__FILE__)}/../../../config/settings.yml"), ("#{File.join(Dir.home)}" + '/.config/sshm/') unless File.exists?(("#{File.join(Dir.home)}" + '/.config/sshm/settings.yml'))
4
4
  CONFIG = YAML.load_file("#{File.join(ENV['HOME'])}/.config/sshm/settings.yml")
5
+ require 'debugger'
5
6
 
6
7
  module SSH
7
8
  module Manager
@@ -11,34 +12,52 @@ module SSH
11
12
  @options = opts
12
13
  end
13
14
 
14
- def connect_to(id)
15
- ip = SSH::Manager::Database.new.get_connection_data[id.to_i-1][0]
16
- user = SSH::Manager::Database.new.get_connection_data[id.to_i-1][1]
15
+ def check_term(ip, user)
17
16
  if CONFIG['terminal'] == "xfce4-terminal" || CONFIG['terminal'] == "gnome-terminal"
18
- %x(#{CONFIG['terminal']} --command="ssh #{user}@#{ip}")
19
- elsif CONFIG['terminal'] == "xterm"
17
+ if CONFIG['tabbed'] == 'true'
18
+ command = '--tab --command='
19
+ else
20
+ command = '--command='
21
+ end
22
+ #TODO: add title --title='connection name to identify '
23
+ #TODO: bug when no terminal is open => wants to open 2 terms
24
+ %x(#{CONFIG['terminal']} #{command}"ssh #{user}@#{ip}")
25
+ elsif CONFIG['terminal'] == "xterm" || CONFIG['terminal'] == "urxvt"
20
26
  %x(#{CONFIG['terminal']} -e "ssh #{user}@#{ip}")
21
27
  else
22
28
  puts "We dont support #{CONFIG['terminal']} right now"
23
- puts "Check Github for further development or contributing"
29
+ puts 'Check Github for further development or contributing'
24
30
  end
31
+ end
25
32
 
26
-
27
-
33
+ def connect_to(id)
34
+ @ip = SSH::Manager::Database.new.get_connection_data[id.to_i-1][0]
35
+ @user = SSH::Manager::Database.new.get_connection_data[id.to_i-1][1]
36
+ check_term(@ip, @user)
37
+ #TODO: check for options
38
+ #TODO: if db[secure_login] = false => http://linuxcommando.blogspot.de/2008/10/how-to-disable-ssh-host-key-checking.html
28
39
  end
29
40
 
30
41
  def add_connection(ip)
31
- puts "Username: "
32
- user =$stdin.gets.chomp
42
+ puts 'Username: '
43
+ user = $stdin.gets.chomp
33
44
  user = 'root' if user == ''
34
- puts "Hostname: "
45
+ puts 'Hostname: '
35
46
  hostname = $stdin.gets.chomp
36
- puts "port: "
47
+ puts 'port: '
37
48
  port = $stdin.gets.chomp
38
- port = "22" if port == ''
39
- puts "Notes: "
49
+ port = '22' if port == ''
50
+ puts 'Notes: '
40
51
  note = $stdin.gets.chomp
41
- SSH::Manager::Database.new.add_new_connection(ip, user, hostname, port, note)
52
+ puts 'Options: '
53
+ options = $stdin.gets.chomp
54
+ options = '' if options == ''
55
+ puts 'Group: '
56
+ group = $stdin.gets.chomp
57
+ count = 0
58
+ created_at = Time.now.to_s
59
+ last_time = Time.now.to_s
60
+ SSH::Manager::Database.new.add_new_connection(ip, user, hostname, port, note, created_at, options, count, group, last_time)
42
61
  end
43
62
 
44
63
  def delete(id)
@@ -48,43 +67,56 @@ module SSH
48
67
 
49
68
  def list_all
50
69
  cnt = 0
51
- # TODO: add indentation functionality with stringlenght etc..
52
70
  connections = Hash[SSH::Manager::Database.new.get_connection_data.collect { |x| [cnt+=1, x]}]
53
- puts "ID IP USERNAME HOSTNAME PORT NOTES"
71
+ puts 'ID IP USERNAME HOSTNAME PORT NOTES GROUP'
54
72
  connections.each do |x|
55
73
  print "#{x[0]}: "
56
74
  x[1].each do |a|
57
- printf "%-20s", a
75
+ printf '%-20s', a
58
76
  end
59
77
  puts "\n"
60
78
  end
61
-
62
79
  end
63
80
 
64
81
  def update(id)
65
- puts "Username: "
82
+ puts 'Entries wont change of left out blank.'
83
+ puts 'Username: '
66
84
  user =$stdin.gets.chomp
67
85
  user = SSH::Manager::Database.new.get_connection_data[id.to_i][1] if user == ''
68
- puts "Hostname: "
86
+ puts 'Hostname: '
69
87
  hostname = $stdin.gets.chomp
70
88
  hostname = SSH::Manager::Database.new.get_connection_data[id.to_i][2] if hostname == ''
71
- puts "port: "
89
+ puts 'port: '
72
90
  port = $stdin.gets.chomp
73
91
  port = SSH::Manager::Database.new.get_connection_data[id.to_i][3] if port == ''
74
- puts "Notes: "
92
+ puts 'Notes: '
75
93
  note = $stdin.gets.chomp
76
94
  note = SSH::Manager::Database.new.get_connection_data[id.to_i][4] if note == ''
77
95
  SSH::Manager::Database.new.update_connection(SSH::Manager::Database.new.get_connection_data[id.to_i][0], user, hostname, port, note)
78
96
  end
79
97
 
80
98
  def search_for(term)
99
+ puts 'IP USERNAME HOSTNAME PORT NOTES GROUP'
81
100
  SSH::Manager::Database.new.search_for(term).each do |x|
82
- puts x.all
101
+ x.all.each do |cons|
102
+ cons.values.each do |each_con|
103
+ printf '%-20s', each_con
104
+ end
105
+ puts "\n"
106
+ end
83
107
  end
84
108
  puts "All results for searchterm: #{term}"
85
109
  end
86
110
 
111
+ def multiple_connection(term)
112
+ SSH::Manager::Database.new.search_for(term).each do |x|
113
+ x.all.each do |dataset|
114
+ check_term(dataset[:ip], dataset[:user])
115
+ #TODO: Add terminalposition
116
+ end
117
+ end
118
+ end
119
+
87
120
  end
88
121
  end
89
122
  end
90
-
@@ -2,6 +2,7 @@
2
2
  require 'optparse'
3
3
  require_relative 'db'
4
4
  require_relative 'client'
5
+ require_relative 'version'
5
6
 
6
7
  module SSH
7
8
  module Manager
@@ -32,9 +33,15 @@ module SSH
32
33
  elsif @options[:update]
33
34
  puts 'Updating ..'
34
35
  cli.new(@options).update(@options[:update])
36
+ elsif @options[:multi]
37
+ puts 'Connecting to multiple ips'
38
+ cli.new(@options).multiple_connection(@options[:multi])
35
39
  elsif @options[:search]
36
40
  puts 'Searching ..'
37
41
  cli.new(@options).search_for(@options[:search])
42
+ # elsif @options[:settings]
43
+ # puts 'Settings'
44
+ # cli.new(@options).settings(@options[:settings])
38
45
  else
39
46
  cli.new(@argv.first).connect_to(@argv.first) if @argv != []
40
47
  puts @optparse if @argv ==[]
@@ -65,6 +72,10 @@ module SSH
65
72
  opts.on( '-s', '--search string', 'search connection for given criteria' ) do |opt|
66
73
  @options[:search] = opt
67
74
  end
75
+ @options[:multi] = false
76
+ opts.on( '-m', '--multi string', 'connect to multiple ips with given criteria' ) do |opt|
77
+ @options[:multi] = opt
78
+ end
68
79
  @options[:list] = false
69
80
  opts.on( '-l', '--list', 'list all connections' ) do
70
81
  @options[:list] = true
@@ -5,8 +5,8 @@ module SSH
5
5
  module Manager
6
6
  class Database
7
7
 
8
- FileUtils.cp ("#{File.dirname(__FILE__)}/../../../config/sshm.db"), ("#{File.join(Dir.home)}" + '/.config/sshm/') unless File.exists?(("#{File.join(Dir.home)}" + '/.config/sshm/sshm.db'))
9
8
  FileUtils.mkdir_p("#{File.join(ENV['HOME'])}/.config/sshm/") unless Dir.exists?("#{ENV['HOME']}/.config/sshm")
9
+ FileUtils.cp ("#{File.dirname(__FILE__)}/../../../config/sshm.db"), ("#{File.join(Dir.home)}" + '/.config/sshm/') unless File.exists?(("#{File.join(Dir.home)}" + '/.config/sshm/sshm.db'))
10
10
 
11
11
  @path = "#{File.join(ENV['HOME'])}/.config/sshm"
12
12
  DATABASE = Sequel.connect("sqlite://#{@path}/sshm.db")
@@ -18,12 +18,11 @@ module SSH
18
18
  end
19
19
 
20
20
  def get_connection_data
21
- @connections.map([:ip, :user, :hostname, :port, :note])
21
+ @connections.map([:ip, :user, :hostname, :port, :note, :group])
22
22
  end
23
23
 
24
- def add_new_connection(ip, user='root', hostname='', port=22, note='')
25
- # default params are currently useless FIXME
26
- @connections.insert(:ip => ip, :user => user, :hostname => hostname, :port => port, :note => note)
24
+ def add_new_connection(ip, user='root', hostname='', port=22, note='', created_at, option, count, group, last_time)
25
+ @connections.insert(:ip => ip, :user => user, :hostname => hostname, :port => port, :note => note, :created_at => created_at, :options => option, :group => group, :count => count, :last_time => last_time)
27
26
  end
28
27
 
29
28
  def delete_connection(ip)
@@ -37,9 +36,10 @@ module SSH
37
36
 
38
37
  def search_for(term)
39
38
  # check online: search for 'contains' not for complete matching
40
- return @connections.where(:ip => term), @connections.where(:user => term), @connections.where(:hostname => term), @connections.where(:port => term), @connections.where(:note => term)
39
+ return @connections.where(:ip => term), @connections.where(:user => term), @connections.where(:hostname => term), @connections.where(:port => term), @connections.where(:note => term), @connections.where(:group => term), @connections.where(:options => term)
41
40
  end
42
41
 
42
+
43
43
  end
44
44
  end
45
45
  end
@@ -1,5 +1,5 @@
1
1
  module SSH
2
2
  module Manager
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
data/ssh-manager.gemspec CHANGED
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_runtime_dependency 'sequel', '=4.13.0'
23
23
  spec.add_runtime_dependency 'sqlite3', '=1.3.9'
24
+ #spec.add_runtime_dependency 'ruby-devel', '=1.3.9'
24
25
  spec.add_development_dependency "rake"
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Schmid, Juraj Hura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler