summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
Diffstat (limited to 'lcm')
-rwxr-xr-xlcm/docker/instance_init.sh26
1 files changed, 7 insertions, 19 deletions
diff --git a/lcm/docker/instance_init.sh b/lcm/docker/instance_init.sh
index 125896a5..aa6a2d63 100755
--- a/lcm/docker/instance_init.sh
+++ b/lcm/docker/instance_init.sh
@@ -1,11 +1,5 @@
#!/bin/bash
-######
-# by vfc-db test
-#####
-# echo "No service needs init."
-#MYSQL_USER=$1
-######
-#by duan
+
pip install PyMySQL==0.9.3
if [ ! -f /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log ]; then
mkdir -p /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/
@@ -29,22 +23,16 @@ MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2`
function create_database {
cd /service/vfc/gvnfm/vnflcm/lcm/resources/bin
bash initDB.sh $MYSQL_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP
- #DIRNAME=`dirname $0`
- #HOME=`cd $DIRNAME/; pwd`
- #man_path=$HOME/../
+
man_path=/service/vfc/gvnfm/vnflcm/lcm
- #tab=`mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "use vfcnfvolcm; select count(*) from vfcnfvolcm;"`
+
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='gvnfm';"`
tab1=`echo $tab |awk '{print $2}'`
- echo "=========="
- echo $tab1
- echo "=========="
+
if [ $tab1 -eq 0 ] ; then
- echo "============"
- echo $tab1
- echo "============"
+
echo "TABLE NOT EXISTS, START MIGRATE"
- python $man_path/manage.py makemigrations database && python $man_path/manage.py 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='gvnfm';"`
tab3=`echo $tab2|awk '{print $2}'`
@@ -59,7 +47,7 @@ fi
if [ ! -f /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt ]; then
echo 1 > /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt
- echo `pwd` >> /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt
+
create_database
else
echo "database already existed"