Class: Flucti::Resources::SshDetails::AccountBinding
- Inherits:
-
Struct
- Object
- Struct
- Flucti::Resources::SshDetails::AccountBinding
- Defined in:
- lib/flucti/resources/ssh_details.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #connection_command ⇒ Object
- #execute(command) ⇒ Object (also: #run)
- #execute_command(command) ⇒ Object
- #upload(*files) ⇒ Object
Instance Method Details
#connect ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/flucti/resources/ssh_details.rb', line 21 def connect check_for_presence_of_ssh do command = connection_command $stderr.puts "Connecting to VPS with: `#{command}'" exec(command) end end |
#connection_command ⇒ Object
17 18 19 |
# File 'lib/flucti/resources/ssh_details.rb', line 17 def connection_command "ssh -p #{port} #{login}@#{host}" end |
#execute(command) ⇒ Object Also known as: run
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/flucti/resources/ssh_details.rb', line 33 def execute(command) check_for_presence_of_ssh do command = execute_command(command) $stderr.puts "Executing: #{command}" # For some reason, `exec' won't work, it throws the following error: # `Operation not supported' (Errno::E045). `system' causes this too # sometimes, but so much less often that it's bearable. system(command) end end |
#execute_command(command) ⇒ Object
29 30 31 |
# File 'lib/flucti/resources/ssh_details.rb', line 29 def execute_command(command) %(#{connection_command} 'echo "#{command.gsub /"/, '\"'}" | bash -l -s') end |
#upload(*files) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/flucti/resources/ssh_details.rb', line 46 def upload(*files) check_for_presence_of_scp do command = %(scp -P #{port} #{files * ' '} #{login}@#{host}:~) $stderr.puts "Executing: #{command}" system(command) end end |