forked from dcm4che-dockerfiles/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setenv.sh
executable file
·73 lines (66 loc) · 1.99 KB
/
setenv.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
file_env 'LDAP_ROOTPASS' 'secret'
file_env 'KEYCLOAK_DB_USER' 'keycloak'
file_env 'KEYCLOAK_DB_PASSWORD' 'keycloak'
file_env 'KEYCLOAK_USER'
file_env 'KEYCLOAK_PASSWORD'
file_env 'KEYSTORE_PASSWORD' 'secret'
file_env 'KEY_PASSWORD' "${KEYSTORE_PASSWORD}"
file_env 'TRUSTSTORE_PASSWORD' 'changeit'
file_env 'EXTRA_CACERTS_PASSWORD' 'secret'
case $DB_VENDOR in
postgres)
DB="-psql"
;;
mysql)
DB="-mysql"
;;
mariadb)
DB="-mariadb"
;;
oracle)
DB="-oracle"
;;
esac
if [ -n "$DB" -a -n "$JGROUPS_DISCOVERY_EXTERNAL_IP" -a -n "$JGROUPS_DISCOVERY_INITIAL_HOSTS" ]; then
HA="-ha"
fi
if [ -n "$LOGSTASH_HOST" ]; then
LOGSTASH="-logstash"
fi
if [ -z "$JGROUPS_BIND_IP" ]; then
if [ -n "$JGROUPS_BIND_IP_PREFIX" ]; then
for JGROUPS_BIND_IP in $(hostname -I); do if [[ "$JGROUPS_BIND_IP" == "$JGROUPS_BIND_IP_PREFIX"* ]]; then break; fi; done
else
JGROUPS_BIND_IP=$(hostname -i)
fi
fi
SYS_PROPS="-bprivate=$JGROUPS_BIND_IP -c keycloak${HA}${DB}${LOGSTASH}.xml"
SYS_PROPS+=" -Djboss.management.http.port=${MANAGEMENT_HTTP_PORT:-9990}"
SYS_PROPS+=" -Djboss.management.https.port=${MANAGEMENT_HTTPS_PORT:-9993}"
SYS_PROPS+=" -Djboss.http.port=${HTTP_PORT:-8080}"
SYS_PROPS+=" -Djboss.https.port=${HTTPS_PORT:-8443}"
SYS_PROPS+=" -Djboss.redirect.https.port=${REDIRECT_HTTPS_PORT:-8443}"
SYS_PROPS+=" -Djboss.jgroups.tcp.port=${JGROUPS_TCP_PORT:-7600}"
SYS_PROPS+=" -Dkeycloak.import=$KEYCLOAK_IMPORT"