From cb11c16487b84a5e05b4ffe7847e81aa922f6ee2 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Mon, 11 Apr 2005 18:52:23 +0000 Subject: fix service stuff (Logical change 1.223) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@933 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Debian.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/Client/Debian.py b/src/lib/Client/Debian.py index 837da85a8..8cf97fcd3 100644 --- a/src/lib/Client/Debian.py +++ b/src/lib/Client/Debian.py @@ -4,6 +4,7 @@ __revision__ = '$Revision$' from glob import glob from os import environ, stat, system from popen2 import Popen4 +from re import compile as regcompile import apt_pkg @@ -17,6 +18,7 @@ class Debian(Toolset): '/etc/apt/apt.conf'] pkgtool = ('apt-get --reinstall -q=2 --force-yes -y install %s', ('%s=%s', ['name', 'version'])) + svcre = regcompile("/etc/.*/[SK]\d\d(?P\S+)") def __init__(self, cfg, setup): Toolset.__init__(self, cfg, setup) @@ -45,7 +47,8 @@ class Debian(Toolset): def VerifyService(self, entry): '''Verify Service status for entry''' - files = glob("/etc/rc*.d/*%s" % (entry.get('name'))) + rawfiles = glob("/etc/rc*.d/*%s" % (entry.get('name'))) + files = [filename for filename in rawfiles if self.svcre.match(filename).group('name') == entry.get('name')] if entry.get('status') == 'off': if files: return False @@ -102,9 +105,12 @@ class Debian(Toolset): '''Do standard inventory plus debian extra service check''' Toolset.Inventory(self) allsrv = [] - [allsrv.append(fname[14:]) for fname in glob("/etc/rc[12345].d/S*") if fname[14:] not in allsrv] + [allsrv.append(self.svcre.match(fname).group('name')) for fname in + glob("/etc/rc[12345].d/S*") if self.svcre.match(fname).group('name') not in allsrv] + self.CondPrint('debug', "Found active services: %s" % allsrv) csrv = self.cfg.findall(".//Service") - [allsrv.remove(svc.get('name')) for svc in csrv if svc.get('status') == 'on' and svc.get('name') in allsrv] + [allsrv.remove(svc.get('name')) for svc in csrv if + svc.get('status') == 'on' and svc.get('name') in allsrv] self.extra_services = allsrv def HandleExtra(self): -- cgit v1.2.3-1-g7c22