summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/instance_config.sh12
-rwxr-xr-xdocker/instance_init.sh56
2 files changed, 26 insertions, 42 deletions
diff --git a/docker/instance_config.sh b/docker/instance_config.sh
index 185194cd..524d4e7f 100755
--- a/docker/instance_config.sh
+++ b/docker/instance_config.sh
@@ -29,14 +29,16 @@ fi
# Configure MYSQL
MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
-MYSQL_USER=`echo $MYSQL_AUTH | cut -d: -f 1`
-MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2
-
echo "MYSQL_ADDR=$MYSQL_ADDR"
+
+if [ $REDIS_ADDR ]; then
+ REDIS_IP=`echo $REDIS_ADDR | cut -d: -f 1`
+else
+ REDIS_IP="$MYSQL_ADDR"
+fi
+
sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py
sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/nfvo/lcm/lcm/pub/config/config.py
sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py
-sed -i "s|DB_USER.*|DB_USER = '$MYSQL_USER'|" vfc/nfvo/lcm/lcm/pub/config/config.py
-sed -i "s|DB_PASSWD.*|DB_PASSWD = '$MYSQL_ROOT_PASSWORD'|" vfc/nfvo/lcm/lcm/pub/config/config.py
cat vfc/nfvo/lcm/lcm/pub/config/config.py
diff --git a/docker/instance_init.sh b/docker/instance_init.sh
index 70e83016..6c289657 100755
--- a/docker/instance_init.sh
+++ b/docker/instance_init.sh
@@ -1,52 +1,34 @@
#/bin/bash
-mkdir -p /service/vfc/nfvo/lcm/resources/bin/logs
-mkdir -p /var/log/onap/vfc/nslcm/
-if [ ! -f /service/vfc/nfvo/lcm/resources/bin/logs/django.log ]; then
- touch /service/vfc/nfvo/lcm/resources/bin/logs/django.log
-else
- echo >/service/vfc/nfvo/lcm/resources/bin/logs/django.log
-fi
-if [ ! -f /var/log/onap/vfc/nslcm/runtime_nslcm.log ]; then
- touch /var/log/onap/vfc/nslcm/runtime_nslcm.log
+MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
+MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
+
+if [ $MYSQL_AUTH ]; then
+ MYSQL_ROOT_USER=`echo $MYSQL_AUTH | cut -d: -f 1`
+ MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2`
else
- echo >/var/log/onap/vfc/nslcm/runtime_nslcm.log
+ MYSQL_ROOT_USER="root"
+ MYSQL_ROOT_PASSWORD="root"
fi
-MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
-MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
-MYSQL_USER=`echo $MYSQL_AUTH | cut -d: -f 1`
-MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2`
function create_database {
cd /service/vfc/nfvo/lcm/resources/bin
- bash initDB.sh $MYSQL_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP
- man_path=/service/vfc/nfvo/lcm
- tab=`mysql -u${MYSQL_USER} -p${MYSQL_ROOT_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='vfcnfvolcm';"`
- tab1=`echo $tab |awk '{print $2}'`
-
- if [ $tab1 -eq 0 ] ; then
-
- echo "TABLE NOT EXISTS, START MIGRATE"
- python $man_path/manage.py makemigrations database && python $man_path/manage.py migrate database &
- wait
- tab2=`mysql -u${MYSQL_USER} -p${MYSQL_ROOT_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='vfcnfvolcm';"`
- tab3=`echo $tab2|awk '{print $2}'`
- if [ $tab3 -gt 0 ] ; then
- echo "TABLE CREATE uUCCESSFUL"
- fi
-else
- echo "table already existed"
- exit 1
-fi
+ bash initDB.sh $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP
+
}
+function migrate_database {
+ cd /service/vfc/nfvo/lcm
+ python manage.py makemigrations database
+ python manage.py migrate
+}
-if [ ! -f /service/vfc/nfvo/lcm/docker/db.txt ]; then
- echo 1 > /service/vfc/nfvo/lcm/docker/db.txt
+cd /service
+if [ ! -f dbexist.txt ]; then
+ echo 1 > dbexist.txt
create_database
-else
- echo "database already existed"
+ migrate_database
fi