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