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