lib/steamy.rb in steamy-0.0.2 vs lib/steamy.rb in steamy-0.0.3
- old
+ new
@@ -19,12 +19,23 @@
list
exit 1
end
@ssh = "ssh #{@host}"
- @user = (@connections[@host]['user'].nil?) ? '' : "-u #{@connections[@host]['user']}"
- @password = (@connections[@host]['password'].nil?) ? '' : "-p\"#{@connections[@host]['password']}\""
- @database = database
+ @user = (@connections[@host]['user'].empty?) ? '' : "-u #{@connections[@host]['user']}"
+ @password = (@connections[@host]['password'].empty?) ? '' : "-p\"#{@connections[@host]['password']}\""
+ @database = set_database(host, database)
+ end
+
+ def set_database(host, database)
+ if host.nil? || @connections[@host]['database'].nil? || database
+ database = database
+ else
+ puts "This user can only access '#{@connections[@host]['database']}', update credentials to access other databases or specify database to dump."
+ exit 1
+ end
+
+ database
end
def remote_exec(command)
command = "#{@ssh} #{command}"
`#{command}`
\ No newline at end of file