class Redata::Ssh
Public Class Methods
new()
click to toggle source
# File lib/redata/ssh.rb, line 3 def initialize @ssh = RED.ssh end
Public Instance Methods
local_command(cmd)
click to toggle source
# File lib/redata/ssh.rb, line 30 def local_command(cmd) out, err, status = Open3.capture3 "#{cmd} >> #{RED.log_file}" puts err unless err.empty? Log.err_file err unless err.empty? end
remove_dir(dir)
click to toggle source
# File lib/redata/ssh.rb, line 36 def remove_dir(dir) `ssh -i #{@ssh['IdentityFile']} #{@ssh['User']}@#{@ssh['HostName']} \"rm -rf #{dir}\"` end
run_command(cmd)
click to toggle source
# File lib/redata/ssh.rb, line 24 def run_command(cmd) out, err, status = Open3.capture3 "ssh -i #{@ssh['IdentityFile']} #{@ssh['User']}@#{@ssh['HostName']} \"#{cmd}\" >> #{RED.log_file}" puts err unless err.empty? Log.err_file err unless err.empty? end
run_with_ssh?()
click to toggle source
# File lib/redata/ssh.rb, line 7 def run_with_ssh? if RED.is_ssh && @ssh && !RED.production? Log.warning "WARNING: Using gateway server #{@ssh['HostName']}" return true end if RED.is_ssh Log.warning "WARNING: SSH config file was not found. Ignore this config." unless @ssh Log.warning "WARNING: Could not use ssh mode in production. Ignore this config." if RED.production? end return false end
upload_dir(dir)
click to toggle source
# File lib/redata/ssh.rb, line 20 def upload_dir(dir) `scp -r -i #{@ssh['IdentityFile']} #{dir} #{@ssh['User']}@#{@ssh['HostName']}:~/tmp/` end