Class: Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/rstuk.rb

Class Method Summary collapse

Class Method Details

.local(cmd, expected_exit_status = 0) ⇒ Object



23
24
25
26
# File 'lib/rstuk.rb', line 23

def self.local cmd, expected_exit_status = 0
  puts "local: #{cmd}"
  self.do cmd, expected_exit_status
end

.remote(server, port, cmd, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/rstuk.rb', line 13

def self.remote server, port, cmd, opts = {}
  defaults = {exit_code: 0, timeout: 90}
  opts = defaults.merge opts
  self.wait_for server, port, opts[:timeout]
  puts "ssh: #{cmd}"
  self.do \
    "ssh root@#{server}  #{self.ssh_options} -p #{port} \"#{cmd}\"",
    opts[:exit_code]
end

.scp(source, server, port, dest) ⇒ Object



28
29
30
31
# File 'lib/rstuk.rb', line 28

def self.scp source, server, port, dest
  puts "scp: #{source} root@#{server}:#{dest}"
  self.do "scp #{self.ssh_options} -r -P #{port} #{source} root@#{server}:#{dest}", 0
end