Class AutomateIt::ServiceManager::Chkconfig
In: lib/automateit/service_manager/chkconfig.rb
Parent: AutomateIt::ServiceManager::SYSV

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.

Methods

disable   enable   enabled?  

Public Instance methods

See ServiceManager#disable

[Source]

# 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

See ServiceManager#enable

[Source]

# 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

See ServiceManager#enabled?

[Source]

# 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

[Validate]