summaryrefslogtreecommitdiffstats
path: root/epsdk-app-onap/src/main/swm/common/localize_system.sh
blob: c9d0afd8d6e9d3d937b686590c1ad60cd2b78f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash

FINAL_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/system.properties
TEMPLATE_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/system_template.properties
BACKUP1_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/system.properties.bk.1
BACKUP2_CONFIG_FILE=${ROOT_DIR}/war/WEB-INF/conf/system.properties.bk.2

echo "Localizing the VID system configuration"

if [ -z "${VID_MYSQL_HOST}" ]; then
	VID_MYSQL_HOST=localhost
fi

if [ -z "${VID_MYSQL_PORT}" ]; then
	VID_MYSQL_PORT=3306
fi

if [ -z "${VID_MYSQL_DBNAME}" ]; then
	VID_MYSQL_DBNAME=vid_portal
fi

if [ -z "${VID_MYSQL_USER}" ]; then
	VID_MYSQL_USER=vid_admin
fi

if [ -z "${VID_MYSQL_MAXCONNECTIONS}" ]; then
	VID_MYSQL_MAXCONNECTIONS=5
fi

if [ -z "${VID_AAI_HOST}" ]; then
	VID_AAI_HOST=aai.api.openecomp.org
fi

if [ -z "${VID_AAI_PORT}" ]; then
	VID_AAI_PORT=8443
fi

if [ -z "${VID_APP_DISPLAY_NAME}" ]; then
	VID_APP_DISPLAY_NAME=VID
fi

if [ -z "${VID_ECOMP_SHARED_CONTEXT_REST_URL}" ]; then
	VID_ECOMP_SHARED_CONTEXT_REST_URL="https://portal.openecomp.org:8080/ecompportal/context"
fi

if [ -z "${VID_ECOMP_REDIRECT_URL}" ]; then
	VID_ECOMP_REDIRECT_URL=http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm
fi

if [ -z "${VID_ECOMP_REST_URL}" ]; then
	VID_ECOMP_REST_URL=http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/auxapi
fi

if [ -z "${VID_MSO_SERVER_URL}" ]; then
	VID_MSO_SERVER_URL=https://mso.api.openecomp.org:8443
fi

if [ -z "${VID_TRUSTSTORE_FILE}" ]; then
	VID_TRUSTSTORE_FILE=${ROOT_DIR}/etc/vid_keystore.jks
fi

if [ -z "${VID_MYLOGIN_FEED_DIRECTORY}" ]; then
	VID_MYLOGIN_FEED_DIRECTORY=/tmp/MyLogins
fi

if [ -z "${VID_TRUSTSTORE_PASS}" ]; then
	echo "ERROR: Missing required parameter VID_TRUSTSTORE_PASS"
	exit 1
fi

if [ -z "${VID_MSO_USER}" ]; then
	echo "ERROR: Missing required parameter VID_MSO_USER"
	exit 1
fi

if [ -z "${VID_MSO_PASS}" ]; then
	echo "ERROR: Missing required parameter VID_MSO_PASS";
	exit 1
fi

if [ -z "${VID_MYSQL_PASS}" ]; then
	echo "ERROR: Missing required parameter VID_MYSQL_PASS"
	exit 1
fi

if [ -z "${MSO_DME2_CLIENT_TIMEOUT}" ]; then
	echo "ERROR: Missing required parameter MSO_DME2_CLIENT_TIMEOUT"
	exit 1
fi

if [ -z "${MSO_DME2_CLIENT_READ_TIMEOUT}" ]; then
	echo "ERROR: Missing required parameter MSO_DME2_CLIENT_READ_TIMEOUT"
	exit 1
fi

if [ -z "${MSO_DME2_SERVER_URL}" ]; then
	echo "ERROR: Missing required parameter MSO_DME2_SERVER_URL"
	exit 1
fi
if [ -z "${MSO_DME2_ENABLED}" ]; then
	echo "ERROR: Missing required parameter MSO_DME2_ENABLED"
	exit 1
fi
if [ -z "${MSO_POLLING_INTERVAL_MSECS}" ]; then
	MSO_POLLING_INTERVAL_MSECS=10000
fi

if [ -z "${AAI_TRUSTSTORE_FILENAME}" ]; then
	AAI_TRUSTSTORE_FILENAME=tomcat_keystore
fi

if [ -z "${AAI_TRUSTSTORE_PASSWD_X}" ]; then
	AAI_TRUSTSTORE_PASSWD_X=70c87528c88dcd9f9c2558d30e817868
fi

if [ -z "${AAI_KEYSTORE_FILENAME}" ]; then
	AAI_KEYSTORE_FILENAME=aai-client-cert.p12
fi

