URL: https://github.com/freeipa/freeipa/pull/816
Author: martbab
 Title: #816: only stop/disable simple service if it is installed
Action: opened

PR body:
"""
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
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/816/head:pr816
git checkout pr816
From dca1ca780be369544d1886ff489301eaee48a317 Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
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
---
 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 1aa49ed25b..0523e914aa 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -674,18 +674,21 @@ def __enable(self):
         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()
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to