mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
select init system by os version for now
This commit is contained in:
parent
4479001763
commit
1b5e6fa7af
1 changed files with 31 additions and 0 deletions
|
@ -17,6 +17,32 @@ class Service < Vulcano.resource(1)
|
|||
@service_mgmt = nil
|
||||
@cache = nil
|
||||
case vulcano.os[:family]
|
||||
# Ubuntu
|
||||
# @see: https://wiki.ubuntu.com/SystemdForUpstartUsers
|
||||
# Ubuntu 15.04 : Systemd
|
||||
# Systemd runs with PID 1 as /sbin/init.
|
||||
# Upstart runs with PID 1 as /sbin/upstart.
|
||||
# Ubuntu < 15.04 : Upstart
|
||||
# Upstart runs with PID 1 as /sbin/init.
|
||||
# Systemd runs with PID 1 as /lib/systemd/systemd.
|
||||
when 'ubuntu'
|
||||
version = os[:release].to_f
|
||||
if version < 15.04
|
||||
# upstart
|
||||
@service_mgmt = Upstart.new(vulcano)
|
||||
else
|
||||
# sysyemd
|
||||
@service_mgmt = Systemd.new(vulcano)
|
||||
end
|
||||
when 'redhat', 'fedora'
|
||||
version = os[:release].to_i
|
||||
if version >= 7
|
||||
# systemd
|
||||
@service_mgmt = Systemd.new(vulcano)
|
||||
else
|
||||
# sysv
|
||||
@service_mgmt = SysV.new(vulcano)
|
||||
end
|
||||
when 'windows'
|
||||
@service_mgmt = WindowsSrv.new(vulcano)
|
||||
end
|
||||
|
@ -119,6 +145,11 @@ class Upstart < ServiceManager
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
class SysV < ServiceManager
|
||||
def info(service_name)
|
||||
end
|
||||
end
|
||||
# Determine the service state from Windows
|
||||
# Uses Powershell to retrieve the information
|
||||
class WindowsSrv < ServiceManager
|
||||
|
|
Loading…
Reference in a new issue