Sha256: 63854690746d69f0cb7e13eaf883d876edcbe14b667d05b205e1c797d0e600c4

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

require 'configuration'
conf = "#{ENV['HOME']}/.configuration.rb"
raise "#{conf} not found, please create a conf file with a scp section" unless File.exists?(conf)
require conf

module  Opsk
  class DeployScp < Thor::Group
    include Thorable, Thor::Actions

    argument :dest, :type => :string, :desc => 'dest'

    desc 'Deploy sandbox into a remote ssh server'

    def validate
	check_root
    end


    def upload
	require 'net/scp'
	pkg = Opsk::Package.new
	tar =  "#{pkg.artifact_path}.tar.gz"
	base = File.basename(tar)
	if(File.exists?(tar))
	  begin
	    conf = Configuration.for('scp').send(dest.to_sym)
          port = conf.port || '22'
	    Net::SSH.start(conf.host, conf.user, :port => port) do |session|
            session.scp.upload!(tar, conf.dest)
          end
	    say("deployed #{base} to #{conf.user}@#{conf.host}:#{conf.dest}")
	  rescue Exception => e
	    say("failed to deploy due to #{e}")
	  end
	else
	  say('package is missing please run opsk package first')
	end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opskeleton-0.8.9 lib/opskeleton/deploy_scp.rb