summaryrefslogtreecommitdiffstats
path: root/playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2016-03-03 15:37:53 -0500
committerBrenton Leanhardt <bleanhar@redhat.com>2016-03-03 15:37:53 -0500
commit26b37a59d52665bf2b7663326dd72a2262faf844 (patch)
tree67a8f2b9c5b472204f0e56560c3defe87a11c072 /playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh
parentaef4ac6419d80b7002a7a6ab13ef8d928408e8d0 (diff)
parent322689ef0dc93a39cc9fef2d86eecfdc11e953ef (diff)
downloadopenshift-26b37a59d52665bf2b7663326dd72a2262faf844.tar.gz
openshift-26b37a59d52665bf2b7663326dd72a2262faf844.tar.bz2
openshift-26b37a59d52665bf2b7663326dd72a2262faf844.tar.xz
openshift-26b37a59d52665bf2b7663326dd72a2262faf844.zip
Merge pull request #1483 from brenton/32upgrade
First past at the upgrade process for 3.2
Diffstat (limited to 'playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh')
-rw-r--r--playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh b/playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh
new file mode 100644
index 000000000..239f43314
--- /dev/null
+++ b/playbooks/common/openshift-cluster/upgrades/files/ensure_system_units_have_version.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+set -e
+
+SERVICE_TYPE=$1
+DEPLOYMENT_TYPE=$2
+VERSION="v${3}"
+
+add_image_version_to_sysconfig () {
+ unit_name=$2
+ sysconfig_file=/etc/sysconfig/${unit_name}
+
+ if ! grep IMAGE_VERSION ${sysconfig_file}; then
+ sed -i "/CONFIG_FILE/a IMAGE_VERSION=${1}" ${sysconfig_file}
+ else
+ sed -i "s/\(IMAGE_VERSION=\).*/\1${1}/" ${sysconfig_file}
+ fi
+}
+
+add_image_version_to_unit () {
+ deployment_type=$1
+ unit_file=$2
+
+ if ! grep IMAGE_VERSION $unit_file; then
+ image_namespace="openshift/"
+ if [ $deployment_type == "atomic-enterprise" ]; then
+ image_namespace="aep3/"
+ elif [ $deployment_type == "openshift-enterprise" ]; then
+ image_namespace="openshift3/"
+ fi
+
+ sed -i "s|\(${image_namespace}[a-zA-Z0-9]\+\)|\1:\${IMAGE_VERSION}|" $unit_file
+ fi
+}
+
+for unit_file in $(ls /etc/systemd/system/${SERVICE_TYPE}*.service); do
+ unit_name=$(basename -s .service ${unit_file})
+ add_image_version_to_sysconfig $VERSION $unit_name
+ add_image_version_to_unit $DEPLOYMENT_TYPE $unit_file
+done
+
+if [ -e /etc/sysconfig/openvswitch ]; then
+ add_image_version_to_sysconfig $VERSION openvswitch
+else
+ echo IMAGE_VERSION=${VERSION} > /etc/sysconfig/openvswitch
+fi
+if ! grep EnvironmentFile /etc/systemd/system/openvswitch.service > /dev/null; then
+ sed -i "/Service/a EnvironmentFile=/etc/sysconfig/openvswitch" /etc/systemd/system/openvswitch.service
+fi
+add_image_version_to_unit $DEPLOYMENT_TYPE /etc/systemd/system/openvswitch.service
+
+systemctl daemon-reload