|
1 |
| -#! /usr/bin/env bash |
| 1 | +#!/usr/bin/env bash |
| 2 | +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
| 3 | + set -euo pipefail |
| 4 | +fi |
| 5 | +SOURCE_DIR=`dirname "${BASH_SOURCE[0]}"` |
| 6 | +cd "$(dirname "$0")" |
| 7 | + |
| 8 | +if [[ $# -eq 0 ]] && [[ -z "${PG_BROAD_VERSION:-}" ]]; then |
| 9 | + echo "Usage: ./$(basename "$0") [latest/oldest]" >&2 |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | +# `oldest` or `latest` |
| 13 | +container=mb-postgres-db-${1:-$PG_BROAD_VERSION} |
| 14 | +port=$(docker port ${container} 5432/tcp | cut -d: -f2) |
| 15 | +source ${SOURCE_DIR}/getenv.sh ${container} POSTGRES_USER POSTGRES_DB POSTGRES_PASSWORD |
| 16 | + |
| 17 | +export MB_DB_TYPE=postgres |
| 18 | +export MB_DB_DBNAME=${POSTGRES_DB} |
| 19 | +export MB_DB_HOST=127.0.0.1 |
| 20 | +export MB_DB_PASS=${POSTGRES_PASSWORD} |
| 21 | +export MB_DB_PORT=${port} |
| 22 | +export MB_DB_USER=${POSTGRES_USER} |
2 | 23 |
|
3 |
| -set -euo pipefail |
| 24 | +export MB_POSTGRESQL_TEST_USER=${MB_DB_USER} |
| 25 | +export MB_POSTGRESQL_TEST_PASSWORD=${MB_DB_PASS} |
| 26 | +export MB_POSTGRESQL_TEST_DBNAME=${MB_DB_DBNAME} |
| 27 | +export MB_POSTGRESQL_TEST_HOST=${MB_DB_HOST} |
| 28 | +export MB_POSTGRESQL_TEST_PORT=${MB_DB_PORT} |
4 | 29 |
|
5 |
| -CONTAINER_NAME=mb-postgres-db |
6 |
| -HOST_PORT=${PGSQL_PORT:-5432} |
7 |
| -DB_NAME=metabase |
8 |
| -DB_USER=metabase |
9 |
| -DB_PASSWORD=password |
| 30 | +export PGHOST=${MB_DB_HOST} |
| 31 | +export PGPORT=${MB_DB_PORT} |
| 32 | +export PGUSER=${MB_DB_USER} |
| 33 | +export PGPASSWORD=${MB_DB_PASS} |
| 34 | +export PGDATABASE=${MB_DB_DBNAME} |
10 | 35 |
|
11 | 36 | function print-postgres-vars() {
|
12 | 37 | cat <<EOF
|
13 | 38 | Java properties:
|
14 |
| --Dmb.postgresql.test.host=localhost -Dmb.postgresql.test.port=${HOST_PORT} -Dmb.postgresql.test.db=${DB_NAME} -Dmb.postgresql.test.user=${DB_USER} -Dmb.postgresql.test.password=${DB_PASSWORD} |
| 39 | +-Dmb.postgresql.test.host=localhost -Dmb.postgresql.test.port=${MB_DB_PORT} -Dmb.postgresql.test.db=${MB_DB_DBNAME} -Dmb.postgresql.test.user=${MB_DB_USER} -Dmb.postgresql.test.password=${MB_DB_PASS} |
15 | 40 |
|
16 | 41 | Clojure pairs:
|
17 |
| -:mb-postgresql-test-host "localhost" :mb-postgresql-test-port "${HOST_PORT}" :mb-postgresql-test-db "${DB_NAME}" :mb-postgresql-test-user "${DB_USER}" :mb-postgresql-test-password "${DB_PASSWORD}" |
| 42 | +:mb-postgresql-test-host "localhost" :mb-postgresql-test-port "${MB_DB_PORT}" :mb-postgresql-test-db "${MB_DB_DBNAME}" :mb-postgresql-test-user "${MB_DB_USER}" :mb-postgresql-test-password "${MB_DB_PASS}" |
18 | 43 |
|
19 | 44 | Bash variables:
|
20 |
| -MB_POSTGRESQL_TEST_HOST=localhost MB_POSTGRESQL_TEST_PORT=${HOST_PORT} MB_POSTGRESQL_TEST_DB=${DB_NAME} MB_POSTGRESQL_TEST_USER=${DB_USER} MB_POSTGRESQL_TEST_PASSWORD=${DB_PASSWORD} |
| 45 | +MB_POSTGRESQL_TEST_HOST=localhost MB_POSTGRESQL_TEST_PORT=${MB_DB_PORT} MB_POSTGRESQL_TEST_DB=${MB_DB_DBNAME} MB_POSTGRESQL_TEST_USER=${MB_DB_USER} MB_POSTGRESQL_TEST_PASSWORD=${MB_DB_PASS} |
21 | 46 | EOF
|
22 | 47 | }
|
23 | 48 |
|
|
0 commit comments