Class: Optimacms::Appdata::RsyncCommand
- Inherits:
-
Object
- Object
- Optimacms::Appdata::RsyncCommand
- Defined in:
- lib/optimacms/appdata/rsync_command.rb
Class Method Summary collapse
- .build_cmd_with_ssh_save(storage, d_local_full, d_remote) ⇒ Object
- .build_cmd_with_ssh_update(storage, d_local_full, d_remote) ⇒ Object
- .build_ssh_opts(storage) ⇒ Object
Class Method Details
.build_cmd_with_ssh_save(storage, d_local_full, d_remote) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/optimacms/appdata/rsync_command.rb', line 6 def self.build_cmd_with_ssh_save(storage, d_local_full, d_remote) s_ssh = " #{storage['ssh_user']}@#{storage['host']}" ssh_opts = build_ssh_opts(storage) cmd_rsync = %Q(rsync -Lavrt -e "ssh #{ssh_opts}" #{d_local_full} #{s_ssh}:#{d_remote} --delete) cmd = nil if storage['ssh_key'] && storage['ssh_key']!='' # use ssh key cmd = cmd_rsync else # use sshpass with password cmd = %Q(sshpass -p #{storage['ssh_password']} #{cmd_rsync}) end cmd end |
.build_cmd_with_ssh_update(storage, d_local_full, d_remote) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/optimacms/appdata/rsync_command.rb', line 25 def self.build_cmd_with_ssh_update(storage, d_local_full, d_remote) s_ssh = " #{storage['ssh_user']}@#{storage['host']}" ssh_opts = build_ssh_opts(storage) cmd_rsync = %Q(rsync -Lavrt -e "ssh #{ssh_opts}" #{s_ssh}:#{d_remote} #{d_local_full} --delete) cmd = nil if storage['ssh_key'] && storage['ssh_key']!='' # use ssh key cmd = cmd_rsync else # use sshpass with password cmd = %Q(sshpass -p #{storage['ssh_password']} #{cmd_rsync}) end cmd end |
.build_ssh_opts(storage) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/optimacms/appdata/rsync_command.rb', line 46 def self.build_ssh_opts(storage) ssh_opts = "-p #{storage['ssh_port']||22} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" if storage['ssh_key'] && storage['ssh_key']!='' ssh_opts << " -i #{storage['ssh_key']}" end ssh_opts end |