Sha256: 4e9bf1d92c75cade7f87f6d8dd61a55ebe64dfd19b1a3b306521be5060483b8b
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
module Vagrant module Zscp # This is a helper that abstracts out the functionality of scping # folders so that it can be called from anywhere. class ZscpHelper def self.scp(machine, ssh_info, opts) guestpath = opts[:guestpath] hostpath = opts[:hostpath] hostpath = File.expand_path(hostpath, machine.env.root_path) hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s if (opts[:zscp_include]) included_files = opts[:zscp_include].join(' ') else included_files = '.' end username = ssh_info[:username] host = ssh_info[:host] if !hostpath.end_with?("/") hostpath += "/" end machine.ui.info("Sending #{hostpath} to #{guestpath}") Dir.mktmpdir { |dir| machine.ui.info("Removing remote #{guestpath}") machine.communicate.execute("sudo rm -rf #{guestpath}; sudo mkdir -p #{guestpath}; sudo chown #{username}:$(id -gn) #{guestpath}") machine.ui.info("Compressing #{hostpath} into #{dir}/temp.tar.gz") `tar -czLf #{dir}/temp.tar.gz -C #{hostpath} #{included_files}` machine.ui.info("Copying #{dir}/temp.tar.gz to #{guestpath}") command = [ "scp", '-o StrictHostKeyChecking=no', '-o UserKnownHostsFile=/dev/null', "-o port=#{ssh_info[:port]}", "-i '#{ssh_info[:private_key_path][0]}'", "#{dir}/temp.tar.gz", "#{username}@#{host}:#{guestpath}" ].join(' ') system(command) machine.ui.info("Extracting remotely #{guestpath}/temp.tar.gz") machine.communicate.execute("tar -xzf #{guestpath}/temp.tar.gz -C #{guestpath}; rm #{guestpath}/temp.tar.gz") } machine.ui.info("#{guestpath} synchronised") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vagrant-zscp-0.1.2 | lib/vagrant/zscp/helper.rb |
vagrant-zscp-0.1.1 | lib/vagrant/zscp/helper.rb |
vagrant-zscp-0.1.0 | lib/vagrant/zscp/helper.rb |