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/quartz.properties
|
| 4 | TEMPLATE_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz_template.properties
|
| 5 | BACKUP1_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz.properties.bk.1
|
| 6 | BACKUP2_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz.properties.bk.2
|
| 7 |
|
| 8 | echo "Localizing the VID quartz configuration"
|
| 9 |
|
| 10 | if [ -z "${VID_MYSQL_HOST}" ]; then
|
| 11 | VID_MYSQL_HOST=localhost
|
| 12 | fi
|
| 13 |
|
| 14 | if [ -z "${VID_MYSQL_PORT}" ]; then
|
| 15 | VID_MYSQL_PORT=3306
|
| 16 | fi
|
| 17 |
|
| 18 | if [ -z "${VID_MYSQL_DBNAME}" ]; then
|
| 19 | VID_MYSQL_DBNAME=vid_portal
|
| 20 | fi
|
| 21 |
|
| 22 | if [ -z "${VID_MYSQL_USER}" ]; then
|
| 23 | VID_MYSQL_USER=$(id -un)
|
| 24 | fi
|
| 25 |
|
| 26 | if [ -z "${VID_MYSQL_MAXCONNECTIONS}" ]; then
|
| 27 | VID_MYSQL_MAXCONNECTIONS=5
|
| 28 | fi
|
| 29 |
|
| 30 | if [ -z "${VID_MYSQL_PASS}" ]; then
|
| 31 | echo "Missing required parameter VID_MYSQL_PASS"
|
| 32 | exit 1
|
| 33 | fi
|
| 34 |
|
| 35 | #------------------------------------------------------------------------
|
| 36 | #- MAKE A BACKUP OF PREVIOUS BACKUP FILE, IF EXISTS
|
| 37 | #------------------------------------------------------------------------
|
| 38 | if [ -f ${BACKUP1_CONFIG_FILE} ]; then
|
| 39 | cp -f ${BACKUP1_CONFIG_FILE} ${BACKUP2_CONFIG_FILE} || {
|
| 40 | echo "ERROR: Could not copy ${BACKUP1_CONFIG_FILE} to ${BACKUP2_CONFIG_FILE}"
|
| 41 | exit 2
|
| 42 | }
|
| 43 | fi
|
| 44 |
|
| 45 | #------------------------------------------------------------------------
|
| 46 | #- MAKE A BACKUP OF CURRENT FILE, IF EXISTS
|
| 47 | #------------------------------------------------------------------------
|
| 48 | if [ -f ${FINAL_CONFIG_FILE} ]; then
|
| 49 | cp -f ${FINAL_CONFIG_FILE} ${BACKUP1_CONFIG_FILE} || {
|
| 50 | echo "ERROR: Could not copy ${FINAL_CONFIG_FILE} to ${BACKUP1_CONFIG_FILE}"
|
| 51 | exit 3
|
| 52 | }
|
| 53 | fi
|
| 54 |
|
| 55 | sed -e 's/${VID_MYSQL_HOST}/'${VID_MYSQL_HOST}'/g' \
|
| 56 | -e 's/${VID_MYSQL_PORT}/'${VID_MYSQL_PORT}'/g' \
|
| 57 | -e 's/${VID_MYSQL_DBNAME}/'${VID_MYSQL_DBNAME}'/g' \
|
| 58 | -e 's/${VID_MYSQL_USER}/'${VID_MYSQL_USER}'/g' \
|
| 59 | -e 's/${VID_MYSQL_PASS}/'${VID_MYSQL_PASS}'/g' \
|
| 60 | -e 's/${VID_MYSQL_MAXCONNECTIONS}/'${VID_MYSQL_MAXCONNECTIONS}'/g' ${TEMPLATE_CONFIG_FILE} > ${FINAL_CONFIG_FILE} || {
|
| 61 | echo "ERROR: Could not process template file ${TEMPLATE_CONFIG_FILE} into ${FINAL_CONFIG_FILE}"
|
| 62 | exit 4
|
| 63 | }
|
| 64 |
|
| 65 | echo "Localized ${FINAL_CONFIG_FILE} successfully."
|
| 66 |
|
| 67 |
|