summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Tools/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Client/Tools/__init__.py')
-rw-r--r--src/lib/Client/Tools/__init__.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py
index 0c0aa6b8e..af872c8b4 100644
--- a/src/lib/Client/Tools/__init__.py
+++ b/src/lib/Client/Tools/__init__.py
@@ -288,6 +288,10 @@ class SvcTool(Tool):
"""This class defines basic Service behavior"""
name = 'SvcTool'
+ def __init__(self, logger, setup, config):
+ Tool.__init__(self, logger, setup, config)
+ self.restarted = []
+
def get_svc_command(self, service, action):
"""Return the basename of the command used to start/stop services."""
return '/etc/init.d/%s %s' % (service.get('name'), action)
@@ -323,17 +327,19 @@ class SvcTool(Tool):
for entry in [ent for ent in bundle if self.handlesEntry(ent)]:
mode = entry.get('mode', 'default')
- if mode == 'manual' or \
- (mode == 'interactive_only' and not self.setup['interactive']):
+ if (mode == 'manual' or
+ (mode == 'interactive_only' and
+ not self.setup['interactive'])):
continue
# need to handle servicemode = (build|default)
# need to handle mode = (default|supervised)
if entry.get('status') == 'on':
if self.setup['servicemode'] == 'build':
rc = self.stop_service(entry)
- else:
+ elif entry.get('name') not in self.restarted:
if self.setup['interactive']:
- prompt = 'Restart service %s?: (y/N): ' % entry.get('name')
+ prompt = ('Restart service %s?: (y/N): ' %
+ entry.get('name'))
# py3k compatibility
try:
ans = raw_input(prompt)
@@ -342,8 +348,10 @@ class SvcTool(Tool):
if ans not in ['y', 'Y']:
continue
rc = self.restart_service(entry)
+ if not rc:
+ self.restarted.append(entry.get('name'))
else:
rc = self.stop_service(entry)
if rc:
- self.logger.error("Failed to manipulate service %s" % \
+ self.logger.error("Failed to manipulate service %s" %
(entry.get('name')))