Sha256: 33d1f5560a65421cd0efc4650ed302ef2c1fd316330c1501806d7b8ff9bd746c

Contents?: true

Size: 1.67 KB

Versions: 43

Compression:

Stored size: 1.67 KB

Contents

# Gentoo OpenRC
Puppet::Type.type(:service).provide :openrc, :parent => :base do
  desc <<-EOT
    Support for Gentoo's OpenRC initskripts

    Uses rc-update, rc-status and rc-service to manage services.

  EOT

  defaultfor :operatingsystem => :gentoo
  defaultfor :operatingsystem => :funtoo

  commands :rcservice => '/sbin/rc-service'
  commands :rcstatus  => '/bin/rc-status'
  commands :rcupdate  => '/sbin/rc-update'

  self::STATUSLINE = /^\s+(.*?)\s*\[\s*(.*)\s*\]$/

  def enable
    rcupdate('-C', :add, @resource[:name])
  end

  def disable
    rcupdate('-C', :del, @resource[:name])
  end

  # rc-status -a shows all runlevels and dynamic runlevels which
  # are not considered as enabled. We have to find out under which
  # runlevel our service is listed
  def enabled?
    enabled = :false
    rcstatus('-C', '-a').each_line do |line|
      case line.chomp
      when /^Runlevel: /
        enabled = :true
      when /^\S+/ # caption of a dynamic runlevel
        enabled = :false
      when self.class::STATUSLINE
        return enabled if @resource[:name] == $1
      end
    end
    :false
  end

  def self.instances
    instances = []
    rcservice('-C', '--list').each_line do |line|
      instances << new(:name => line.chomp)
    end
    instances
  end

  def restartcmd
    (@resource[:hasrestart] == :true) && [command(:rcservice), @resource[:name], :restart]
  end

  def startcmd
    [command(:rcservice), @resource[:name], :start ]
  end

  def stopcmd
    [command(:rcservice), @resource[:name], :stop]
  end

  def statuscmd
    ((@resource.provider.get(:hasstatus) == true) || (@resource[:hasstatus] == :true)) && [command(:rcservice), @resource[:name], :status]
  end

end

Version data entries

43 entries across 43 versions & 3 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/provider/service/openrc.rb
puppet-parse-0.1.3 lib/vendor/puppet/provider/service/openrc.rb
puppet-parse-0.1.2 lib/vendor/puppet/provider/service/openrc.rb
puppet-parse-0.1.1 lib/vendor/puppet/provider/service/openrc.rb
puppet-2.7.26 lib/puppet/provider/service/openrc.rb
puppet-2.7.25 lib/puppet/provider/service/openrc.rb
puppet-2.7.24 lib/puppet/provider/service/openrc.rb
puppet-3.2.4 lib/puppet/provider/service/openrc.rb
puppet-2.7.23 lib/puppet/provider/service/openrc.rb
puppet-3.2.3 lib/puppet/provider/service/openrc.rb
puppet-3.2.3.rc1 lib/puppet/provider/service/openrc.rb
puppet-3.2.2 lib/puppet/provider/service/openrc.rb
puppet-2.7.22 lib/puppet/provider/service/openrc.rb
puppet-3.2.1 lib/puppet/provider/service/openrc.rb
puppet-3.2.1.rc1 lib/puppet/provider/service/openrc.rb
puppet-3.2.0.rc2 lib/puppet/provider/service/openrc.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/provider/service/openrc.rb
puppet-3.2.0.rc1 lib/puppet/provider/service/openrc.rb
puppet-parse-0.1.0 lib/vendor/puppet/provider/service/openrc.rb
puppet-parse-0.0.6 lib/vendor/puppet/provider/service/openrc.rb