jimmydot | 3982f4f | 2017-05-07 14:58:24 -0400 | [diff] [blame] | 1 | #!/bin/bash
|
| 2 |
|
| 3 | FINAL_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/log4j.properties
|
| 4 | TEMPLATE_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/log4j_template.properties
|
| 5 | BACKUP1_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/log4j.properties.bk.1
|
| 6 | BACKUP2_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/log4j.properties.bk.2
|
| 7 |
|
| 8 | echo "Localizing the VID log4j configuration"
|
| 9 |
|
| 10 | if [ -z "${LOG4J_LOGLEVEL}" ]; then
|
| 11 | LOG4J_LOGLEVEL=INFO
|
| 12 | fi
|
| 13 |
|
| 14 |
|
| 15 | if [ -z "${LOG4J_APPENDER}" ]; then
|
| 16 | LOG4J_APPENDER=rollingfile
|
| 17 | fi
|
| 18 |
|
| 19 | if [ -z "${LOG4J_LOGS_DIRECTORY}" ]; then
|
| 20 | LOG4J_LOGS_DIRECTORY=${ROOT_DIR}/logs
|
| 21 | fi
|
| 22 |
|
| 23 | mkdir -p ${LOG4J_LOGS_DIRECTORY}
|
| 24 |
|
| 25 | #------------------------------------------------------------------------
|
| 26 | #- MAKE A BACKUP OF PREVIOUS BACKUP FILE, IF EXISTS
|
| 27 | #------------------------------------------------------------------------
|
| 28 | if [ -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 | }
|
| 33 | fi
|
| 34 |
|
| 35 | #------------------------------------------------------------------------
|
| 36 | #- MAKE A BACKUP OF CURRENT FILE, IF EXISTS
|
| 37 | #------------------------------------------------------------------------
|
| 38 | if [ -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 | }
|
| 43 | fi
|
| 44 |
|
| 45 | sed -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 |
|
| 52 | echo "Localized ${FINAL_CONFIG_FILE} successfully."
|
| 53 |
|
| 54 |
|