#!/bin/bash

set -xe

# Several configuration files are owned by one package in RHOSE 1.2 and are
# owned by another package in RHOSE 2.0.  Consequently, the Yum upgrade from
# RHOSE 1.2 to RHOSE 2.0 deletes these files if they have not been modified or
# saves them with the .rpmsave extension if they have been modified when Yum
# performs removes the old package.  We must stash copies of these files now so
# that the conf step later can copy them back in place after Yum has wrought its
# dastardly deeds.
#
# In RHOSE 1.2, the rubygem-openshift-origin-node package the following files
# that are owned by the rubygem-openshift-origin-frontend-apachedb package in
# RHOSE 2.0:
#
#     /etc/httpd/conf.d/000001_openshift_origin_node_servername.conf
#     /var/lib/openshift/.httpd.d/nodes.db
#     /var/lib/openshift/.httpd.d/nodes.txt
#     /var/lib/openshift/.httpd.d/geardb.json
#
# In RHOSE 1.2, the rubygem-openshift-origin-node package the following files
# that are owned by the rubygem-openshift-origin-frontend-apache-mod-rewrite 
# package in RHOSE 2.0:
#
#     /var/lib/openshift/.httpd.d/sts.db
#     /var/lib/openshift/.httpd.d/sts.txt
#     /var/lib/openshift/.httpd.d/aliases.db
#     /var/lib/openshift/.httpd.d/aliases.txt
#     /var/lib/openshift/.httpd.d/idler.db
#     /var/lib/openshift/.httpd.d/idler.txt
#
# In RHOSE 1.2, the rubygem-openshift-origin-node package owns the following
# files that are owned by the rubygem-openshift-origin-frontend-nodejs-websocket
# package in RHOSE 2.0:
#
#     /var/lib/openshift/.httpd.d/routes.json{.rpmsave,}
#
# In RHOSE 1.2, the mcollective package owns the following file that is owned by
# the ruby193-mcollective package in RHOSE 2.0:
#
#     /etc/mcollective/server.cfg

mkdir -p /etc/openshift/upgrade/3/

# for file in \
#   /etc/mcollective/server.cfg \
#   /etc/httpd/conf.d/000001_openshift_origin_node_servername.conf \
#   /var/lib/openshift/.httpd.d/nodes.db \
#   /var/lib/openshift/.httpd.d/nodes.txt \
#   /var/lib/openshift/.httpd.d/geardb.json \
#   /var/lib/openshift/.httpd.d/sts.db \
#   /var/lib/openshift/.httpd.d/sts.txt \
#   /var/lib/openshift/.httpd.d/aliases.db \
#   /var/lib/openshift/.httpd.d/aliases.txt \
#   /var/lib/openshift/.httpd.d/idler.db \
#   /var/lib/openshift/.httpd.d/idler.txt \
#   /var/lib/openshift/.httpd.d/routes.json
# do
#   command cp -f "$file" /etc/openshift/upgrade/3/
# done
