diff --git a/lib/mixlib/install/generator.rb b/lib/mixlib/install/generator.rb index 74ea6748..ce9853dd 100644 --- a/lib/mixlib/install/generator.rb +++ b/lib/mixlib/install/generator.rb @@ -22,11 +22,10 @@ module Mixlib class Install class Generator def self.install_command(options) - if options.for_ps1? - PowerShell.new(options).install_command - else - Bourne.new(options).install_command - end + klass = options.for_ps1? ? PowerShell : Bourne + meth = options.options[:new_omnibus_download_url] ? :install_sh_from_upstream : :install_command + + klass.new(options).send(meth) end end end diff --git a/lib/mixlib/install/generator/base.rb b/lib/mixlib/install/generator/base.rb index b6adf071..aabce1f5 100644 --- a/lib/mixlib/install/generator/base.rb +++ b/lib/mixlib/install/generator/base.rb @@ -19,6 +19,7 @@ require "ostruct" unless defined?(OpenStruct) require_relative "../util" require_relative "../dist" +require "net/http" unless defined?(Net::HTTP) module Mixlib class Install @@ -68,6 +69,17 @@ def self.get_script(name, context = {}) def get_script(name, context = {}) self.class.get_script(name, context) end + + def install_sh_from_upstream + uri = URI.parse(options.options[:new_omnibus_download_url]) + response = Net::HTTP.get_response(uri) + + if response.code == "200" + response.body + else + raise StandardError, "unable to fetch the install.sh" + end + end end end end diff --git a/lib/mixlib/install/script_generator.rb b/lib/mixlib/install/script_generator.rb index 567ba992..82b52a9d 100644 --- a/lib/mixlib/install/script_generator.rb +++ b/lib/mixlib/install/script_generator.rb @@ -21,6 +21,7 @@ require_relative "generator/powershell" require_relative "dist" require "cgi" +require "net/http" unless defined?(Net::HTTP) module Mixlib class Install @@ -101,6 +102,17 @@ def install_command shell_code_from_file(vars) end + def install_command_from_omnitruck(url) + uri = URI.parse(url) + response = Net::HTTP.get_response(uri) + + if response.code == "200" + response.body + else + raise StandardError, "unable to fetch the install.sh" + end + end + private # Generates the install command variables for Bourne shell-based