Class: AutomateIt::ServiceManager::Chkconfig
- Inherits:
-
SYSV
- Object
- Common
- Plugin::Base
- Plugin::Driver
- BaseDriver
- SYSV
- AutomateIt::ServiceManager::Chkconfig
- Defined in:
- lib/automateit/service_manager/chkconfig.rb
Overview
ServiceManager::Chkconfig
The Chkconfig driver implements the ServiceManager methods for #enabled?, #enable and #disable on RedHat-like platforms. It uses the SYSV driver for handling the methods #running?, #start and #stop.
Constant Summary
Constants inherited from SYSV
Constants inherited from Plugin::Driver
Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#disable(service, opts = {}) ⇒ Object
See ServiceManager#disable.
-
#enable(service, opts = {}) ⇒ Object
See ServiceManager#enable.
-
#enabled?(service) ⇒ Boolean
See ServiceManager#enabled?.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
Methods inherited from SYSV
#restart, #running?, #start, #started?, #stop, #stopped?, #tell
Methods inherited from BaseDriver
#start_and_enable, #start_or_restart
Methods inherited from Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #setup
Methods inherited from Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#disable(service, opts = {}) ⇒ Object
See ServiceManager#disable
34 35 36 37 38 |
# File 'lib/automateit/service_manager/chkconfig.rb', line 34 def disable(service, opts={}) _raise_unless_available return false unless enabled?(service) interpreter.sh("chkconfig --del #{service}") end |
#enable(service, opts = {}) ⇒ Object
See ServiceManager#enable
27 28 29 30 31 |
# File 'lib/automateit/service_manager/chkconfig.rb', line 27 def enable(service, opts={}) _raise_unless_available return false if enabled?(service) interpreter.sh("chkconfig --add #{service}") end |
#enabled?(service) ⇒ Boolean
See ServiceManager#enabled?
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/automateit/service_manager/chkconfig.rb', line 14 def enabled?(service) _raise_unless_available # "chkconfig --list service" may produce output like the below: # service httpd supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add automateit_service_sysv_test') # => httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off if matcher = `chkconfig --list #{service} < /dev/null 2>&1` \ .match(/^(#{service}).+?(\d+:(on|off).+?)$/) return true if matcher[2].match(/\b\d+:on\b/) end return false end |
#suitability(method, *args) ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/automateit/service_manager/chkconfig.rb', line 9 def suitability(method, *args) # :nodoc: return available? ? 2 : 0 end |