An upgrade script has been added to replace the <instance>/common
in existing instances with a link to /usr/share/pki/server/common
which contains links to server dependencies.

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

--
Endi S. Dewata
>From d9f054449015c69e93eb2cdad6377c7073e97812 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Sun, 24 Jul 2016 07:36:36 +0200
Subject: [PATCH] Added upgrade scripts to fix server library.

An upgrade script has been added to replace the <instance>/common
in existing instances with a link to /usr/share/pki/server/common
which contains links to server dependencies.

https://fedorahosted.org/pki/ticket/2403
---
 base/common/upgrade/10.3.4/.gitignore          |  4 +++
 base/common/upgrade/10.3.5/.gitignore          |  4 +++
 base/server/upgrade/10.3.4/.gitignore          |  4 +++
 base/server/upgrade/10.3.5/01-FixServerLibrary | 46 ++++++++++++++++++++++++++
 4 files changed, 58 insertions(+)
 create mode 100644 base/common/upgrade/10.3.4/.gitignore
 create mode 100644 base/common/upgrade/10.3.5/.gitignore
 create mode 100644 base/server/upgrade/10.3.4/.gitignore
 create mode 100644 base/server/upgrade/10.3.5/01-FixServerLibrary

diff --git a/base/common/upgrade/10.3.4/.gitignore b/base/common/upgrade/10.3.4/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..5e7d2734cfc60289debf74293817c0a8f572ff32
--- /dev/null
+++ b/base/common/upgrade/10.3.4/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/base/common/upgrade/10.3.5/.gitignore b/base/common/upgrade/10.3.5/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..5e7d2734cfc60289debf74293817c0a8f572ff32
--- /dev/null
+++ b/base/common/upgrade/10.3.5/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/base/server/upgrade/10.3.4/.gitignore b/base/server/upgrade/10.3.4/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..5e7d2734cfc60289debf74293817c0a8f572ff32
--- /dev/null
+++ b/base/server/upgrade/10.3.4/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/base/server/upgrade/10.3.5/01-FixServerLibrary b/base/server/upgrade/10.3.5/01-FixServerLibrary
new file mode 100644
index 0000000000000000000000000000000000000000..79d496559ba1e1cb02ea5f0d02364dd230a6f4d5
--- /dev/null
+++ b/base/server/upgrade/10.3.5/01-FixServerLibrary
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# Authors:
+#     Endi S. Dewata <edew...@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+
+from __future__ import absolute_import
+import os.path
+import shutil
+import pki.server.upgrade
+
+
+class FixServerLibrary(pki.server.upgrade.PKIServerUpgradeScriptlet):
+
+    def __init__(self):
+        super(FixServerLibrary, self).__init__()
+        self.message = 'Fix server library'
+
+    def upgrade_instance(self, instance):
+
+        common_dir = os.path.join(instance.base_dir, 'common')
+
+        # if <instance>/common is already a link, skip
+        if os.path.islink(common_dir):
+            return
+
+        # remove old <instance>/common
+        shutil.rmtree(common_dir)
+
+        # link <instance>/common to /usr/share/pki/server/common
+        os.symlink('/usr/share/pki/server/common', common_dir)
+        os.lchown(common_dir, instance.uid, instance.gid)
-- 
2.5.5

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to