Sha256: 3abd13250cf671f3e5551b4bc78f228bea292b6c30f26a8886a8cf2271be644e

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 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"

    defaultfor :operatingsystem => :gentoo

    def disable
        begin
            output = update :del, @resource[:name], :default
        rescue Puppet::ExecutionFailure
            raise Puppet::Error, "Could not disable %s: %s" %
                [self.name, output]
        end
    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 =~ /#{@resource[:name]}\s*|\s*default/
            return :true
        else
            return :false
        end
    end

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

# $Id $

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puppet-0.23.0 lib/puppet/provider/service/gentoo.rb
puppet-0.23.1 lib/puppet/provider/service/gentoo.rb
puppet-0.24.0 lib/puppet/provider/service/gentoo.rb
puppet-0.23.2 lib/puppet/provider/service/gentoo.rb
puppet-0.24.1 lib/puppet/provider/service/gentoo.rb