Skip to content

Commit

Permalink
Added upgrade script to fix outdated server configuration
Browse files Browse the repository at this point in the history
An upgrade script has been added to replace some configuration
files in existing instances with links as in new installations,
which will simplify future upgrades. The original files will be
backed up so they can be restored if necessary.

https://pagure.io/dogtagpki/issue/2560

Change-Id: I35a6e539a214dadeee88a9aab9bb085434236e49
  • Loading branch information
edewata committed Mar 14, 2018
1 parent 4d4f6b9 commit 44b39b1
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions base/server/upgrade/10.6.0/02-FixServerConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Authors:
# Endi S. Dewata <[email protected]>
#
# 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) 2018 Red Hat, Inc.
# All rights reserved.

from __future__ import absolute_import
import os
import pki.server.upgrade


class FixServerConfiguration(pki.server.upgrade.PKIServerUpgradeScriptlet):

def __init__(self):
super(FixServerConfiguration, self).__init__()
self.message = 'Fix server configuration'

def upgrade_instance(self, instance):

self.replace_with_link(
instance,
'catalina.properties',
'/usr/share/pki/server/conf/catalina.properties')

self.replace_with_link(
instance,
'ciphers.info',
'/usr/share/pki/server/conf/ciphers.info')

self.replace_with_link(
instance,
'context.xml',
'/usr/share/tomcat/conf/context.xml')

self.replace_with_link(
instance,
'web.xml',
'/usr/share/tomcat/conf/web.xml')

def replace_with_link(self, instance, filename, target):

source = os.path.join(instance.conf_dir, filename)

# if source is already a link, skip
if os.path.islink(source):
return

self.backup(source)
os.remove(source)

# link source to target
os.symlink(target, source)
os.lchown(source, instance.uid, instance.gid)

0 comments on commit 44b39b1

Please sign in to comment.