-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-entrypoint.sh
65 lines (54 loc) · 1.64 KB
/
docker-entrypoint.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
#!/bin/bash
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"
}
load_vars() {
file_env "DB_PASSWORD"
file_env "ADMIN_PASSWORD"
file_env "SESSION_KEY"
}
install_adapt() {
echo "No 'conf' dir found, running 'node install...'"
tenantname=`od -x /dev/urandom | head -1 | awk '{OFS=""; print $2$3,$4,$5,$6,$7$8$9}'`
yes "" | node install --install Y \
--authoringToolRepository https://github.com/adaptlearning/adapt_authoring.git \
--frameworkRepository https://github.com/adaptlearning/adapt_framework.git \
--frameworkRevision tags/v5.14.0 \
--serverPort "${PORT}" --serverName "${DOMAIN}" \
--dbHost "${DB_HOST}" --dbName "${DB_NAME}" --dbPort "${DB_PORT}" \
--dbUser "${DB_USER}" \
--useConnectionUri false \
--dataRoot data \
--sessionSecret "${SESSION_KEY}" --useffmpeg Y \
--useSmtp true --smtpService "${SMTP_SERVICE}" \
--smtpConnectionUrl smtp://postfix_relay_app \
--fromAddress "${FROM_EMAIL}" \
--masterTenantName $tenantname --masterTenantDisplayName $tenantname \
--suEmail "${ADMIN_EMAIL}" --suPassword "${ADMIN_PASSWORD}" \
--suRetypePassword "${ADMIN_PASSWORD}" \
--dbPass "${DB_PASSWORD}" --dbAuthSource "${DB_AUTH_SOURCE}"
--smtpUsername "${SMTP_USERNAME}" --smtpPassword "${SMTP_PASSWORD}"
}
main() {
set -eu
load_vars
if [ ! -d conf ]; then
install_adapt
fi
}
main
exec "$@"