forked from alerta/docker-alerta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·58 lines (50 loc) · 1.4 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·58 lines (50 loc) · 1.4 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -x
RUN_ONCE=/app/.run_once
# Generate web console config, if not supplied
if [ ! -f "${ALERTA_WEB_CONF_FILE}" ]; then
cat >"${ALERTA_WEB_CONF_FILE}" << EOF
'use strict';
angular.module('config', [])
.constant('config', {
'endpoint' : "${BASE_URL}",
'provider' : "${PROVIDER}",
'client_id' : "${OAUTH2_CLIENT_ID}",
'colors' : {}
});
EOF
fi
# Generate server config, if not supplied
if [ ! -f "${ALERTA_SVR_CONF_FILE}" ]; then
cat >"${ALERTA_SVR_CONF_FILE}" << EOF
SECRET_KEY = '$(< /dev/urandom tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= | head -c 32)'
EOF
fi
if [ ! -f "${RUN_ONCE}" ]; then
# Set BASE_URL
sed -i 's@!BASE_URL!@'"$BASE_URL"'@' /app/nginx.conf
sed -i 's@!BASE_URL!@'"$BASE_URL"'@' /app/supervisord.conf
# Init admin users and API Keys
if [ -n "${ADMIN_USERS}" ]; then
alertad user --password ${ADMIN_PASSWORD:-alerta} --all
alertad key --all
fi
# Generate alerta CLI config
API_KEY=`alertad keys 2>/dev/null | head -1 | cut -d" " -f1`
if [ -n "${API_KEY}" ]; then
cat >${ALERTA_CONF_FILE} << EOF
[DEFAULT]
endpoint = http://localhost:8080${BASE_URL}
key = ${API_KEY}
EOF
fi
# Install plugins
IFS=","
for plugin in ${INSTALL_PLUGINS}
do
echo "Installing plugin '${plugin}'"
/venv/bin/pip install git+https://github.com/alerta/alerta-contrib.git#subdirectory=plugins/$plugin
done
touch ${RUN_ONCE}
fi
exec "$@"