forked from 3ofcoins/docker-sentry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sentry
executable file
·59 lines (45 loc) · 1.55 KB
/
sentry
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
#!/bin/sh
set -e
exec 2>&1
export LC_ALL=${LC_ALL:-C.UTF-8}
# Default gateway is our Docker host
DOCKER_IP="$(ip route show to 0/0)"
DOCKER_IP="${DOCKER_IP#*via }"
DOCKER_IP="${DOCKER_IP%% *}"
export DOCKER_IP
# translate linked container's POSTGRES_PORT to PHOST/PGPORT pair
if [ -n "$POSTGRES_PORT" ] ; then
eval "export `echo "$POSTGRES_PORT" | sed -e 's,tcp://,PGHOST=,' -e 's,:, PGPORT=,'`"
fi
export PGHOST=${PGHOST:-$DOCKER_IP}
export PGPORT=${PGPORT:-5432}
export PGDATABASE=${PGDATABASE:-sentry}
export PGUSER=${PGUSER:-sentry}
export PGPASSWORD=${PGPASSWORD:-sentry}
if [ -z "$SMTP_HOST" ] ; then
export SMTP_HOST=$DOCKER_IP SMTP_PORT=25
else
export SMTP_PORT=${SMTP_PORT:-587}
fi
if [ "$1" = "pg_dump" ] ; then
shift
exec pg_dump "${@}"
fi
[ -f /var/opt/sentry/secret ] || openssl rand -base64 64 | tr -d \\n > /var/opt/sentry/secret
chown root:sentry /var/opt/sentry/secret
chmod 0640 /var/opt/sentry/secret
sentry () {
flock -x /var/opt/sentry/sentry.$1.lock chpst -u sentry /opt/sentry/bin/sentry --config=/etc/sentry/settings.py "${@}"
}
sentry upgrade --noinput
sentry shell <<EOF
from sentry.models import User
from django.core.management import call_command
if User.objects.filter(is_superuser=True).exists():
print "(superuser found, not creating one)"
else:
print "*** Creating initial superuser 'root' with password 'root'"
User.objects.create_superuser('root', 'root@example.com', 'root')
call_command('repair', owner='root')
EOF
exec chpst -u sentry /opt/sentry/bin/sentry --config=/etc/sentry/settings.py "${@}"