if [ -z "${AAI_KEYSTORE_PASSWD_X}" ]; then
	AAI_KEYSTORE_PASSWD_X=70c87528c88dcd9f9c2558d30e817868
fi

mkdir -p "${VID_MYLOGIN_FEED_DIRECTORY}"

#------------------------------------------------------------------------
#- MAKE A BACKUP OF PREVIOUS BACKUP FILE, IF EXISTS
#------------------------------------------------------------------------
if [ -f ${BACKUP1_CONFIG_FILE} ]; then
    cp -f ${BACKUP1_CONFIG_FILE} ${BACKUP2_CONFIG_FILE} || {
        echo "ERROR: Could not copy ${BACKUP1_CONFIG_FILE} to ${BACKUP2_CONFIG_FILE}"
        exit 2
    }
fi
 
#------------------------------------------------------------------------
#- MAKE A BACKUP OF CURRENT FILE, IF EXISTS
#------------------------------------------------------------------------
if [ -f ${FINAL_CONFIG_FILE} ]; then
    cp -f ${FINAL_CONFIG_FILE} ${BACKUP1_CONFIG_FILE} || {
        echo "ERROR: Could not copy ${FINAL_CONFIG_FILE} to ${BACKUP1_CONFIG_FILE}"
        exit 3
    }
fi

sed -e 's/${VID_MYSQL_HOST}/'${VID_MYSQL_HOST}'/g' \
	-e 's/${VID_MYSQL_PORT}/'${VID_MYSQL_PORT}'/g' \
	-e 's/${VID_MYSQL_DBNAME}/'${VID_MYSQL_DBNAME}'/g' \
	-e 's/${VID_MYSQL_USER}/'${VID_MYSQL_USER}'/g' \
	-e 's/${VID_MYSQL_PASS}/'${VID_MYSQL_PASS}'/g' \
	-e 's/${VID_AAI_HOST}/'${VID_AAI_HOST}'/g' \
	-e 's/${VID_AAI_PORT}/'${VID_AAI_PORT}'/g' \
	-e 's,${AAI_TRUSTSTORE_FILENAME},'${AAI_TRUSTSTORE_FILENAME}',g' \
	-e 's/${AAI_TRUSTSTORE_PASSWD_X}/'${AAI_TRUSTSTORE_PASSWD_X}'/g' \
	-e 's,${AAI_KEYSTORE_FILENAME},'${AAI_KEYSTORE_FILENAME}',g' \
	-e 's/${AAI_KEYSTORE_PASSWD_X}/'${AAI_KEYSTORE_PASSWD_X}'/g' \
	-e 's/${VID_APP_DISPLAY_NAME}/'${VID_APP_DISPLAY_NAME}'/g' \
	-e 's ${VID_ECOMP_SHARED_CONTEXT_REST_URL} '${VID_ECOMP_SHARED_CONTEXT_REST_URL}' g' \
	-e 's ${VID_ECOMP_REDIRECT_URL} '${VID_ECOMP_REDIRECT_URL}' g' \
	-e 's ${VID_ECOMP_REST_URL} '${VID_ECOMP_REST_URL}' g' \
	-e 's ${VID_MSO_SERVER_URL} '${VID_MSO_SERVER_URL}' g' \
	-e 's/${VID_MSO_USER}/'${VID_MSO_USER}'/g' \
	-e 's/${VID_MSO_PASS}/'${VID_MSO_PASS}'/g' \
	-e 's,${VID_MYLOGIN_FEED_DIRECTORY},'${VID_MYLOGIN_FEED_DIRECTORY}',g' \
	-e 's,${MSO_DME2_CLIENT_TIMEOUT},'${MSO_DME2_CLIENT_TIMEOUT}',g' \
	-e 's,${MSO_DME2_CLIENT_READ_TIMEOUT},'${MSO_DME2_CLIENT_READ_TIMEOUT}',g' \
	-e 's,${MSO_DME2_SERVER_URL},'${MSO_DME2_SERVER_URL}',g' \
	-e 's,${MSO_DME2_ENABLED},'${MSO_DME2_ENABLED}',g' \
	-e 's,${MSO_POLLING_INTERVAL_MSECS},'${MSO_POLLING_INTERVAL_MSECS}',g' \
	-e 's,${VID_TRUSTSTORE_FILE},'${VID_TRUSTSTORE_FILE}',g' \
	-e 's/${VID_TRUSTSTORE_PASS}/'${VID_TRUSTSTORE_PASS}'/g' ${TEMPLATE_CONFIG_FILE} > ${FINAL_CONFIG_FILE} || {
		echo "ERROR: Could not process template file ${TEMPLATE_CONFIG_FILE} into ${FINAL_CONFIG_FILE}"
		exit 4
	}

echo "Localized ${FINAL_CONFIG_FILE} successfully."