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