Class: AutomateIt::ServiceManager::UpdateRCD

Inherits:
SYSV show all
Defined in:
lib/automateit/service_manager/update_rcd.rb

Overview

ServiceManager::UpdateRCD

The UpdateRCD driver implements the ServiceManager methods for #enabled?, #enable and #disable on Debian-like platforms. It uses the SYSV driver for handling the methods #running?, #start and #stop.

Constant Summary collapse

TOOL =
"update-rc.d"

Constants inherited from SYSV

SYSV::ETC_INITD

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

#manager

Attributes inherited from Common

#interpreter

Instance Method Summary collapse

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

#setup, #token, token

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



23
24
25
26
27
# File 'lib/automateit/service_manager/update_rcd.rb', line 23

def disable(service, opts={})
  _raise_unless_available
  return false unless enabled?(service)
  interpreter.sh("#{TOOL} -f #{service} remove < /dev/null > /dev/null")
end

#enable(service, opts = {}) ⇒ Object

See ServiceManager#enable



16
17
18
19
20
# File 'lib/automateit/service_manager/update_rcd.rb', line 16

def enable(service, opts={})
  _raise_unless_available
  return false if enabled?(service)
  interpreter.sh("#{TOOL} #{service} defaults < /dev/null > /dev/null")
end

#enabled?(service, opts = {}) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
# File 'lib/automateit/service_manager/update_rcd.rb', line 29

def enabled?(service, opts={})
  _raise_unless_available
  cmd = "#{TOOL} -n -f #{service} remove < /dev/null"
  output = `#{cmd}`
  return ! output.match(/etc\/rc[\dS].d|Nothing to do\./).nil?
end

#suitability(method, *args) ⇒ Object

:nodoc:



11
12
13
# File 'lib/automateit/service_manager/update_rcd.rb', line 11

def suitability(method, *args) # :nodoc:
  return available? ? 3 : 0
end