#!/bin/bash

set -xe

# Changes to configuration and logging definitions indicate re-creating
# any frontend vhosts, e.g.:
# https://github.com/openshift/origin-server/pull/4797
# https://trello.com/c/q1ro2vDB/408-3-use-proxy-pass-for-virtual-hosts-plugin-instead-of-mod-rewrite
# https://github.com/openshift/origin-server/pull/5164
# https://trello.com/c/RF3kubpI/428-2-remove-unnecessary-directives-from-frontend-vhost-definitions

# Save and restore commands need to be in separate scripts so that a
# failure on the --delete command doesn't cause us to rerun --save
# (thereby destroying the saved frontends)

if rpm -q rubygem-openshift-origin-frontend-apache-vhost || \
   rpm -q rubygem-openshift-origin-frontend-apache-mod-rewrite; then
        frontends=/etc/openshift/upgrade/3/upgrade-vhost-frontends.save
	oo-frontend-plugin-modify --delete --confirm
	oo-frontend-plugin-modify --restore < $frontends
fi
