From 52e626a6f3979137337697f6892c12ad31a85ef0 Mon Sep 17 00:00:00 2001 From: Robert Gogolok Date: Thu, 8 May 2008 17:26:08 +0000 Subject: - 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 --- src/lib/Client/Tools/FreeBSDInit.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/lib/Client/Tools/FreeBSDInit.py (limited to 'src/lib/Client/Tools/FreeBSDInit.py') 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'))) + -- cgit v1.2.3-1-g7c22