container_init 696 Bytes
Newer Older
CAMPION Sebastien's avatar
CAMPION Sebastien committed
1
2
3
#!/bin/sh
set -e -x

4
5
6
# generate the tokens certificate
gen-cert

7
8
9
# generate a secret token for the controller
gen-controller-token

10
# wait until the mysql server is ready
BAIRE Anthony's avatar
BAIRE Anthony committed
11
wait-mysql
12

BAIRE Anthony's avatar
BAIRE Anthony committed
13
14
mkdir -p /vol/cache/allgo

15
16
17
18
19
20
21
22
23
24
25
26
27
28

mysql_cmd() {
	mysql -uallgo -pallgo -h"$ENV-mysql"
}


# reset the database (if we are in development)
if [ "$ENV" = dev ] ; then
	echo "DROP DATABASE IF EXISTS allgo;" | mysql_cmd
fi

# create the database
echo "CREATE DATABASE allgo CHARACTER SET 'utf8';" | mysql_cmd

29
30
31
32
33
# generate the missing migrations (in qualif/dev only)
if [ "$ENV" = dev ] || [ "$ENV" = qualif ] ; then
	python3 manage.py makemigrations
fi

34
35
36
# create the tables (apply the migrations)
python3 manage.py migrate