Class: DanarchyDeploy::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy/installer.rb

Class Method Summary collapse

Class Method Details

.new(deployment, options) ⇒ Object



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/danarchy_deploy/installer.rb', line 4

def self.new(deployment, options)
  # available opts: { pretend: true|false }
  abort('Operating System not defined! Exiting!') if !deployment[:os]
  puts "\n" + self.name

  installer, updater, cleaner = prep_operating_system(deployment, options)
  install_result = nil
  if deployment[:packages]
    packages = deployment[:packages].join(' ')
    install_result = DanarchyDeploy::Helpers.run_command("#{installer} #{packages}", options)
  else
    puts 'No packages to install.'
  end

  if !options[:pretend]
    puts "\nRunning system updates..."
    updater_result = DanarchyDeploy::Helpers.run_command(updater, options)
    puts updater_result[:stdout] if updater_result[:stdout]
    puts "\nCleaning up unused packages..."
    cleanup_result = DanarchyDeploy::Helpers.run_command(cleaner, options)
    puts cleanup_result[:stdout] if cleanup_result[:stdout]
  end

  # [install_result, cleanup_result, updater_result]
  deployment
end