From 8b6f8ed7d47542b9bd8b7453a8a0e202ed1db97d Mon Sep 17 00:00:00 2001 From: Martin Babinsky Date: Tue, 23 May 2017 16:35:01 +0200 Subject: [PATCH] only stop/disable simple service if it is installed The SimpleServiceInstance uninstaller assument that the service to uninstall was always present on the system. This may not be valid in some cases (e.g. containerized deployments) and thus we need to change the service state only when we know that the unit file exists. https://pagure.io/freeipa/issue/6977 Reviewed-By: Martin Basti --- ipaserver/install/service.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py index 1aa49ed25..0523e914a 100644 --- a/ipaserver/install/service.py +++ b/ipaserver/install/service.py @@ -674,18 +674,21 @@ class SimpleServiceInstance(Service): else: self.ldap_enable(self.gensvc_name, self.fqdn, None, self.suffix) + def is_installed(self): + return self.service.is_installed() + def uninstall(self): if self.is_configured(): self.print_msg("Unconfiguring %s" % self.service_name) - self.stop() - self.disable() - running = self.restore_state("running") enabled = self.restore_state("enabled") - # restore the original state of service - if running: - self.start() - if enabled: - self.enable() + if self.is_installed(): + self.stop() + self.disable() + + if running: + self.start() + if enabled: + self.enable()