blob: 4067dee5e9db41218ac2125e599d3a463a1d075b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# 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
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 $
|