Method: Inspec::Resources::Runit#info

Defined in:
lib/resources/service.rb

#info(service_name) ⇒ Object

rubocop:disable Style/DoubleNegation



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/resources/service.rb', line 492

def info(service_name)
  # get the status of runit service
  cmd = inspec.command("#{service_ctl} status #{service_name}")
  # return nil unless cmd.exit_status == 0 # NOTE(sr) why do we do this?

  installed = cmd.exit_status == 0
  running = installed && !!(cmd.stdout =~ /^run:/)
  enabled = installed && (running || !!(cmd.stdout =~ /normally up/) || !!(cmd.stdout =~ /want up/))

  {
    name: service_name,
    description: nil,
    installed: installed,
    running: running,
    enabled: enabled,
    type: 'runit',
  }
end