|
| 1 | +#!/bin/bash |
| 2 | +# ARTWORK |
| 3 | +# GET=1 (attempt to fetch Postgres database from the test server) |
| 4 | +# INIT=1 (needs PG_PASS_RO, PG_PASS_TEAM, initialize from no postgres database state, creates postgres logs database and users) |
| 5 | +# ONLYINIT=1 (only run init_database.sh and then exit success) |
| 6 | +# SKIPVARS=1 (if set it will skip final Postgres vars regeneration) |
| 7 | +set -o pipefail |
| 8 | +exec > >(tee run.log) |
| 9 | +exec 2> >(tee errors.txt) |
| 10 | +if ( [ ! -z "$INIT" ] && ( [ -z "$PG_PASS_RO" ] || [ -z "$PG_PASS_TEAM" ] ) ) |
| 11 | +then |
| 12 | + echo "$0: You need to set PG_PASS_RO, PG_PASS_TEAM when using INIT" |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +if ( [ -z "$PG_PASS" ] || [ -z "$PG_HOST" ] || [ -z "$PG_PORT" ] ) |
| 17 | +then |
| 18 | + echo "$0: you need to set PG_PASS, PG_HOST and PG_PORT to run this script" |
| 19 | + exit 2 |
| 20 | +fi |
| 21 | + |
| 22 | +if [ -z "$ONLYINIT" ] |
| 23 | +then |
| 24 | + if ( [ -z "$PROJ" ] || [ -z "$PROJDB" ] || [ -z "$PROJREPO" ] ) |
| 25 | + then |
| 26 | + echo "$0: You need to set PROJ, PROJDB, PROJREPO environment variables to run this script" |
| 27 | + exit 3 |
| 28 | + fi |
| 29 | +fi |
| 30 | + |
| 31 | +# export PG_ADMIN_USER=sa |
| 32 | +export GHA2DB_PROJECTS_YAML="graphql/projects.yaml" |
| 33 | +export LIST_FN_PREFIX="graphql/all_" |
| 34 | + |
| 35 | +if [ ! -z "$ONLY" ] |
| 36 | +then |
| 37 | + export ONLY |
| 38 | +fi |
| 39 | + |
| 40 | +if [ ! -z "$INIT" ] |
| 41 | +then |
| 42 | + ./devel/init_database.sh || exit 4 |
| 43 | + if [ ! -z "$ONLYINIT" ] |
| 44 | + then |
| 45 | + echo "Only init mode, exiting" |
| 46 | + exit 0 |
| 47 | + fi |
| 48 | +fi |
| 49 | + |
| 50 | +ORGNAME="-" PORT="-" ICON="-" GRAFSUFF="-" GA="-" SKIPGRAFANA=1 ./devel/deploy_proj.sh || exit 5 |
| 51 | + |
| 52 | +if [ -z "$SKIPVARS" ] |
| 53 | +then |
| 54 | + GHA2DB_EXCLUDE_VARS="projects_health_partial_html" ./devel/vars_all.sh || exit 6 |
| 55 | +fi |
| 56 | + |
| 57 | +echo "<<< start: errors.txt >>>" |
| 58 | +cat errors.txt 2>/dev/null |
| 59 | +echo "<<< end: errors.txt >>>" |
| 60 | + |
| 61 | +./devel/set_flag.sh "$PROJDB" provisioned || exit 7 |
| 62 | + |
| 63 | +echo "$0: All deployments finished" |
0 commit comments