update README
[vfc/nfvo/lcm.git] / docker / instance_init.sh
index 255bbe2..ed286cf 100755 (executable)
@@ -1,40 +1,27 @@
-#!/bin/bash
+#/bin/bash
 
-function install_python_libs {
-    cd /service/vfc/nfvo/lcm/
-    pip install -r requirements.txt
-}
 
-function start_redis_server {
-    redis-server &
-}
+MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
+MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
 
-function start_mysql {
-    service mysql start
-}
+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
+    MYSQL_ROOT_USER="root"
+    MYSQL_ROOT_PASSWORD="root"
+fi
 
 function create_database {
     cd /service/vfc/nfvo/lcm/resources/bin
-    bash initDB.sh root $MYSQL_ROOT_PASSWORD 3306 127.0.0.1
+    bash initDB.sh $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP
 }
 
-function edit_configs {
-    cd /service/vfc/nfvo/lcm/
-    bash docker/instance_config.sh
+function migrate_database {
+    cd /service/vfc/nfvo/lcm
+    python manage.py migrate
 }
 
-function start_server {
-    cd /service/vfc/nfvo/lcm/
-    bash run.sh
-}
+create_database
+migrate_database
 
-if [ $MYSQL_ROOT_PASSWORD ]; then
-    install_python_libs
-    start_redis_server
-    start_mysql
-    create_database
-    edit_configs
-    start_server
-else
-    echo "MYSQL_ROOT_PASSWORD environment variable not set."
-fi