Class: Inspec::Resources::Runit
- Inherits:
-
ServiceManager
- Object
- ServiceManager
- Inspec::Resources::Runit
- Defined in:
- lib/inspec/resources/service.rb
Instance Attribute Summary
Attributes inherited from ServiceManager
Instance Method Summary collapse
-
#info(service_name) ⇒ Object
rubocop:disable Style/DoubleNegation.
-
#initialize(service_name, service_ctl = nil) ⇒ Runit
constructor
A new instance of Runit.
Constructor Details
#initialize(service_name, service_ctl = nil) ⇒ Runit
Returns a new instance of Runit.
605 606 607 608 |
# File 'lib/inspec/resources/service.rb', line 605 def initialize(service_name, service_ctl = nil) @service_ctl = service_ctl || "sv" super end |
Instance Method Details
#info(service_name) ⇒ Object
rubocop:disable Style/DoubleNegation
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
# File 'lib/inspec/resources/service.rb', line 611 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 |