class Inspec::Resources::Upstart
@see: upstart.ubuntu.com
Public Class Methods
new(service_name, service_ctl = nil)
click to toggle source
Calls superclass method
Inspec::Resources::ServiceManager::new
# File lib/inspec/resources/service.rb, line 383 def initialize(service_name, service_ctl = nil) @service_ctl = service_ctl || "initctl" super end
Public Instance Methods
info(service_name)
click to toggle source
# File lib/inspec/resources/service.rb, line 388 def info(service_name) # get the status of upstart service status = inspec.command("#{service_ctl} status #{service_name}") # fallback for systemv services, those are not handled via `initctl` return SysV.new(inspec).info(service_name) if status.exit_status.to_i != 0 || status.stdout == "" # @see: http://upstart.ubuntu.com/cookbook/#job-states # grep for running to indicate the service is there running = !status.stdout[%r{start/running}].nil? enabled = info_enabled(service_name) { name: service_name, description: nil, installed: true, running: running, enabled: enabled, type: "upstart", } end
Private Instance Methods
info_enabled(service_name)
click to toggle source
# File lib/inspec/resources/service.rb, line 412 def info_enabled(service_name) # check if a service is enabled config = read_file_content("/etc/init/#{service_name}.conf", allow_empty: true) !config.match(/^\s*start on/).nil? end
version()
click to toggle source
# File lib/inspec/resources/service.rb, line 419 def version @version ||= begin out = inspec.command("#{service_ctl} --version").stdout Gem::Version.new(out[/\(upstart ([^\)]+)\)/, 1]) end end