Sha256: 0e46e8576208a1bfe02988d3e8c6ad5ff3ed039a0b45bdb302408b0300cb0746

Contents?: true

Size: 1.39 KB

Versions: 18

Compression:

Stored size: 1.39 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'aws/s3'

include AWS::S3

USER_DATA = `wget -q -O - http://169.254.169.254/latest/user-data`.split("\n")

bucket_name = 'rhoconnect'
channel     = ARGV[0]
files       = []

exit if ARGV.length != 1

def cmd(cmd)
  puts cmd
  system(cmd)
end #cmd

def get_access_keys
  access_key        = USER_DATA[0].to_s.strip
  secret_access_key = USER_DATA[1].to_s.strip
  keys = { :access_key_id => access_key,
           :secret_access_key => secret_access_key}
end #get_access_keys

AWS::S3::Base.establish_connection!(get_access_keys)

objects = Bucket.objects(bucket_name)

objects.each do |obj|
  files << "#{obj.key}" if obj.key =~ /^#{channel}/
end

# Remove the files before downloading new in case they already exist
cmd "rm -rf #{channel}" if File.directory? channel
cmd "rm -f #{channel}/SHA1/checksum" if File.exists?("#{channel}/SHA1/checksum")

puts "Downloading S3 files"
files.each do |file|
  cmd = "wget -qx -P #{channel} \"http://#{bucket_name}.s3.amazonaws.com/#{file}\""
  puts cmd
  system(cmd)
end #do

# The download increases the depth of the files by two folders.
# Remove exess directory levels.
cmd "mv -f #{channel}/#{bucket_name}.s3.amazonaws.com/#{channel}/* #{channel}"
cmd "rm -rf #{channel}/#{bucket_name}.s3.amazonaws.com"

# Pull the SHA1 checksum out
cmd "mv -f #{channel}/SHA1/checksum ."
cmd "mv -f checksum old_checksum"
cmd "rm -rf #{channel}/SHA1"

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rhoconnect-3.4.2 installer/utils/download_from_s3.rb
rhoconnect-3.3.6 installer/utils/download_from_s3.rb
rhoconnect-3.3.5 installer/utils/download_from_s3.rb
rhoconnect-3.3.4 installer/utils/download_from_s3.rb
rhoconnect-3.3.3 installer/utils/download_from_s3.rb
rhoconnect-3.3.2 installer/utils/download_from_s3.rb
rhoconnect-3.3.1 installer/utils/download_from_s3.rb
rhoconnect-3.3.1.beta4 installer/utils/download_from_s3.rb
rhoconnect-3.3.1.beta3 installer/utils/download_from_s3.rb
rhoconnect-3.3.1.beta2 installer/utils/download_from_s3.rb
rhoconnect-3.2.1 installer/utils/download_from_s3.rb
rhoconnect-3.2.0 installer/utils/download_from_s3.rb
rhoconnect-3.2.0.beta5 installer/utils/download_from_s3.rb
rhoconnect-3.2.0.beta4 installer/utils/download_from_s3.rb
rhoconnect-3.2.0.beta3 installer/utils/download_from_s3.rb
rhoconnect-3.2.0.beta2 installer/utils/download_from_s3.rb
rhoconnect-3.2.0.beta1 installer/utils/download_from_s3.rb
rhoconnect-3.1.2 installer/utils/download_from_s3.rb