blob: 9a646867c550528bd7bc88b966c4c60893fedce6 [file] [log] [blame]
jimmydot3982f4f2017-05-07 14:58:24 -04001#!/bin/bash
2
3FINAL_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz.properties
4TEMPLATE_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz_template.properties
5BACKUP1_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz.properties.bk.1
6BACKUP2_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/quartz.properties.bk.2
7
8echo "Localizing the VID quartz configuration"
9
10if [ -z "${VID_MYSQL_HOST}" ]; then
11 VID_MYSQL_HOST=localhost
12fi
13
14if [ -z "${VID_MYSQL_PORT}" ]; then
15 VID_MYSQL_PORT=3306
16fi
17
18if [ -z "${VID_MYSQL_DBNAME}" ]; then
19 VID_MYSQL_DBNAME=vid_portal
20fi
21
22if [ -z "${VID_MYSQL_USER}" ]; then
23 VID_MYSQL_USER=$(id -un)
24fi
25
26if [ -z "${VID_MYSQL_MAXCONNECTIONS}" ]; then
27 VID_MYSQL_MAXCONNECTIONS=5
28fi
29
30if [ -z "${VID_MYSQL_PASS}" ]; then
31 echo "Missing required parameter VID_MYSQL_PASS"
32 exit 1
33fi
34
35#------------------------------------------------------------------------
36#- MAKE A BACKUP OF PREVIOUS BACKUP FILE, IF EXISTS
37#------------------------------------------------------------------------
38if [ -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 }
43fi
44
45#------------------------------------------------------------------------
46#- MAKE A BACKUP OF CURRENT FILE, IF EXISTS
47#------------------------------------------------------------------------
48if [ -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 }
53fi
54
55sed -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
65echo "Localized ${FINAL_CONFIG_FILE} successfully."
66
67