Sha256: b155d17e5a917e83953e7c4756e6495cca64140d60adc7305a2c050e250708ad

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require 'devinstall/utils'
require 'devinstall/settings'

module Provider
  module Ssh
    include Utils

    SETTINGS = {
        build:   [:user, :host],
        install: [:user, :host],
        tests:   [:user, :host],
        repos:   [:user, :host],
        ssh:     [:ssh, :scp, :rsync, :sudo]
    }

    def upload_sources(cfg, src, dst)
      config =Devinstall::Settings.instance
      rsync  = config.ssh(:rsync)
      source = src[-1]=='/' ? src : "#{src}/"       # source folder(we add / because we are using rsync)
      dest   = "#{cfg[:user]}@#{cfg[:host]}:#{dst}" # cfg should provide user and host
      command("#{rsync} #{source} #{dest}")
    end

    def download_file(cfg, file, local)
      config=Devinstall::Settings.instance
      rsync = config.ssh(:rsync) # should be config.provider[:ssh][:rsync]
      command("#{rsync} -az #{cfg[:user]}@#{cfg[:host]}:#{cfg[:target]}/#{file.to_s} #{local}")
    end

    def upload_file(cfg, file, local)
      config=Devinstall::Settings.instance
      scp   = config.ssh(:scp) # should be config.provider[:ssh][:scp]
      hosts = Array === cfg[:host] ? cfg[:host] : [cfg[:host]]
      hosts.each do |host|
        command("#{scp} #{local}/#{file} #{cfg[:user]}@#{host}:#{cfg[:folder]}")
      end
    end

    def exec_command(cfg, command)
      config=Devinstall::Settings.instance
      ssh   = config.ssh(:ssh) # should be config.provider[:ssh][:scp]
      hosts = Array === cfg[:host] ? cfg[:host] : [cfg[:host]]
      hosts.each do |host|
        command("#{ssh} #{cfg[:user]}@#{host} \"#{command}\"")
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devinstall-1.2.2 lib/devinstall/provider/provider_ssh.rb
devinstall-1.2.1 lib/devinstall/provider/provider_ssh.rb
devinstall-1.2.0 lib/devinstall/provider/provider_ssh.rb