Class: Redata::Ssh
- Inherits:
-
Object
- Object
- Redata::Ssh
- Defined in:
- lib/redata/ssh.rb
Instance Method Summary collapse
-
#initialize ⇒ Ssh
constructor
A new instance of Ssh.
- #local_command(cmd) ⇒ Object
- #remove_dir(dir) ⇒ Object
- #run_command(cmd) ⇒ Object
- #run_with_ssh? ⇒ Boolean
- #upload_dir(dir) ⇒ Object
Constructor Details
Instance Method Details
#local_command(cmd) ⇒ Object
30 31 32 33 34 |
# 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) ⇒ Object
36 37 38 |
# 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) ⇒ Object
24 25 26 27 28 |
# 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? ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 |
# 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) ⇒ Object
20 21 22 |
# File 'lib/redata/ssh.rb', line 20 def upload_dir(dir) `scp -r -i #{@ssh['IdentityFile']} #{dir} #{@ssh['User']}@#{@ssh['HostName']}:~/tmp/` end |