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
|
#!/bin/bash
###
# ============LICENSE_START=======================================================
# ONAP : ccsdk distribution web
# ================================================================================
# Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
# All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
###
# Comment listening on 8080 in nginx.conf as we don't want nginx to listen on any port other than SDNR
sed -i 's/listen/\#listen/g' /opt/bitnami/nginx/conf/nginx.conf
update_index_html() {
# Backup the index.html file
cp /opt/bitnami/nginx/html/odlux/index.html /opt/bitnami/nginx/html/odlux/index.html.backup
#default values
ODLUX_AUTH_METHOD="basic"
ENABLE_ODLUX_RBAC=${ENABLE_ODLUX_RBAC:-false}
if [ "$ENABLE_OAUTH" == "true" ]; then
ODLUX_AUTH_METHOD="oauth"
fi
echo "authentication is $ODLUX_AUTH_METHOD"
echo "rbac access is enabled: $ENABLE_ODLUX_RBAC"
ODLUX_CONFIG='{"authentication":"'$ODLUX_AUTH_METHOD'","enablePolicy":'$ENABLE_ODLUX_RBAC'}'
# sed -z 's/<script>[^<]*<\/script>/<script>\n \/\/ run the application \n require\(\[\"connectApp\",\"faultApp\",\"maintenanceApp\",\"configurationApp\",\"performanceHistoryApp\",\"inventoryApp\",\"eventLogApp\",\"mediatorApp\",\"networkMapApp\",\"linkCalculationApp\",\"helpApp\",\"run\"\], function \(connectApp,faultApp,maintenanceApp,configurationApp,performanceHistoryApp,inventoryApp,eventLogApp,mediatorApp,networkMapApp,linkCalculationApp,helpApp,run\) \{ \n run.configure('$ODLUX_CONFIG'); \n connectApp.register\(\); \n faultApp.register\(\);\n maintenanceApp.register\(\); \n configurationApp.register\(\);\n performanceHistoryApp.register\(\); \n inventoryApp.register\(\);\n eventLogApp.register\(\);\n mediatorApp.register\(\);\n networkMapApp.register\(\);\n linkCalculationApp.register\(\);\n helpApp.register\(\);\n run.runApplication();\n \}\);\n <\/script>/' -i /opt/bitnami/nginx/html/odlux/index.html
#replace require expression
sed -z 's/require(\["run"\],\ function\ (run)/require\(\[\"connectApp\",\"faultApp\",\"maintenanceApp\",\"configurationApp\",\"performanceHistoryApp\",\"inventoryApp\",\"eventLogApp\",\"mediatorApp\",\"networkMapApp\",\"linkCalculationApp\",\"helpApp\",\"run\"\], function \(connectApp,faultApp,maintenanceApp,configurationApp,performanceHistoryApp,inventoryApp,eventLogApp,mediatorApp,networkMapApp,linkCalculationApp,helpApp,run\)/' -i /opt/bitnami/nginx/html/odlux/index.html
#replace run.runApplication expression
sed -z 's/run.runApplication();/connectApp.register\(\); \n faultApp.register\(\);\n maintenanceApp.register\(\); \n configurationApp.register\(\);\n performanceHistoryApp.register\(\); \n inventoryApp.register\(\);\n eventLogApp.register\(\);\n mediatorApp.register\(\);\n networkMapApp.register\(\);\n linkCalculationApp.register\(\);\n helpApp.register\(\);\n run.runApplication();/' -i /opt/bitnami/nginx/html/odlux/index.html
#replace run.configure expression if exists
sed -z 's/run.configureApplication([^)]\+)/run.configureApplication('$ODLUX_CONFIG');/' -i /opt/bitnami/nginx/html/odlux/index.html
}
update_nginx_site_conf() {
if [ "$WEBPROTOCOL" == "HTTPS" ]
then
FN=/opt/bitnami/nginx/conf/server_blocks/https_site.conf
rm /opt/bitnami/nginx/conf/server_blocks/http_site.conf
sed -i 's|SSL_CERT_DIR|'$SSL_CERT_DIR'|g' $FN
sed -i 's|\bSSL_CERTIFICATE\b|'$SSL_CERTIFICATE'|g' $FN
sed -i 's|\bSSL_CERTIFICATE_KEY\b|'$SSL_CERTIFICATE_KEY'|g' $FN
elif [ "$WEBPROTOCOL" == "HTTP" ]
then
FN=/opt/bitnami/nginx/conf/server_blocks/http_site.conf
rm /opt/bitnami/nginx/conf/server_blocks/https_site.conf
fi
if [ -z "$FN" ]; then
echo "unknown env WEBPROTOCOL: $WEBPROTOCOL"
exit 1
fi
# replace needed parameters
sed -i 's|WEBPORT|'$WEBPORT'|g' $FN
sed -i 's|SDNRPROTOCOL|'$SDNRPROTOCOL'|g' $FN
sed -i 's|SDNRHOST|'$SDNRHOST'|g' $FN
sed -i 's|SDNRPORT|'$SDNRPORT'|g' $FN
sed -i 's|DNS_RESOLVER|'$DNS_RESOLVER'|g' $FN
# handle optional parameters
if [ -z "$TRPCEURL" ]; then
echo "transportPCE forwarding disabled"
sed -i 's|proxy_pass TRPCEURL/$1;|return 404;|g' $FN
else
sed -i 's|TRPCEURL|'$TRPCEURL'|g' $FN
fi
if [ -z "$TOPOURL" ]; then
echo "topology api forwarding disabled"
sed -i 's|proxy_pass TOPOURL;|return 404;|g' $FN
else
sed -i 's|TOPOURL|'$TOPOURL'|g' $FN
fi
if [ -z "$TILEURL" ]; then
echo "tile server forwarding disabled"
sed -i 's|proxy_pass TILEURL/$1;|return 404;|g' $FN
else
sed -i 's|TILEURL|'$TILEURL'|g' $FN
fi
}
update_index_html
update_nginx_site_conf
|