Class: DanarchyDeploy::Services::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy/services/init.rb,
lib/danarchy_deploy/services/init/openrc.rb,
lib/danarchy_deploy/services/init/systemd.rb

Defined Under Namespace

Classes: Openrc, Systemd

Class Method Summary collapse

Class Method Details

.new(deployment, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/danarchy_deploy/services/init.rb', line 7

def self.new(deployment, options)
  return deployment if ! deployment[:services]
  puts "\n" + self.name

  deployment[:services].each do |service, params|
    next if ! params[:init]
    if params[:init].class == Array
      # one-time update for :init to new format
      params[:init] =  if deployment[:os] == 'gentoo'
                         { runlevel: 'default', actions: params[:init] }
                       else
                         { actions: params[:init] }
                       end
    end

    init_manager(deployment[:os], service, params[:init][:runlevel], options)
    puts "\n > Init actions for #{service}: #{params[:init][:actions].join(', ')}"
    params[:init][:actions].each do |action|
      puts "    |> Taking action: #{action} on #{service}"
      if options[:pretend]
        puts "     |- Fake run: #{action} #{service}"
      else
        init_run(action)
      end
    end
  end

  deployment
end