https://fedorahosted.org/freeipa/ticket/5775

From 8ba87072d8e998ccb8743390eb541e74f6b1aa96 Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Tue, 7 Jun 2016 10:08:45 +0200
Subject: [PATCH] Uninstaller won't fail if service can't be started

https://fedorahosted.org/freeipa/ticket/5775
---
 ipaserver/install/bindinstance.py        | 6 +++++-
 ipaserver/install/httpinstance.py        | 6 +++++-
 ipaserver/install/krbinstance.py         | 6 +++++-
 ipaserver/install/ntpinstance.py         | 6 +++++-
 ipaserver/install/odsexporterinstance.py | 6 +++++-
 ipaserver/install/opendnssecinstance.py  | 6 +++++-
 ipaserver/install/service.py             | 6 +++++-
 7 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index afcb6b0c10e54b1aae975fd1e81f37144e6b97ed..928957594098563c89ed905946933110e92b0bb5 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -1269,7 +1269,11 @@ class BindInstance(service.Service):
             self.enable()
 
         if running:
-            self.restart()
+            try:
+                self.restart()
+            except Exception as e:
+                root_logger.error("Unable to restart {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
 
         self.named_regular.unmask()
         if named_regular_enabled:
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index 00f890175ae583f485797da6f913a7f83b302df3..3dc115c225316362957e78ce4a6b12e59844edf9 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -549,7 +549,11 @@ class HTTPInstance(service.Service):
             self.print_msg('WARNING: ' + str(e))
 
         if running:
-            self.restart()
+            try:
+                self.restart()
+            except Exception as e:
+                root_logger.error("Unable to restart {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
 
         # disabled by default, by ldap_enable()
         if enabled:
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index f560a6ec4c2e4ce931cc1552976db5900a3fa5cd..b3c742ece6974931c8c918fb2742ec7c518a490b 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -405,7 +405,11 @@ class KrbInstance(service.Service):
             self.enable()
 
         if running:
-            self.restart()
+            try:
+                self.restart()
+            except Exception as e:
+                root_logger.error("Unable to restart {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
 
         self.kpasswd = KpasswdInstance()
         self.kpasswd.uninstall()
diff --git a/ipaserver/install/ntpinstance.py b/ipaserver/install/ntpinstance.py
index 8b0f0e5395dae3c058fc31bd8914741e4d158830..9bac7b75130dbf592598e1e2a4a64c62ff5858f0 100644
--- a/ipaserver/install/ntpinstance.py
+++ b/ipaserver/install/ntpinstance.py
@@ -183,4 +183,8 @@ class NTPInstance(service.Service):
             self.enable()
 
         if running:
-            self.restart()
+            try:
+                self.restart()
+            except Exception as e:
+                root_logger.error("Unable to restart {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
diff --git a/ipaserver/install/odsexporterinstance.py b/ipaserver/install/odsexporterinstance.py
index e9f7bf853d98237aa19aace384b8ff7021c3a85a..089372b13414a74b8b90566223662fa56d28ec7f 100644
--- a/ipaserver/install/odsexporterinstance.py
+++ b/ipaserver/install/odsexporterinstance.py
@@ -193,7 +193,11 @@ class ODSExporterInstance(service.Service):
             signerd_service.enable()
 
         if signerd_running:
-            signerd_service.start()
+            try:
+                signerd_service.start()
+            except Exception as e:
+                root_logger.error("Unable to start {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
 
         installutils.remove_keytab(paths.IPA_ODS_EXPORTER_KEYTAB)
         installutils.remove_ccache(ccache_path=paths.IPA_ODS_EXPORTER_CCACHE)
diff --git a/ipaserver/install/opendnssecinstance.py b/ipaserver/install/opendnssecinstance.py
index f0c512ba04129d08b5874f58c7a25620f7435b2a..4c2c4145240f030ce8946205faea336a6f462f9f 100644
--- a/ipaserver/install/opendnssecinstance.py
+++ b/ipaserver/install/opendnssecinstance.py
@@ -386,4 +386,8 @@ class OpenDNSSECInstance(service.Service):
             self.enable()
 
         if running:
-            self.restart()
+            try:
+                self.restart()
+            except Exception as e:
+                root_logger.error("Unable to restart {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 40767acd57d5e1fa8126144ca64f6951848ce214..66e2eb146777461bb0e78abaf8db4c3c3cf22b6f 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -604,6 +604,10 @@ class SimpleServiceInstance(Service):
 
         # restore the original state of service
         if running:
-            self.start()
+            try:
+                self.start()
+            except Exception as e:
+                root_logger.error("Unable to start {sname}: {err}"
+                                  .format(sname=self.service_name, err=e))
         if enabled:
             self.enable()
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to