Class: Mixlib::Install::ScriptGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/mixlib/install/script_generator.rb

Constant Summary collapse

VALID_INSTALL_OPTS =
%w{omnibus_url
endpoint
http_proxy
https_proxy
install_flags
install_msi_url
license_id
nightlies
prerelease
project
root
use_sudo
sudo_command
base_url}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, powershell = false, opts = {}) ⇒ ScriptGenerator

Returns a new instance of ScriptGenerator.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mixlib/install/script_generator.rb', line 78

def initialize(version, powershell = false, opts = {})
  @version = (version || "latest").to_s.downcase
  @powershell = powershell
  @http_proxy = nil
  @https_proxy = nil
  @install_flags = nil
  @prerelease = false
  @nightlies = false
  @endpoint = "metadata"
  @omnibus_url = "#{Mixlib::Install::Dist::OMNITRUCK_ENDPOINT}/install.sh"
  @use_sudo = true
  @sudo_command = "sudo -E"
  @license_id = nil
  @project = Mixlib::Install::Dist::DEFAULT_PRODUCT.freeze
  @channel = "stable"

  @root = if powershell
            "$env:systemdrive\\#{Mixlib::Install::Dist::OMNIBUS_WINDOWS_INSTALL_DIR}\\#{Mixlib::Install::Dist::DEFAULT_PRODUCT}"
          else
            "#{Mixlib::Install::Dist::OMNIBUS_LINUX_INSTALL_DIR}/#{Mixlib::Install::Dist::DEFAULT_PRODUCT}"
          end

  parse_opts(opts)

  # Update root for chef-ice to use Habitat install directories
  if @project&.casecmp("chef-ice") == 0
    @root = if powershell
              "$env:systemdrive\\#{Mixlib::Install::Dist::HABITAT_WINDOWS_INSTALL_DIR}\\chef\\chef-infra-client\\*\\*"
            else
              "#{Mixlib::Install::Dist::HABITAT_LINUX_INSTALL_DIR}/chef/chef-infra-client/*/*"
            end
  end
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



61
62
63
# File 'lib/mixlib/install/script_generator.rb', line 61

def base_url
  @base_url
end

#endpointObject

Returns the value of attribute endpoint.



38
39
40
# File 'lib/mixlib/install/script_generator.rb', line 38

def endpoint
  @endpoint
end

#http_proxyObject

Returns the value of attribute http_proxy.



54
55
56
# File 'lib/mixlib/install/script_generator.rb', line 54

def http_proxy
  @http_proxy
end

#https_proxyObject

Returns the value of attribute https_proxy.



55
56
57
# File 'lib/mixlib/install/script_generator.rb', line 55

def https_proxy
  @https_proxy
end

#install_flagsObject

Returns the value of attribute install_flags.



36
37
38
# File 'lib/mixlib/install/script_generator.rb', line 36

def install_flags
  @install_flags
end

#install_msi_urlObject

Returns the value of attribute install_msi_url.



58
59
60
# File 'lib/mixlib/install/script_generator.rb', line 58

def install_msi_url
  @install_msi_url
end

#license_idObject

Returns the value of attribute license_id.



60
61
62
# File 'lib/mixlib/install/script_generator.rb', line 60

def license_id
  @license_id
end

#nightliesObject

Returns the value of attribute nightlies.



34
35
36
# File 'lib/mixlib/install/script_generator.rb', line 34

def nightlies
  @nightlies
end

#omnibus_urlObject

Returns the value of attribute omnibus_url.



57
58
59
# File 'lib/mixlib/install/script_generator.rb', line 57

def omnibus_url
  @omnibus_url
end

#powershellObject

Returns the value of attribute powershell.



30
31
32
# File 'lib/mixlib/install/script_generator.rb', line 30

def powershell
  @powershell
end

#prereleaseObject

Returns the value of attribute prerelease.



32
33
34
# File 'lib/mixlib/install/script_generator.rb', line 32

def prerelease
  @prerelease
end

#rootObject

Returns the value of attribute root.



40
41
42
# File 'lib/mixlib/install/script_generator.rb', line 40

def root
  @root
end

#sudo_commandObject

Returns the value of attribute sudo_command.



44
45
46
# File 'lib/mixlib/install/script_generator.rb', line 44

def sudo_command
  @sudo_command
end

#use_sudoObject

Returns the value of attribute use_sudo.



42
43
44
# File 'lib/mixlib/install/script_generator.rb', line 42

def use_sudo
  @use_sudo
end

#versionObject

Returns the value of attribute version.



28
29
30
# File 'lib/mixlib/install/script_generator.rb', line 28

def version
  @version
end

Instance Method Details

#install_commandObject



112
113
114
115
116
117
118
119
# File 'lib/mixlib/install/script_generator.rb', line 112

def install_command
  vars = if powershell
           install_command_vars_for_powershell
         else
           install_command_vars_for_bourne
         end
  shell_code_from_file(vars)
end