summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael V. O'Brien <michael@reductivelabs.com>2007-10-04 15:19:03 -0500
committerMichael V. O'Brien <michael@reductivelabs.com>2007-10-04 15:19:03 -0500
commitf41c843f6263e7bb2b89c109710307c4ab2779bf (patch)
tree78833f2efa9722738e0a357e800ecbd193ca23cc
parent533ce4b405e5864332a6a32862a61375273db466 (diff)
downloadpuppet-f41c843f6263e7bb2b89c109710307c4ab2779bf.tar.gz
puppet-f41c843f6263e7bb2b89c109710307c4ab2779bf.tar.xz
puppet-f41c843f6263e7bb2b89c109710307c4ab2779bf.zip
Fixed #837. Added freebsd service provider by trombik.
-rw-r--r--lib/puppet/provider/service/freebsd.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb
new file mode 100644
index 000000000..31fdacb86
--- /dev/null
+++ b/lib/puppet/provider/service/freebsd.rb
@@ -0,0 +1,46 @@
+# Manage FreeBSD services.
+Puppet::Type.type(:service).provide :freebsd, :parent => :init do
+ desc "FreeBSD's (and probably NetBSD?) form of ``init``-style service
+ management; uses ``rc-update`` for service enabling and disabling."
+
+ commands :rcupdate => "/usr/local/sbin/rc-update"
+
+ defaultfor :operatingsystem => :freebsd
+
+ def self.defpath
+ superclass.defpath
+ end
+
+ def disable
+ begin
+ output = rcupdate("disable", @model[:name])
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error, "Could not disable %s: %s" %
+ [self.name, output]
+ end
+ end
+
+ def enabled?
+ begin
+ output = rcupdate("enabled", @model[:name])
+ rescue Puppet::ExecutionFailure
+ return :false
+ end
+
+ # If it's enabled, output is 0
+ if output =~ /^0$/
+ return :true
+ end
+
+ return :false
+ end
+
+ def enable
+ begin
+ output = rcupdate("enable", @model[:name])
+ rescue Puppet::ExecutionFailure => detail
+ raise Puppet::Error, "Could not enable %s: %s" %
+ [self.name, detail]
+ end
+ end
+end