mirror of
https://github.com/inspec/inspec
synced 2024-11-14 17:07:09 +00:00
add service implementation for systemv
This commit is contained in:
parent
eb8c9411c7
commit
7239c7ced5
1 changed files with 26 additions and 0 deletions
|
@ -148,6 +148,32 @@ end
|
|||
|
||||
class SysV < ServiceManager
|
||||
def info(service_name)
|
||||
|
||||
# check if service is installed
|
||||
filename = "/etc/init/#{service_name}.conf"
|
||||
service = @vulcano.file(filename)
|
||||
|
||||
# check if service is installed
|
||||
return nil if !service.exists?
|
||||
|
||||
# check if service is enabled
|
||||
match_enabled = /^\s*start on/.match(service.content)
|
||||
!match_enabled.nil? ? (enabled = true) : (enabled = false)
|
||||
|
||||
# check if service is really running
|
||||
# service throws an exit code if the service is not installed or
|
||||
# not enabled
|
||||
cmd = @vulcano.run_command("service #{service_name} status")
|
||||
cmd.exit_status == 0 ? (running = true) : (running = false)
|
||||
|
||||
{
|
||||
name: service_name,
|
||||
description: '',
|
||||
installed: true,
|
||||
running: running,
|
||||
enabled: enabled,
|
||||
type: 'upstart',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue