Sha256: 459ed784e68f0fad09820f80d0f0e89316e4296cede6c11c403622149b0ff3a8

Contents?: true

Size: 1.21 KB

Versions: 31

Compression:

Stored size: 1.21 KB

Contents

# == ServiceManager::RC_Update
#
# RC_Update implements the #enabled?, #enable and #disable features of the
# ServiceManager on Gentoo-like systems.
class AutomateIt::ServiceManager::RC_Update < AutomateIt::ServiceManager::SYSV
  depends_on :programs => %w(rc-update)

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

  # See ServiceManager#enabled?
  def enabled?(service)
    _raise_unless_available
    # Do NOT use Gentoo's rc-update because the idiot that wrote that utility
    # truncates service names to look "prettier" and provides no way to disable
    # this annoyance for people that need to query services by name.
    result = %w(boot default).select do |runlevel|
      File.exists?(File.join("/etc/runlevels", runlevel, service))
    end
    return ! result.empty?
  end

  # See ServiceManager#enable
  def enable(service, opts={})
    _raise_unless_available
    return false if enabled?(service)
    interpreter.sh("rc-update add #{service} default > /dev/null 2>&1")
  end

  # See ServiceManager#disable
  def disable(service, opts={})
    _raise_unless_available
    return false unless enabled?(service)
    interpreter.sh("rc-update del #{service} default > /dev/null 2>&1")
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

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