Sha256: 9811f7cd37bee1da928b79667fa7623eafeca855abc16a7b153e2b8521ffcfc3

Contents?: true

Size: 1.21 KB

Versions: 17

Compression:

Stored size: 1.21 KB

Contents

# Manage gentoo services.  Start/stop is the same as InitSvc, but enable/disable
# is special.
Puppet::Type.type(:service).provide :gentoo, :parent => :init do
  desc "Gentoo's form of `init`-style service management.

  Uses `rc-update` for service enabling and disabling.

  "

  commands :update => "/sbin/rc-update"

  confine :operatingsystem => :gentoo

  defaultfor :operatingsystem => :gentoo

  def self.defpath
    superclass.defpath
  end

  def disable
      output = update :del, @resource[:name], :default
  rescue Puppet::ExecutionFailure
      raise Puppet::Error, "Could not disable #{self.name}: #{output}"
  end

  def enabled?
    begin
      output = update :show
    rescue Puppet::ExecutionFailure
      return :false
    end

    line = output.split(/\n/).find { |l| l.include?(@resource[:name]) }

    return :false unless line

    # If it's enabled then it will print output showing service | runlevel
    if output =~ /^\s*#{@resource[:name]}\s*\|\s*(boot|default)/
      return :true
    else
      return :false
    end
  end

  def enable
      output = update :add, @resource[:name], :default
  rescue Puppet::ExecutionFailure
      raise Puppet::Error, "Could not enable #{self.name}: #{output}"
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
puppet-2.6.18 lib/puppet/provider/service/gentoo.rb
puppet-2.6.17 lib/puppet/provider/service/gentoo.rb
puppet-2.6.16 lib/puppet/provider/service/gentoo.rb
puppet-2.6.15 lib/puppet/provider/service/gentoo.rb
puppet-2.6.14 lib/puppet/provider/service/gentoo.rb
puppet-2.6.13 lib/puppet/provider/service/gentoo.rb
puppet-2.7.6 lib/puppet/provider/service/gentoo.rb
puppet-2.6.12 lib/puppet/provider/service/gentoo.rb
puppet-2.7.5 lib/puppet/provider/service/gentoo.rb
puppet-2.6.11 lib/puppet/provider/service/gentoo.rb
puppet-2.7.4 lib/puppet/provider/service/gentoo.rb
puppet-2.6.10 lib/puppet/provider/service/gentoo.rb
puppet-2.7.3 lib/puppet/provider/service/gentoo.rb
puppet-2.7.1 lib/puppet/provider/service/gentoo.rb
puppet-2.6.9 lib/puppet/provider/service/gentoo.rb
puppet-2.6.8 lib/puppet/provider/service/gentoo.rb
puppet-2.6.7 lib/puppet/provider/service/gentoo.rb