[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 590 Fixed migration tool to update Tomcat libraries.



The migration tool has been fixed to update the links to Tomcat
libraries in the instance folder to match the current Tomcat
version installed on the system.

https://fedorahosted.org/pki/ticket/1353

--
Endi S. Dewata
From a17d65e85c9b69ff1f2a317fef99f5c530382196 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Wed, 6 May 2015 00:08:30 -0400
Subject: [PATCH] Fixed migration tool to update Tomcat libraries.

The migration tool has been fixed to update the links to Tomcat
libraries in the instance folder to match the current Tomcat
version installed on the system.

https://fedorahosted.org/pki/ticket/1353
---
 base/server/python/pki/server/__init__.py    |  6 ++--
 base/server/python/pki/server/cli/migrate.py | 41 ++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/base/server/python/pki/server/__init__.py b/base/server/python/pki/server/__init__.py
index bbdfedc2c36a73662762b817bb1c0054b762cdbf..9eaadc1ef307bfc1c2b0d3e74f1d77c8fc4b5e4c 100644
--- a/base/server/python/pki/server/__init__.py
+++ b/base/server/python/pki/server/__init__.py
@@ -50,6 +50,7 @@ class PKIServer(object):
 
         return instances
 
+
 class PKISubsystem(object):
 
     def __init__(self, instance, subsystem_name):
@@ -104,10 +105,11 @@ class PKIInstance(object):
 
         if self.type >= 10:
             self.base_dir = os.path.join(INSTANCE_BASE_DIR, name)
-            self.conf_dir = os.path.join(self.base_dir, 'conf')
         else:
             self.base_dir = os.path.join(pki.BASE_DIR, name)
-            self.conf_dir = os.path.join(self.base_dir, 'conf')
+
+        self.conf_dir = os.path.join(self.base_dir, 'conf')
+        self.lib_dir = os.path.join(self.base_dir, 'lib')
 
         self.registry_dir = os.path.join(pki.server.REGISTRY_DIR, 'tomcat', self.name)
         self.registry_file = os.path.join(self.registry_dir, self.name)
diff --git a/base/server/python/pki/server/cli/migrate.py b/base/server/python/pki/server/cli/migrate.py
index 5b387cd6728dfcc44e808359c3740e8cd9d59c52..665d046d1ef99204a3aaea2faa6a4e6b33e46c4f 100644
--- a/base/server/python/pki/server/cli/migrate.py
+++ b/base/server/python/pki/server/cli/migrate.py
@@ -20,7 +20,9 @@
 #
 
 import getopt
+import grp
 import os
+import pwd
 import sys
 
 from lxml import etree
@@ -106,6 +108,8 @@ class MigrateCLI(pki.cli.CLI):
         pki_context_xml = os.path.join(instance.conf_dir, 'Catalina', 'localhost', 'pki.xml')
         self.migrate_context_xml(pki_context_xml, tomcat_version)
 
+        self.migrate_tomcat_libraries(instance.lib_dir)
+
     def migrate_server_xml(self, filename, tomcat_version):
 
         if self.verbose:
@@ -379,6 +383,9 @@ class MigrateCLI(pki.cli.CLI):
 
     def migrate_context_xml(self, filename, tomcat_version):
 
+        if not os.path.exists(filename):
+            return
+
         if self.verbose:
             print 'Migrating %s' % filename
 
@@ -429,3 +436,37 @@ class MigrateCLI(pki.cli.CLI):
             context.append(resources)
 
         resources.set('allowLinking', 'true')
+
+    def migrate_tomcat_libraries(self, lib_dir):
+
+        tomcat_dir = '/usr/share/tomcat/lib'
+        uid = pwd.getpwnam('pkiuser').pw_uid
+        gid = grp.getgrnam('pkiuser').gr_gid
+
+        # remove old links
+        for filename in os.listdir(lib_dir):
+
+            if not filename.endswith(".jar"):
+                continue
+
+            path = os.path.join(lib_dir, filename)
+
+            if self.verbose:
+                print 'Removing %s' % path
+
+            os.remove(path)
+
+        # create new links
+        for filename in os.listdir(tomcat_dir):
+
+            if not filename.endswith(".jar"):
+                continue
+
+            source = os.path.join(tomcat_dir, filename)
+            dest = os.path.join(lib_dir, filename)
+
+            if self.verbose:
+                print 'Creating %s' % dest
+
+            os.symlink(source, dest)
+            os.lchown(dest, uid, gid)
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]