summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-18 14:40:50 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-18 14:40:50 +0000
commitead49c673e352166d87f47cbbea2086d4c1fc2f7 (patch)
treeb11dd8da727b310d1fb479f1ff2d9010d5cda1f5 /lib
parent7261cbb0a5c05d5e18573ccdeb7c3ce84ba11f68 (diff)
downloadpuppet-ead49c673e352166d87f47cbbea2086d4c1fc2f7.tar.gz
puppet-ead49c673e352166d87f47cbbea2086d4c1fc2f7.tar.xz
puppet-ead49c673e352166d87f47cbbea2086d4c1fc2f7.zip
Applying patch from #318.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1812 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/service/gentoo.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb
new file mode 100644
index 000000000..bd3a03f9b
--- /dev/null
+++ b/lib/puppet/provider/service/gentoo.rb
@@ -0,0 +1,45 @@
+# 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 = util_execute("#{command(:update)} del #{@model[:name]} default 2>&1")
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error, "Could not disable %s: %s" %
+ [self.name, output]
+ end
+ end
+
+ def enabled?
+ begin
+ output = util_execute("#{command(:update)} show | grep #{@model[:name]}").chomp
+ rescue Puppet::ExecutionFailure
+ return :false
+ end
+
+ # If it's enabled then it will print output showing service | runlevel
+ if output =~ /#{@model[:name]}\s*|\s*default/
+ return :true
+ else
+ return :false
+ end
+ end
+
+ def enable
+ begin
+ output = util_execute("#{command(:update)} add #{@model[:name]} default 2>&1")
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error, "Could not enable %s: %s" %
+ [self.name, output]
+ end
+ end
+end
+
+# $Id $