Class: AutomateIt::ServiceManager::UpdateRCD

Inherits:
SYSV
  • Object
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"

Instance Method Summary collapse

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