Sha256: 6baedd55b4b1ba1d6eb9407e9b703d09630d583e7d02233ad716e370e69cbbc0

Contents?: true

Size: 1.07 KB

Versions: 31

Compression:

Stored size: 1.07 KB

Contents

# == 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.
class AutomateIt::ServiceManager::UpdateRCD < AutomateIt::ServiceManager::SYSV
  TOOL = "update-rc.d"

  depends_on :programs => [TOOL]

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

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

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

  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
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
automate-it-0.9.2 lib/automateit/service_manager/update_rcd.rb
automate-it-0.9.1 lib/automateit/service_manager/update_rcd.rb
automate-it-0.9.0 lib/automateit/service_manager/update_rcd.rb
automateit-0.70930 lib/automateit/service_manager/update_rcd.rb
automateit-0.71003 lib/automateit/service_manager/update_rcd.rb
automateit-0.70923 lib/automateit/service_manager/update_rcd.rb
automateit-0.70928 lib/automateit/service_manager/update_rcd.rb
automateit-0.71030 lib/automateit/service_manager/update_rcd.rb
automateit-0.71021 lib/automateit/service_manager/update_rcd.rb
automateit-0.71017 lib/automateit/service_manager/update_rcd.rb
automateit-0.71031.2 lib/automateit/service_manager/update_rcd.rb
automateit-0.71006 lib/automateit/service_manager/update_rcd.rb
automateit-0.71012 lib/automateit/service_manager/update_rcd.rb
automateit-0.71031.1 lib/automateit/service_manager/update_rcd.rb
automateit-0.71031 lib/automateit/service_manager/update_rcd.rb
automateit-0.71101 lib/automateit/service_manager/update_rcd.rb
automateit-0.71101.1 lib/automateit/service_manager/update_rcd.rb
automateit-0.71101.2 lib/automateit/service_manager/update_rcd.rb
automateit-0.71102 lib/automateit/service_manager/update_rcd.rb
automateit-0.71103 lib/automateit/service_manager/update_rcd.rb