diff options
Diffstat (limited to 'openecomp-be/dist/sdc-onboard-db-init-docker/artifacts')
-rw-r--r-- | openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/Dockerfile | 4 | ||||
-rw-r--r-- | openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/startup.sh | 42 |
2 files changed, 29 insertions, 17 deletions
diff --git a/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/Dockerfile b/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/Dockerfile index 8408d2f51c..05034e1565 100644 --- a/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/Dockerfile +++ b/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/Dockerfile @@ -32,8 +32,8 @@ USER sdc COPY --chown=sdc:sdc init_keyspaces.cql /home/sdc/ COPY --chown=sdc:sdc init_schemas.cql /home/sdc/ -COPY --chown=sdc:sdc alter_tables.cql /home/sdc/ -COPY --chown=sdc:sdc startup.sh /home/sdc/ +COPY --chown=sdc:sdc upgrade-scripts /home/sdc/upgrade-scripts +COPY --chown=sdc:sdc startup.sh /home/sdc/ RUN chmod 770 /home/sdc/startup.sh diff --git a/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/startup.sh b/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/startup.sh index 92bf869ccc..3856e10f89 100644 --- a/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/startup.sh +++ b/openecomp-be/dist/sdc-onboard-db-init-docker/artifacts/startup.sh @@ -1,38 +1,50 @@ #!/bin/sh - -cd /home/sdc +SDC_HOME="/home/sdc" +cd $SDC_HOME || { echo "$(date) Failed to access directory $SDC_HOME"; exit 1; } CS_PORT="" CS_HOST=127.0.0.1 -if [ ! -z "${CS_HOST_IP}" ]; then +if [ -n "${CS_HOST_IP}" ]; then CS_HOST=$CS_HOST_IP fi -if [ ! -z "${CS_HOST_PORT}" ]; then +if [ -n "${CS_HOST_PORT}" ]; then CS_PORT=$CS_HOST_PORT fi -echo "[Info] Going to initialize sdc onboard cassandra: user=$SDC_USER; host=$CS_HOST; port=$CS_PORT" +echo "$(date) [Info] Going to initialize sdc onboard cassandra: user=$SDC_USER; host=$CS_HOST; port=$CS_PORT" -echo "[Info] Initializing onboard keyspaces" -date; -cqlsh -u $SDC_USER -p $SDC_PASSWORD -f init_keyspaces.cql $CS_HOST $CS_PORT +echo "$(date) [Info] Initializing onboard keyspaces" +cqlsh -u "$SDC_USER" -p "$SDC_PASSWORD" -f init_keyspaces.cql "$CS_HOST" "$CS_PORT" rc=$? -date; if [ $rc != 0 ]; then - echo "[Error] Failed to initialize onboard keyspaces"; + echo "$(date) [Error] Failed to initialize onboard keyspaces"; exit $rc; fi +echo "$(date) [Info] Finished initializing onboard keyspaces" -echo "[Info] Initializing onboard schemas" -date; -cqlsh -u $SDC_USER -p $SDC_PASSWORD -f init_schemas.cql $CS_HOST $CS_PORT +echo "$(date) [Info] Initializing onboard schemas" +cqlsh -u "$SDC_USER" -p "$SDC_PASSWORD" -f init_schemas.cql "$CS_HOST" "$CS_PORT" rc=$? -date; if [ $rc != 0 ]; then - echo "[Error] Failed to initialize onboard schemas"; + echo "$(date) [Error] Failed to initialize onboard schemas"; exit $rc; fi +echo "$(date) [Info] Finished initializing onboard schemas" + +echo "$(date) [Info] Upgrading onboard schemas" +for entry in "$SDC_HOME/upgrade-scripts"/* +do + echo "$(date) Running upgrade file '$entry'" + cqlsh -u "$SDC_USER" -p "$SDC_PASSWORD" -f "$entry" "$CS_HOST" "$CS_PORT" + rc=$? + if [ $rc != 0 ]; then + echo "$(date) [Warn] Upgrade failed for file '$entry'. It is possible that the upgrade was previously applied."; + fi + echo "$(date) Successfully ran upgrade file '$entry'" +done + +echo "$(date) [Info] Onboarding init was successful"
\ No newline at end of file |