forked from slafs/sentry-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sentry_run
executable file
·51 lines (40 loc) · 1.81 KB
/
sentry_run
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
#!/bin/bash
SENTRY_CONF_FILE=${SENTRY_CONF_FILE:-/conf/sentry_docker_conf.py}
# export env var for other scripts to work
export SENTRY_CONF=$SENTRY_CONF_FILE
SCRIPTS_DIR=${SENTRY_SCRIPTS_DIR:-/conf}
# if starting the web worker then try to initialize DB and superuser
if [ "$1" == "start" ] || [ "$1" == "prepare" ]; then
# check DB health if "SENTRY_DOCKER_DO_DB_CHECK" is set
if [ -n "$SENTRY_DOCKER_DO_DB_CHECK" ]; then
python $SCRIPTS_DIR/check_db_isalive.py 10 3
if [ "$?" != "0" ]; then
echo "couldn't establish DB connection. exiting..."
exit 1
fi
fi
sentry --config=$SENTRY_CONF_FILE upgrade --noinput
/usr/bin/expect << EOF
spawn sentry --config=$SENTRY_CONF_FILE createsuperuser --username=${SENTRY_ADMIN_USERNAME:-admin} --email=${SENTRY_ADMIN_EMAIL:-"root@localhost"}
expect "Password: "
send "${SENTRY_ADMIN_PASSWORD:-admin}\r"
expect "Password (again): "
send "${SENTRY_ADMIN_PASSWORD:-admin}\r"
expect "Superuser created successfully."
EOF
if [ -n "$SENTRY_INITIAL_TEAM" ]; then
python $SCRIPTS_DIR/create_team_or_project.py team ${SENTRY_ADMIN_USERNAME:-admin} $SENTRY_INITIAL_TEAM
if [ -n "$SENTRY_INITIAL_PROJECT" ]; then
python $SCRIPTS_DIR/create_team_or_project.py project $SENTRY_INITIAL_TEAM $SENTRY_INITIAL_PROJECT ${SENTRY_INITIAL_PLATFORM:-python}
if [ -n "$SENTRY_INITIAL_KEY" ]; then
python $SCRIPTS_DIR/create_team_or_project.py key $SENTRY_INITIAL_TEAM $SENTRY_INITIAL_PROJECT $SENTRY_INITIAL_KEY
fi
if [ -n "$SENTRY_INITIAL_DOMAINS" ]; then
python $SCRIPTS_DIR/create_team_or_project.py origins $SENTRY_INITIAL_TEAM $SENTRY_INITIAL_PROJECT "$SENTRY_INITIAL_DOMAINS"
fi
fi
fi
fi
if [ "$1" != "prepare" ]; then
exec sentry --config=$SENTRY_CONF_FILE $@
fi