diff options
author | yangyan <yangyanyj@chinamobile.com> | 2019-03-28 16:17:02 +0800 |
---|---|---|
committer | Yan Yang <yangyanyj@chinamobile.com> | 2019-03-28 08:22:38 +0000 |
commit | a76e4c259dca7d4af1a5245413666062469f272e (patch) | |
tree | 5b7647996c5e192aba2d13bdc8651975aa0b2d54 /lcm/docker/instance_init.sh | |
parent | 8ae005da97061e6b1e8350793f6b67119a27cc95 (diff) |
fix the bug of vnflcm
Change-Id: I2841c32af63c8d85d1fa66721cf026d3860842f5
Issue-ID: VFC-1319
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
Diffstat (limited to 'lcm/docker/instance_init.sh')
-rwxr-xr-x | lcm/docker/instance_init.sh | 26 |
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" |