Sha256: d5ee8496cb7563ddc5c8e58bb714011e3aff78a9b04363e811a9a368048f2f51

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 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 <<-EOT
    Gentoo's form of `init`-style service management.

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

  EOT

  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

16 entries across 16 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
puppet-2.7.14 lib/puppet/provider/service/gentoo.rb
puppet-2.7.13 lib/puppet/provider/service/gentoo.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
puppet-2.7.12 lib/puppet/provider/service/gentoo.rb
puppet-2.7.11 lib/puppet/provider/service/gentoo.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/service/gentoo.rb
puppet-2.7.9 lib/puppet/provider/service/gentoo.rb
puppet-2.7.8 lib/puppet/provider/service/gentoo.rb