jimmydot | 3982f4f | 2017-05-07 14:58:24 -0400 | [diff] [blame] | 1 | #!/bin/bash
|
| 2 |
|
| 3 | FINAL_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/logback.xml
|
| 4 | TEMPLATE_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/logback_template.xml
|
| 5 | BACKUP1_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/logback.xml.bk.1
|
| 6 | BACKUP2_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/classes/logback.xml.bk.2
|
| 7 |
|
| 8 | echo "Localizing the VID logback configuration"
|
| 9 |
|
| 10 | if [ -z "${VID_LOG_DIR}" ]; then
|
| 11 | VID_LOG_DIR="${ROOT_DIR}/logs"
|
| 12 | fi
|
| 13 |
|
| 14 | if [ -z "${VID_LOG_LEVEL}" ]; then
|
| 15 | VID_LOG_LEVEL="INFO"
|
| 16 | fi
|
| 17 |
|
| 18 | mkdir -p "${VID_LOG_DIR}"
|
| 19 |
|
| 20 | #------------------------------------------------------------------------
|
| 21 | #- MAKE A BACKUP OF PREVIOUS BACKUP FILE, IF EXISTS
|
| 22 | #------------------------------------------------------------------------
|
| 23 | if [ -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 | }
|
| 28 | fi
|
| 29 |
|
| 30 | #------------------------------------------------------------------------
|
| 31 | #- MAKE A BACKUP OF CURRENT FILE, IF EXISTS
|
| 32 | #------------------------------------------------------------------------
|
| 33 | if [ -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 | }
|
| 38 | fi
|
| 39 |
|
| 40 | sed -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 |
|
| 46 | echo "Localized ${FINAL_CONFIG_FILE} successfully."
|