lib/ssh/manager/cli.rb in ssh-manager-1.0.0 vs lib/ssh/manager/cli.rb in ssh-manager-1.0.1
- old
+ new
@@ -40,26 +40,32 @@
#TODO: check for options
#TODO: if db[secure_login] = false => http://linuxcommando.blogspot.de/2008/10/how-to-disable-ssh-host-key-checking.html
end
def update_available
- #Thread.new {
- new_version =%x(gem search ssh-manager).split(' ')[1]
+ new_version =%x(gem search ssh-manager).split(' ')[1].gsub /\((.*)\)/, '\1'
old_version = SSH::Manager::VERSION
if new_version<old_version
- puts 'There is a update available -> sudo gem update ssh-manager'
+ puts "There is a update available #{new_version} was released. -> sudo gem update ssh-manager"
+ else
+ puts "Version: #{old_version} is up to date."
end
- #}
end
-
def transfer_key(id)
@ip = DATABASE.get_connection_data[id.to_i-1][0]
@user = DATABASE.get_connection_data[id.to_i-1][1]
%x(ssh-copy-id #{@user}@#{@ip})
end
+ def transfer_file(filename, id='', dest_path="/home/#{user}/")
+ @ip = DATABASE.get_connection_data[id.to_i-1][0]
+ @user = DATABASE.get_connection_data[id.to_i-1][1]
+ %x(scp #{filename} #{@user}@#{@ip}:#{dest_path}) if File.file?(filename)
+ %x(scp -r #{filename} #{@user}@#{@ip}:#{dest_path}) if File.directory?(filename)
+ end
+
def add_connection(ip)
puts 'Username: '
user = $stdin.gets.chomp
user = 'root' if user == ''
puts 'Hostname: '
@@ -72,9 +78,14 @@
puts 'Options: '
options = $stdin.gets.chomp
options = '' if options == ''
puts 'Group: '
group = $stdin.gets.chomp
+ # puts 'Connect via(ip): '
+ # connect_via_ip = $stdin.gets.chomp
+ # puts 'With Username: '
+ # connect_via_user = $stdin.gets.chomp
+ # connect_via= "#{connect_via_user}@#{connect_via_ip}"
count = 0
created_at = Time.now.to_s
last_time = Time.now.to_s
DATABASE.add_new_connection(ip, user, hostname, port, note, created_at, options, count, group, last_time)
end