blob: 00069f89f6601c8f84228a8d36f750798e5161fc [file] [log] [blame]
jimmydot3982f4f2017-05-07 14:58:24 -04001#!/bin/bash
2
3FINAL_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/cache.ccf
4TEMPLATE_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/cache_template.ccf
5BACKUP1_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/cache.ccf.bk.1
6BACKUP2_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/cache.ccf.bk.2
7
8echo "Localizing the VID cache configuration"
9
10if [ -z "${CACHE_DIRECTORY}" ]; then
11 CACHE_DIRECTORY=${ROOT_DIR}/cache
12fi
13
14mkdir -p "${CACHE_DIRECTORY}"
15
16#------------------------------------------------------------------------
17#- MAKE A BACKUP OF PREVIOUS BACKUP FILE, IF EXISTS
18#------------------------------------------------------------------------
19if [ -f ${BACKUP1_CONFIG_FILE} ]; then
20 cp -f ${BACKUP1_CONFIG_FILE} ${BACKUP2_CONFIG_FILE} || {
21 echo "ERROR: Could not copy ${BACKUP1_CONFIG_FILE} to ${BACKUP2_CONFIG_FILE}"
22 exit 1
23 }
24fi
25
26#------------------------------------------------------------------------
27#- MAKE A BACKUP OF CURRENT FILE, IF EXISTS
28#------------------------------------------------------------------------
29if [ -f ${FINAL_CONFIG_FILE} ]; then
30 cp -f ${FINAL_CONFIG_FILE} ${BACKUP1_CONFIG_FILE} || {
31 echo "ERROR: Could not copy ${FINAL_CONFIG_FILE} to ${BACKUP1_CONFIG_FILE}"
32 exit 2
33 }
34fi
35
36sed -e 's,${CACHE_DIRECTORY},'${CACHE_DIRECTORY}',g' ${TEMPLATE_CONFIG_FILE} > ${FINAL_CONFIG_FILE} || {
37 echo "ERROR: Could not process template file ${TEMPLATE_CONFIG_FILE} into ${FINAL_CONFIG_FILE}"
38 exit 3
39 }
40
41echo "Localized ${FINAL_CONFIG_FILE} successfully."