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