forked from dokku-alt/dokku-alt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvars
More file actions
38 lines (33 loc) · 1.25 KB
/
vars
File metadata and controls
38 lines (33 loc) · 1.25 KB
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
#!/bin/bash
source "$(dirname $0)/../dokku_common"
source "$(dirname $0)/../dokku_common_database"
DB_ROOT="$DOKKU_ROOT/.pgsql"
DB_IMAGE="${POSTGRESQL_IMAGE:-ayufan/dokku-alt-postgresql}"
DB_VOLUME="$DB_ROOT/postgresql"
DB_ADMIN_USER="${POSTGRESQL_USER:-root}"
DB_ADMIN_PASSWORD="$DB_ROOT/postgresql_password"
DB_CONTAINER="postgresql_single_container"
DB_CONTAINER_LINK="postgresql"
DB_CONTAINER_VOLUME="${POSTGRESQL_CONTAINER_VOLUME:-/opt/postgresql}"
DB_CONTAINER_PASSWORD="${POSTGRESQL_CONTAINER_PASSWORD:-/opt/postgresql_password}"
DB_HOST="$DB_CONTAINER_LINK"
DB_PORT="${POSTGRESQL_PORT:-5432}"
DB_PROTOCOL="${POSTGRESQL_PROTOCOL:-postgres}"
DB_COMMAND="${POSTGRESQL_COMMAND:-/usr/bin/start_pgsql.sh}"
DB_APP_PASSWORDS="$DB_ROOT/pwd_app_"
DB_APP_DATABASES="$DB_ROOT/dbs_app_"
pgsql_shell() {
DB_USER="$1"
DB_PASSWORD="$2"
shift 2
ensure_database_container_is_running
docker run -i --rm \
--link="$DB_CONTAINER":"$DB_CONTAINER_LINK" \
-e PGUSER="$DB_USER" \
-e PGPASSWORD="$(cat "$DB_PASSWORD")" \
"$DB_IMAGE" \
bash -c "psql -v ON_ERROR_STOP=1 --host=\"$DB_HOST\" --port=\"$DB_PORT\" $@"
}
pgsql_admin() {
pgsql_shell "$DB_ADMIN_USER" "$DB_ADMIN_PASSWORD" "--dbname=$DB_ADMIN_USER" "$@"
}