summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Tools/FreeBSDInit.py
diff options
context:
space:
mode:
authorRobert Gogolok <gogo@cs.uni-sb.de>2008-05-08 17:26:08 +0000
committerRobert Gogolok <gogo@cs.uni-sb.de>2008-05-08 17:26:08 +0000
commit52e626a6f3979137337697f6892c12ad31a85ef0 (patch)
treeac2599db0d9a8734fb40b52f12ade0c4817f203e /src/lib/Client/Tools/FreeBSDInit.py
parent3d054585fab3919a7f61ac7776e3b3d0cf5fc71a (diff)
downloadbcfg2-52e626a6f3979137337697f6892c12ad31a85ef0.tar.gz
bcfg2-52e626a6f3979137337697f6892c12ad31a85ef0.tar.bz2
bcfg2-52e626a6f3979137337697f6892c12ad31a85ef0.zip
- Add preliminary support for rc under FreeBSD
- TODOs git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4602 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client/Tools/FreeBSDInit.py')
-rw-r--r--src/lib/Client/Tools/FreeBSDInit.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/Client/Tools/FreeBSDInit.py b/src/lib/Client/Tools/FreeBSDInit.py
new file mode 100644
index 000000000..8e13e7981
--- /dev/null
+++ b/src/lib/Client/Tools/FreeBSDInit.py
@@ -0,0 +1,34 @@
+'''FreeBSD Init Support for Bcfg2'''
+__revision__ = '$Rev$'
+
+# TODO
+# - hardcoded path to ports rc.d
+# - doesn't know about /etc/rc.d/
+
+import Bcfg2.Client.Tools
+
+class FreeBSDInit(Bcfg2.Client.Tools.SvcTool):
+ '''FreeBSD Service Support for Bcfg2'''
+ __name__ = 'FreeBSDInit'
+ __handles__ = [('Service', 'freebsd')]
+ __req__ = {'Service': ['name', 'status']}
+ __svcrestart__ = 'restart'
+
+ def VerifyService(self, entry, _):
+ return True
+
+ def BundleUpdated(self, bundle, states):
+ '''The Bundle has been updated'''
+ for entry in bundle:
+ if self.handlesEntry(entry):
+ command = "/usr/local/etc/rc.d/%s" % entry.get('name')
+ if entry.get('status') == 'on' and not self.setup['build']:
+ self.logger.debug('Restarting service %s' % entry.get('name'))
+ rc = self.cmd.run('%s %s' % (command, \
+ entry.get('reload', self.__svcrestart__)))[0]
+ else:
+ self.logger.debug('Stopping service %s' % entry.get('name'))
+ rc = self.cmd.run('%s stop' % command)[0]
+ if rc:
+ self.logger.error("Failed to restart service %s" % (entry.get('name')))
+