Don't modify the config file with sed in the docker entrypoint script
[vfc/nfvo/lcm.git] / docker / instance_init.sh
index c3a3b54..a19e1ce 100755 (executable)
@@ -1,30 +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 {
-    su mysql -c /usr/bin/mysqld_safe &
-    service mysql start
-    # Wait for mysql to initialize; Set mysql root password
-    for i in {1..10}; do
-        sleep $i
-        bash /usr/bin/mysqladmin -u root password $MYSQL_ROOT_PASSWORD &> /dev/null && break
-    done
-}
+if [ $MYSQL_ROOT_USER ] && [ $MYSQL_ROOT_PASSWORD ]; then
+    MYSQL_ROOT_USER=$MYSQL_ROOT_USER
+    MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
+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 migrate_database {
+    cd /service/vfc/nfvo/lcm
+    python manage.py migrate
 }
 
-install_python_libs
-start_redis_server
-start_mysql
 create_database
+migrate_database
+