diff options
author | Christopher Lott (cl778h) <clott@research.att.com> | 2017-08-07 08:07:56 -0400 |
---|---|---|
committer | Christopher Lott (cl778h) <clott@research.att.com> | 2017-08-07 08:09:42 -0400 |
commit | 0c184777b805dbef3bc43d0084ca578d8b5aba99 (patch) | |
tree | b0faa276b5ec53a6f1c7493cadca3864389a1467 | |
parent | a94e309943d51a2d56e9aa19a582ac9eb40966e6 (diff) |
Revise portal start script for robustness.
1. Use portal script variables instead of hardcoded strings.
2. Remove named Docker containers BEFORE attempting to tag them;
this script failed if docker containers were lingering.
Change-Id: Id9ad8794f35745a02015768ca8b3eed16ad7dd73
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
-rwxr-xr-x[-rw-r--r--] | boot/portal_vm_init.sh | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/boot/portal_vm_init.sh b/boot/portal_vm_init.sh index 58321dd7..942fc52d 100644..100755 --- a/boot/portal_vm_init.sh +++ b/boot/portal_vm_init.sh @@ -1,42 +1,58 @@ #!/bin/bash +# Starts docker containers for ONAP Portal -NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) -NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) -NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) -DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt) +# be verbose +set -x +# Refresh source area with start scripts cd /opt/portal git pull cd /opt -chmod +x portal/deliveries/new_start.sh -chmod +x portal/deliveries/new_stop.sh -chmod +x portal/deliveries/dbstart.sh +# Establish environment variables +NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) +NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) +NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) +DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt) +source portal/deliveries/os_settings.sh + +# Remove the following lines after merging change to os_settings.sh: +DB_VOL_NAME=data_vol_portal +EP_TAG_NAME=portalapps +DB_TAG_NAME=portaldb +WMS_TAG_NAME=portalwms +# End os_settings.sh dupe lines +# Unpack property files unzip -o portal/deliveries/etc.zip -d /PROJECT/OpenSource/UbuntuEP/ +# Refresh images docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO +docker pull $NEXUS_DOCKER_REPO/openecomp/${DB_TAG_NAME}:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/openecomp/${EP_TAG_NAME}:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/openecomp/${WMS_TAG_NAME}:$DOCKER_IMAGE_VERSION -docker pull $NEXUS_DOCKER_REPO/openecomp/portaldb:$DOCKER_IMAGE_VERSION -docker pull $NEXUS_DOCKER_REPO/openecomp/portalapps:$DOCKER_IMAGE_VERSION -docker pull $NEXUS_DOCKER_REPO/openecomp/portalwms:$DOCKER_IMAGE_VERSION - -docker create --name data_vol_portal -v /var/lib/mysql mariadb - -docker tag $NEXUS_DOCKER_REPO/openecomp/portaldb:$DOCKER_IMAGE_VERSION ecompdb:portal -docker tag $NEXUS_DOCKER_REPO/openecomp/portalapps:$DOCKER_IMAGE_VERSION ep:1610-1 -docker tag $NEXUS_DOCKER_REPO/openecomp/portalwms:$DOCKER_IMAGE_VERSION widget-ms:latest +# Remove lingering containers; order matters. +docker rm -f $DB_CONT_NAME +docker rm -f $DB_VOL_NAME +docker rm -f $EP_CONT_NAME +docker rm -f $WMS_CONT_NAME -# Remove the named containers -# These names are in os_settings.sh -docker rm -f ecompdb_portal -docker rm -f onap_portal -docker rm -f ecomp-portal-widget-ms +docker create --name $DB_VOL_NAME -v /var/lib/mysql mariadb +docker tag $NEXUS_DOCKER_REPO/openecomp/${DB_TAG_NAME}:$DOCKER_IMAGE_VERSION $DB_IMG_NAME +docker tag $NEXUS_DOCKER_REPO/openecomp/${EP_TAG_NAME}:$DOCKER_IMAGE_VERSION $EP_IMG_NAME +# WMS image has no version in the registry +docker tag $NEXUS_DOCKER_REPO/openecomp/${WMS_TAG_NAME}:$DOCKER_IMAGE_VERSION ${WMS_IMG_NAME}:latest # Recreate the named containers cd portal/deliveries +echo "Starting database" ./dbstart.sh +echo "Delaying for database" +sleep 10 +echo "Starting apps" ./new_start.sh +echo "Starting widget-ms" ./widget_ms_start.sh sleep 180 @@ -54,6 +70,7 @@ then do sleep 1 done - mysql -u root -p'Aa123456' -h $IP_ADDRESS < /opt/portal/deliveries/Apps_Users_OnBoarding_Script.sql + # no longer necessary; done at docker build time + # mysql -u root -p'Aa123456' -h $IP_ADDRESS < /opt/portal/deliveries/Apps_Users_OnBoarding_Script.sql echo "yes" > /opt/config/boot.txt fi |