Fix -permission denied on Docker run
[multicloud/azure.git] / azure / docker / instance-config.sh
1 #!/bin/bash
2 # Copyright (c) 2018 Amdocs
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #         http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # Configure MSB IP address
17 MSB_IP=`echo $MSB_ADDR | cut -d: -f 1`
18 MSB_PORT=`echo $MSB_PORT | cut -d: -f 2`
19 sed -i "s|MSB_SERVICE_IP.*|MSB_SERVICE_IP = '$MSB_IP'|" multicloud_azure/multicloud_azure/pub/config/config.py
20 sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" multicloud_azure/multicloud_azure/pub/config/config.py
21 sed -i "s|DB_NAME.*|DB_NAME = 'inventory'|" multicloud_azure/multicloud_azure/pub/config/config.py
22 sed -i "s|DB_USER.*|DB_USER = 'inventory'|" multicloud_azure/multicloud_azure/pub/config/config.py
23 sed -i "s|DB_PASSWD.*|DB_PASSWD = 'inventory'|" multicloud_azure/multicloud_azure/pub/config/config.py
24 sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" multicloud_azure/multicloud_azure/pub/config/config.py
25
26 # Configure MYSQL
27 if [ -z "$MYSQL_ADDR" ]; then
28     export MYSQL_IP=`hostname -i`
29     export MYSQL_PORT=3306
30     export MYSQL_ADDR=$MYSQL_IP:$MYSQL_PORT
31 else
32     MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
33     MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
34 fi
35 echo "MYSQL_ADDR=$MYSQL_ADDR"
36 sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" multicloud_azure/multicloud_azure/pub/config/config.py
37 sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" multicloud_azure/multicloud_azure/pub/config/config.py
38
39 cat multicloud_azure/multicloud_azure/pub/config/config.py
40
41 sed -i "s/sip=.*/sip=$SERVICE_IP/g" multicloud_azure/run.sh
42 sed -i "s/sip=.*/sip=$SERVICE_IP/g" multicloud_azure/stop.sh
43
44 # Create log directory
45 logDir="/var/log/onap/multicloud/azure"
46 if [ ! -x  $logDir  ]; then
47        mkdir -p $logDir
48 fi