Sha256: b421410a7a5aecce31c70a12ee8a571d771fec0f5407fd5c497faff1891f5fef
Contents?: true
Size: 1.5 KB
Versions: 18
Compression:
Stored size: 1.5 KB
Contents
module AwsEc2::Template::Helper::ScriptHelper # Bash code that is meant to included in user-data def extract_scripts(options={}) check_s3_folder_settings! settings_options = settings["extract_scripts"] || {} options = settings_options.merge(options) # defaults also here in case they are removed from settings to = options[:to] || "/opt" user = options[:as] || "ec2-user" if Dir.glob("#{AwsEc2.root}/app/scripts*").empty? puts "WARN: you are using the extract_scripts helper method but you do not have any app/scripts.".colorize(:yellow) calling_line = caller[0].split(':')[0..1].join(':') puts "Called from: #{calling_line}" return "" end <<-BASH_CODE # Generated from the aws-ec2 extract_scripts helper. # Downloads scripts from s3, extract them, and setup. mkdir -p #{to} aws s3 cp #{scripts_s3_path} #{to}/ ( cd #{to} tar zxf #{to}/#{scripts_name} chmod -R a+x #{to}/scripts chown -R #{user}:#{user} #{to}/scripts ) BASH_CODE end private def check_s3_folder_settings! return if settings["s3_folder"] puts "Helper method called that requires the s3_folder to be set at:" lines = caller.reject { |l| l =~ %r{lib/aws-ec2} } # hide internal aws-ec2 trace puts " #{lines[0]}" puts "Please configure your config/settings.yml with an s3_folder.".colorize(:red) exit 1 end def scripts_name File.basename(scripts_s3_path) end def scripts_s3_path upload = AwsEc2::Script::Upload.new upload.s3_dest end end
Version data entries
18 entries across 18 versions & 1 rubygems