summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJoey Hagedorn <hagedorn@mcs.anl.gov>2007-01-02 22:29:42 +0000
committerJoey Hagedorn <hagedorn@mcs.anl.gov>2007-01-02 22:29:42 +0000
commitee99cfb4139b25e2235abd9c773ff180bc93a2ca (patch)
tree32168e95abfbe8a149f988e030c1f7ee165c6adc /src/lib
parent06673bd7a355a62026120d8512be4edd1cf8e927 (diff)
downloadbcfg2-ee99cfb4139b25e2235abd9c773ff180bc93a2ca.tar.gz
bcfg2-ee99cfb4139b25e2235abd9c773ff180bc93a2ca.tar.bz2
bcfg2-ee99cfb4139b25e2235abd9c773ff180bc93a2ca.zip
Initial commit of launchd service support.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2616 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Client/Tools/launchd.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/Client/Tools/launchd.py b/src/lib/Client/Tools/launchd.py
new file mode 100644
index 000000000..eb925dd5c
--- /dev/null
+++ b/src/lib/Client/Tools/launchd.py
@@ -0,0 +1,55 @@
+'''launchd support for Bcfg2'''
+__revision__ = '$Revision: 2596 $'
+
+import glob, os
+import Bcfg2.Client.Tools
+
+class LaunchD(Bcfg2.Client.Tools.Tool):
+ '''Support for Mac OS X Launchd Services'''
+ __handles__ = [('Service', 'launchd')]
+ __execs__ = ['/bin/launchctl', '/usr/bin/defaults']
+ __name__ = 'LaunchD'
+ __req__ = {'Service':['name', 'status', 'plist']}
+
+ #currently requires the path to the plist to load/unload, and Name is acually a reverse-fqdn (or the label)
+
+ def VerifyService(self, entry, _):
+ '''Verify Launchd Service Entry'''
+
+ try:
+ services = self.cmd.run("/bin/launchctl list")
+ except IndexError:#happens when no services are running (should be never)
+ services = []
+ if entry.get('name') in services:#doesn't check if non-spawning services are Started
+ return entry.get('status') == 'on'
+ else:
+ self.logger.debug("Didn't find service Loaded (LaunchD running under same user as bcfg)")
+ return entry.get('status') == 'off'
+
+ try: #Perhaps add the "-w" flag to load and unload to modify the file itself!
+ self.cmd.run("/bin/launchtl load %s" % entry.get('plist'))
+ except IndexError:
+ return "on"
+ return "off"
+
+
+ def InstallService(self, entry):
+ '''Install SMF Service Entry'''
+ pass
+
+ def Remove(self, svcs):
+ '''Remove Extra SMF entries'''
+ pass
+
+ def FindExtra(self):
+ '''Find Extra LaunchD Services'''
+ allsrv = self.cmd.run("/bin/launchctl list")
+
+ [allsrv.remove(svc) for svc in self.getSupportedEntries() if svc in allsrv]
+ return [Bcfg2.Client.XML.Element("Service", type='launchd', name=name) \
+ for name in allsrv]
+
+ def BundleUpdated(self, bundle):
+ '''Reload LaunchD plist'''
+ pass
+