update sdnc-web image 28/117728/1
authorMichael DÜrre <michael.duerre@highstreet-technologies.com>
Thu, 11 Feb 2021 06:27:49 +0000 (07:27 +0100)
committerMichael DÜrre <michael.duerre@highstreet-technologies.com>
Thu, 11 Feb 2021 06:27:59 +0000 (07:27 +0100)
handle new env vars during startup

Issue-ID: SDNC-1478
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Change-Id: Id472e21a235fa11e03a9f1441313658fe48e1eb3

Former-commit-id: 887b16594fbbf6551d22922c8bdd37e8f0d47ee2

installation/sdnc-web/src/main/scripts/configure.sh

index cf53a0d..a257e6e 100644 (file)
@@ -28,7 +28,24 @@ update_index_html() {
  
     # Backup the index.html file
     cp /opt/bitnami/nginx/html/odlux/index.html /opt/bitnami/nginx/html/odlux/index.html.backup
-    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    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 
+    #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 
 
 }