pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0033-Checks-if-Dir-Server-is-installed-and-running-before.patch

c58629
From a81a4a502b020e0b0d91e6018914ea18b4e3e47e Mon Sep 17 00:00:00 2001
c58629
From: Felipe Barreto <fbarreto@redhat.com>
c58629
Date: Wed, 20 Sep 2017 09:51:44 -0300
c58629
Subject: [PATCH] Checks if Dir Server is installed and running before IPA
c58629
 installation
c58629
c58629
In cases when IPA is installed in two steps (external CA), it's
c58629
necessary to check (in the second step) if Dir. Server is
c58629
running before continue with the installation. If it's not,
c58629
start Directory Server.
c58629
c58629
https://pagure.io/freeipa/issue/6611
c58629
c58629
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
c58629
Reviewed-By: Christian Heimes <cheimes@redhat.com>
c58629
---
c58629
 ipaplatform/redhat/services.py      | 4 ++++
c58629
 ipaserver/install/server/install.py | 8 ++++++++
c58629
 2 files changed, 12 insertions(+)
c58629
c58629
diff --git a/ipaplatform/redhat/services.py b/ipaplatform/redhat/services.py
c58629
index 8fae1f3cc5b12dba0fa0192f21bc6d2d369941eb..57aa15ad9a4d83366ff02e5a5ca6e4574561e1fa 100644
c58629
--- a/ipaplatform/redhat/services.py
c58629
+++ b/ipaplatform/redhat/services.py
c58629
@@ -119,6 +119,10 @@ class RedHatDirectoryService(RedHatService):
c58629
 
c58629
         return True
c58629
 
c58629
+    def is_installed(self, instance_name):
c58629
+        file_path = "{}/{}-{}".format(paths.ETC_DIRSRV, "slapd", instance_name)
c58629
+        return os.path.exists(file_path)
c58629
+
c58629
     def restart(self, instance_name="", capture_output=True, wait=True,
c58629
                 ldapi=False):
c58629
     # We need to explicitly enable instances to install proper symlinks as
c58629
diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
c58629
index 97cbc6d8c84ee8fc21b6f8983c7897dc5d30c42d..422474fa915b4876530f304ef9424f6b31cf26cc 100644
c58629
--- a/ipaserver/install/server/install.py
c58629
+++ b/ipaserver/install/server/install.py
c58629
@@ -616,6 +616,14 @@ def install_check(installer):
c58629
         # check addresses here, dns module is doing own check
c58629
         no_matching_interface_for_ip_address_warning(ip_addresses)
c58629
 
c58629
+    instance_name = "-".join(realm_name.split("."))
c58629
+    dirsrv = services.knownservices.dirsrv
c58629
+    if (options.external_cert_files
c58629
+           and dirsrv.is_installed(instance_name)
c58629
+           and not dirsrv.is_running(instance_name)):
c58629
+        root_logger.debug('Starting Directory Server')
c58629
+        services.knownservices.dirsrv.start(instance_name)
c58629
+
c58629
     if options.setup_adtrust:
c58629
         adtrust.install_check(False, options, api)
c58629
 
c58629
-- 
c58629
2.13.6
c58629