diff options
author | 2019-04-02 10:38:20 +0800 | |
---|---|---|
committer | 2019-04-02 10:38:20 +0800 | |
commit | ec6cbe7e2f8561e481d4d6a92d459ea6a5d5afa2 (patch) | |
tree | 41a4b428b128d25eb871f4ad55890754abbfeec6 /lcm/docker/instance_init.sh | |
parent | eef1769b34efad6f59224213618719356bf0f35c (diff) |
Fix docker init and config file
Change-Id: Idebc9c03cd050c3d14cdb7eaa7832258ba97e8cd
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm/docker/instance_init.sh')
-rwxr-xr-x | lcm/docker/instance_init.sh | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/lcm/docker/instance_init.sh b/lcm/docker/instance_init.sh index f556c11f..e7951192 100755 --- a/lcm/docker/instance_init.sh +++ b/lcm/docker/instance_init.sh @@ -1,53 +1,30 @@ #!/bin/bash -if [ ! -f /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log ]; then - mkdir -p /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/ - touch /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log -else - echo >/service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log -fi - -if [ ! -f /var/log/onap/vfc/gvnfm-vnflcm/runtime_lcm.log ]; then - mkdir -p /var/log/onap/vfc/gvnfm-vnflcm/ - touch /var/log/onap/vfc/gvnfm-vnflcm/runtime_lcm.log -else - echo >/var/log/onap/vfc/gvnfm-vnflcm/runtime_lcm.log -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/gvnfm/vnflcm/lcm/resources/bin - bash initDB.sh $MYSQL_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP - - man_path=/service/vfc/gvnfm/vnflcm/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='gvnfm';"` - 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='gvnfm';"` - tab3=`echo $tab2|awk '{print $2}'` - if [ $tab3 -gt 0 ] ; then - echo "TABLE CREATE SUCCESSFUL" - fi +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 "table already existed" - exit 1 + MYSQL_ROOT_USER="root" + MYSQL_ROOT_PASSWORD="root" fi - } - -if [ ! -f /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt ]; then - echo 1 > /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt +function create_database { + cd /service/vfc/gvnfm/vnflcm/lcm/resources/bin + bash initDB.sh $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP +} + +function migrate_database { + cd /service/vfc/gvnfm/vnflcm/lcm + python manage.py makemigrations database + python manage.py migrate +} + +cd /service +if [ ! -f dbexist.txt ]; then + echo 1 > dbexist.txt create_database -else - echo "database already existed" + migrate_database fi |