Module: Lono::Template::Strategy::Common::Helpers
- Included in:
- Dsl::Builder::Helpers
- Defined in:
- lib/lono/template/strategy/common/helpers.rb
Instance Method Summary collapse
-
#extract_scripts(options = {}) ⇒ Object
Bash code that is meant to included in user-data.
- #scripts_name ⇒ Object
- #scripts_s3_path ⇒ Object
- #setting ⇒ Object
Instance Method Details
#extract_scripts(options = {}) ⇒ Object
Bash code that is meant to included in user-data
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lono/template/strategy/common/helpers.rb', line 4 def extract_scripts(={}) settings = setting.data["extract_scripts"] || {} = settings.merge() # defaults also here in case they are removed from settings to = [:to] || "/opt" user = [:as] || "ec2-user" if Dir.glob("#{Lono.config.scripts_path}/*").empty? puts "WARN: you are using the extract_scripts helper method but you do not have any app/scripts.".color(:yellow) calling_line = caller[0].split(':')[0..1].join(':') puts "Called from: #{calling_line}" return "" end <<~BASH_CODE # Generated from the lono 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} chown -R #{user}:#{user} #{to}/scripts ) BASH_CODE end |
#scripts_name ⇒ Object
31 32 33 |
# File 'lib/lono/template/strategy/common/helpers.rb', line 31 def scripts_name File.basename(scripts_s3_path) end |