module ChefUtils::DSL::Service

NOTE: these are mixed into the service resource+providers specifically and deliberately not injected into the global namespace

Public Instance Methods

debianrcd?() click to toggle source

Returns if debian's old rc.d manager is installed (not necessarily the primary init system).

@since 15.5

@return [Boolean]

# File lib/chef-utils/dsl/service.rb, line 37
def debianrcd?
  file_exist?("/usr/sbin/update-rc.d")
end
insserv?() click to toggle source

Returns if insserv is installed (not necessarily the primary init system).

@since 15.5

@return [Boolean]

# File lib/chef-utils/dsl/service.rb, line 67
def insserv?
  file_exist?("/sbin/insserv")
end
invokercd?() click to toggle source

Returns if debian's old invoke rc.d manager is installed (not necessarily the primary init system).

@since 15.5

@return [Boolean]

# File lib/chef-utils/dsl/service.rb, line 47
def invokercd?
  file_exist?("/usr/sbin/invoke-rc.d")
end
redhatrcd?() click to toggle source

Returns if redhat's init system is installed (not necessarily the primary init system).

@since 15.5

@return [Boolean]

# File lib/chef-utils/dsl/service.rb, line 77
def redhatrcd?
  file_exist?("/sbin/chkconfig")
end
service_script_exist?(type, script) click to toggle source

Returns if a particular service exists for a particular service init system. Init systems may be :initd, :upstart, :etc_rcd, :xinetd, and :systemd. Example: service_script_exist?(:systemd, 'ntpd')

@param [Symbol] type The type of init system. :initd, :upstart, :xinetd, :etc_rcd, or :systemd @param [String] script The name of the service @since 15.5

@return [Boolean]

# File lib/chef-utils/dsl/service.rb, line 90
def service_script_exist?(type, script)
  case type
  when :initd
    file_exist?("/etc/init.d/#{script}")
  when :upstart
    file_exist?("/etc/init/#{script}.conf")
  when :xinetd
    file_exist?("/etc/xinetd.d/#{script}")
  when :etc_rcd
    file_exist?("/etc/rc.d/#{script}")
  when :systemd
    file_exist?("/etc/init.d/#{script}") ||
      has_systemd_service_unit?(script) ||
      has_systemd_unit?(script)
  else
    raise ArgumentError, "type of service must be one of :initd, :upstart, :xinetd, :etc_rcd, or :systemd"
  end
end
upstart?() click to toggle source

Returns if upstart is installed (not necessarily the primary init system).

@since 15.5

@return [Boolean]

# File lib/chef-utils/dsl/service.rb, line 57
def upstart?
  file_exist?("/sbin/initctl")
end