forked from cybertec-postgresql/cybertec_migrator_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-env
executable file
·55 lines (47 loc) · 1.38 KB
/
demo-env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -e
shopt -s nullglob
ENV_FILE='./.env'
FALLBACK_NETWORK='cybertec_migrator_common'
# Change working directory to directory that contains script
cd "${0%/*}"
# Create an .env file if it does not exist
if [ ! -f "${ENV_FILE}" ]; then
cat <<EOF > "${ENV_FILE}"
# —— User configurable ——
EXTERNAL_DEMO_POSTGRES_PORT=5432
EXTERNAL_DEMO_ORACLE_PORT=1521
EOF
chmod 600 "${ENV_FILE}"
printf 'Generated environment file\n'
fi;
catch_all_exit_code=1
case "${1}" in
'up')
if [ ! "${2}" ]; then
>&2 printf "Missing argument for database\n"
else
NETWORK_NAME="${3:-${FALLBACK_NETWORK}}" docker-compose up -d ${2}
fi;
;;
'down')
NETWORK_NAME="${2:-${FALLBACK_NETWORK}}" docker-compose down
;;
'logs')
docker-compose logs
;;
'help')
catch_all_exit_code='0'
;&
*)
printf "$(cat <<EOF
up <database> [docker-network] Start PostgreSQL or Oracle demo database (allowed values: demo_db,oracle)
Docker networks can be listed using 'docker network ls'
down [docker-network] Stop PostgreSQL and Oracle demo database
Docker networks can be listed using 'docker network ls'
logs Print PostgreSQL and Oracle demo database logs
help Display this help text
EOF
)\n"
exit "${catch_all_exit_code}"
esac