Module: ChefUtils::DSL::Service

Extended by:
Service
Includes:
Introspection, TrainHelpers, Internal
Included in:
Service
Defined in:
lib/chef-utils/dsl/service.rb

Overview

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

Instance Method Summary collapse

Methods included from Introspection

#ci?, #docker?, #effortless?, #has_systemd_service_unit?, #has_systemd_unit?, #includes_recipe?, #kitchen?, #systemd?

Methods included from TrainHelpers

#dir_exist?, #file_directory?, #file_exist?, #file_open, #file_read

Instance Method Details

#debianrcd?Boolean

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

Returns:

  • (Boolean)

Since:

  • 15.5



37
38
39
# File 'lib/chef-utils/dsl/service.rb', line 37

def debianrcd?
  file_exist?("/usr/sbin/update-rc.d")
end

#insserv?Boolean

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

Returns:

  • (Boolean)

Since:

  • 15.5



67
68
69
# File 'lib/chef-utils/dsl/service.rb', line 67

def insserv?
  file_exist?("/sbin/insserv")
end

#invokercd?Boolean

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

Returns:

  • (Boolean)

Since:

  • 15.5



47
48
49
# File 'lib/chef-utils/dsl/service.rb', line 47

def invokercd?
  file_exist?("/usr/sbin/invoke-rc.d")
end

#redhatrcd?Boolean

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

Returns:

  • (Boolean)

Since:

  • 15.5



77
78
79
# File 'lib/chef-utils/dsl/service.rb', line 77

def redhatrcd?
  file_exist?("/sbin/chkconfig")
end

#service_script_exist?(type, script) ⇒ Boolean

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’)

Parameters:

  • type (Symbol)

    The type of init system. :initd, :upstart, :xinetd, :etc_rcd, or :systemd

  • script (String)

    The name of the service

Returns:

  • (Boolean)

Since:

  • 15.5



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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?Boolean

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

Returns:

  • (Boolean)

Since:

  • 15.5



57
58
59
# File 'lib/chef-utils/dsl/service.rb', line 57

def upstart?
  file_exist?("/sbin/initctl")
end