summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Tools/Chkconfig.py
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2010-05-18 10:22:30 -0500
committerSol Jerome <solj@ices.utexas.edu>2010-05-18 10:22:30 -0500
commit80c61484c8b2c3529ba85ac5cf77974f49b90baa (patch)
tree58f5502dd501a511db90e0f72ee257e82611c043 /src/lib/Client/Tools/Chkconfig.py
parent4c8486bd49fa273f9e6392bcb6b760bfd84b49a0 (diff)
downloadbcfg2-80c61484c8b2c3529ba85ac5cf77974f49b90baa.tar.gz
bcfg2-80c61484c8b2c3529ba85ac5cf77974f49b90baa.tar.bz2
bcfg2-80c61484c8b2c3529ba85ac5cf77974f49b90baa.zip
Chkconfig: Fix supervised mode status='off' behavior (Patch from Mathieu Jobin)
Fixes issue reported in Ticket #846. Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
Diffstat (limited to 'src/lib/Client/Tools/Chkconfig.py')
-rw-r--r--src/lib/Client/Tools/Chkconfig.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py
index 718f22bf2..c95f4c2b3 100644
--- a/src/lib/Client/Tools/Chkconfig.py
+++ b/src/lib/Client/Tools/Chkconfig.py
@@ -4,7 +4,9 @@
'''This is chkconfig support'''
__revision__ = '$Revision$'
-import Bcfg2.Client.Tools, Bcfg2.Client.XML
+import Bcfg2.Client.Tools
+import Bcfg2.Client.XML
+
class Chkconfig(Bcfg2.Client.Tools.SvcTool):
'''Chkconfig support for Bcfg2'''
@@ -43,17 +45,24 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool):
onlevels = []
if entry.get('status') == 'on':
- status = (len(onlevels) > 0 )
+ status = (len(onlevels) > 0)
+ command = 'start'
else:
status = (len(onlevels) == 0)
+ command = 'stop'
if entry.get('mode', 'default') == 'supervised':
- pstatus, pout = self.cmd.run('/sbin/service %s status' % \
- entry.get('name'))
- if pstatus:
- self.cmd.run('/sbin/service %s start' % (entry.get('name')))
- pstatus, pout = self.cmd.run('/sbin/service %s status' % \
- entry.get('name'))
+ # turn on or off the service in supervised mode
+ pstatus = self.cmd.run('/sbin/service %s status' % \
+ entry.get('name'))[0]
+ needs_modification = ((command == 'start' and pstatus) or \
+ (command == 'stop' and not pstatus))
+ if not(self.setup.get('dryrun')) and needs_modification:
+ self.cmd.run('/sbin/service %s %s' % (entry.get('name'),
+ command))
+ pstatus = self.cmd.run('/sbin/service %s status' % \
+ entry.get('name'))[0]
+
# chkconfig/init.d service
if entry.get('status') == 'on':
status = status and not pstatus
@@ -86,4 +95,3 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool):
specified = [srv.get('name') for srv in self.getSupportedEntries()]
return [Bcfg2.Client.XML.Element('Service', type='chkconfig', name=name) \
for name in allsrv if name not in specified]
-