-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrattic-entrypoint.sh
executable file
·42 lines (36 loc) · 1.03 KB
/
rattic-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
#!/usr/bin/env bash
# immediate exit on failure
set -e
# make conf from environ
python <<-END
import os
from jinja2 import Template
with open('conf/local.cfg', 'w') as f:
tpl = Template(open('rattic-local.cfg').read())
f.write(tpl.render(**os.environ))
END
if [ "$1" = init ]
then
# import gpg key
gpg --import /opt/rattic_public.key
# sync db
./manage.py syncdb --noinput
./manage.py migrate --all --noinput
# collect static
./manage.py collectstatic -c --noinput
# create initial user
read -p "Password for super-user: " -s rattic_user_pwd && \
declare -x rattic_user_pwd=$rattic_user_pwd && \
./manage.py shell <<-END
import os
from django.contrib.auth.models import User
User.objects.create_superuser(os.environ['rattic_user_username'], os.environ['rattic_user_email'], os.environ['rattic_user_pwd'])
END
elif [ "$1" = manage ]
then
shift;
exec ./manage.py $*
else
# run gunicorn
exec /usr/local/bin/gunicorn --bind=0.0.0.0:8000 --access-logfile=- ratticweb.wsgi:application
fi