Blob Blame History Raw
From 1fd3016c39e1c0aadd4f892051417011786a0f8f Mon Sep 17 00:00:00 2001
From: Alexander Scheel <ascheel@redhat.com>
Date: Thu, 3 Sep 2020 12:32:57 -0400
Subject: [PATCH] Keep JAVA_HOME in tomcat.conf

Despite the name tomcat.conf, this is also the main configuration file
loaded by instances. Instances (especially pkispawn) expect config to be
only the Tomcat configuration, despite loading configuration from the
environment as well. Eventually, we should migrate all of this to use
the global configuration rather than the per-instance configuration.

Signed-off-by: Alexander Scheel <ascheel@redhat.com>
---
 base/server/python/pki/server/cli/migrate.py | 12 +++++-------
 base/server/share/conf/tomcat.conf           |  3 +++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/base/server/python/pki/server/cli/migrate.py b/base/server/python/pki/server/cli/migrate.py
index bc5cd379a..dd82897ac 100644
--- a/base/server/python/pki/server/cli/migrate.py
+++ b/base/server/python/pki/server/cli/migrate.py
@@ -615,17 +615,17 @@ class MigrateCLI(pki.cli.CLI):
             logger.debug("Refusing to migrate JAVA_HOME with missing environment variable")
             return
 
-        comment = "JAVA_HOME should be set in /etc/pki/pki.conf instead."
+        java_home = os.environ['JAVA_HOME']
 
         # Update in /etc/sysconfig/<instance>
-        result = self.update_java_home_in_config(instance.service_conf, comment)
+        result = self.update_java_home_in_config(instance.service_conf, java_home)
         self.write_config(instance.service_conf, result)
 
         # Update in /etc/pki/<instance>/tomcat.conf
-        result = self.update_java_home_in_config(instance.tomcat_conf, comment)
+        result = self.update_java_home_in_config(instance.tomcat_conf, java_home)
         self.write_config(instance.tomcat_conf, result)
 
-    def update_java_home_in_config(self, path, comment):
+    def update_java_home_in_config(self, path, java_home):
         result = []
 
         target = "JAVA_HOME="
@@ -635,9 +635,7 @@ class MigrateCLI(pki.cli.CLI):
                 if not line.startswith(target):
                     result.append(line)
                 else:
-                    comment_line = '# ' + comment + '\n'
-                    result.append(comment_line)
-                    new_line = '# ' + line
+                    new_line = target + '"' + java_home + '"\n'
                     result.append(new_line)
 
         return result
diff --git a/base/server/share/conf/tomcat.conf b/base/server/share/conf/tomcat.conf
index 3c6388072..fe39243ad 100644
--- a/base/server/share/conf/tomcat.conf
+++ b/base/server/share/conf/tomcat.conf
@@ -8,6 +8,9 @@
 
 # Default NSS DB type is loaded from /usr/share/pki/etc/tomcat.conf
 
+# Where your java installation lives
+JAVA_HOME="[JAVA_HOME]"
+
 # Where your tomcat installation lives
 CATALINA_BASE="[PKI_INSTANCE_PATH]"
 
-- 
2.26.2