mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
add AIX service support
This commit is contained in:
parent
59d1849607
commit
b9ce468886
1 changed files with 43 additions and 0 deletions
|
@ -80,6 +80,8 @@ class Service < Inspec.resource(1)
|
|||
@service_mgmt = BSDInit.new(inspec)
|
||||
when 'arch', 'opensuse'
|
||||
@service_mgmt = Systemd.new(inspec)
|
||||
when 'aix'
|
||||
@service_mgmt = SrcMstr.new(inspec)
|
||||
end
|
||||
|
||||
return skip_resource 'The `service` resource is not supported on your OS yet.' if @service_mgmt.nil?
|
||||
|
@ -155,6 +157,47 @@ class Systemd < ServiceManager
|
|||
end
|
||||
end
|
||||
|
||||
# AIX services
|
||||
class SrcMstr < ServiceManager
|
||||
attr_reader :name
|
||||
|
||||
def info(service_name)
|
||||
@name = service_name
|
||||
running = status?
|
||||
return nil if running.nil?
|
||||
|
||||
{
|
||||
name: service_name,
|
||||
description: nil,
|
||||
installed: true,
|
||||
running: running,
|
||||
enabled: enabled?,
|
||||
type: 'srcmstr',
|
||||
}
|
||||
end
|
||||
|
||||
def status?
|
||||
status_cmd = inspec.command("lssrc -s #{@name}")
|
||||
return nil if status_cmd.exit_status.to_i != 0
|
||||
status_cmd.stdout.split(/\n/).last.chomp.match(/active$/) ? true : false
|
||||
end
|
||||
|
||||
def enabled?
|
||||
enabled_rc_tcpip? || enabled_inittab?
|
||||
end
|
||||
|
||||
private
|
||||
def enabled_rc_tcpip?
|
||||
inspec.command("grep -v ^# /etc/rc.tcpip | grep 'start ' | grep -Eq '(/{0,1}| )#{@name} '") \
|
||||
? true \
|
||||
: false
|
||||
end
|
||||
|
||||
def enabled_inittab?
|
||||
inspec.command("lsitab #{@name}").exit_status.to_i == 0 ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
# @see: http://upstart.ubuntu.com
|
||||
class Upstart < ServiceManager
|
||||
def info(service_name)
|
||||
|
|
Loading…
Reference in a new issue