forked from PnX-SI/GeoNature-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_startup.sh
executable file
·88 lines (70 loc) · 2.97 KB
/
docker_startup.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# script pour l'entry point du docker atlas
set -eof pipefail
export PGPASSWORD=${POSTGRES_PASSWORD}
# si la variable ATLAS_RESET_SCHEMA est à true
# -> suppression en base de données des schema atlas & synthese
#
if [ "$ATLAS_RESET_SCHEMA" = true ];then
psql -d ${POSTGRES_DB} -U ${POSTGRES_USER} -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -t -c "DROP SCHEMA IF EXISTS atlas CASCADE"
psql -d ${POSTGRES_DB} -U ${POSTGRES_USER} -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -t -c "DROP SCHEMA IF EXISTS synthese CASCADE"
fi
# test si le schema atlas existe
schema_atlas_exists=$(psql -d ${POSTGRES_DB} -U ${POSTGRES_USER} -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -t -c "SELECT exists(select schema_name FROM information_schema.schemata WHERE schema_name = 'atlas');" | sed 's/ //g')
# si le schema atlas n'existe pas
if [ ! "$schema_atlas_exists" = "t" ]; then
echo "Schema atlas inexistant ($schema_atlas_exists)"
# si la variable ATLAS_INSTALL_SCHEMA est à true (ou ATLAS_RESET_SCHEMA)
# on procède à l'installation des schema atlas et synthese
if [ "$ATLAS_INSTALL_SCHEMA" = true ] || [ "$ATLAS_RESET_SCHEMA" = true ] ;then
echo Installation du schema de l''atlas
./docker_install_atlas_schema.sh
# sinon on affiche un message avec les indication pour initier la base atlas
else
echo Pour installer la db avec cette commande veuillez definir la variable d''environnement ATLAS_INSTALL_SCHEMA=true
exit 1
fi
else
echo Schema atlas déjà installé
fi
# dossier custom
# dossiers
for custom_dir in "images" "templates"; do
if [ ! -d ${ATLAS_STATIC_FOLDER}/custom/${custom_dir}/ ]; then
mkdir -p ${ATLAS_STATIC_FOLDER}/custom/${custom_dir}/
fi
done
# fichiers (avec find ?)
for custom_file in "templates/footer.html" \
"templates/footer.html" \
"templates/introduction.html" \
"templates/presentation.html" \
"templates/credits.html" \
"templates/mentions-legales.html" \
"templates/bandeaulogoshome.html" \
"templates/navbar.html" \
"templates/robots.txt" \
"custom.css" \
"glossaire.json" \
"maps-custom.js" ; do
if [ ! -f ${ATLAS_STATIC_FOLDER}/custom/${custom_file} ]; then
cp ${ATLAS_STATIC_FOLDER}/../custom_save/${custom_file}.sample ${ATLAS_STATIC_FOLDER}/custom/${custom_file}
fi
done
for custom_file in "favicon.ico" \
"accueil-intro.jpg" \
"logo-structure.png" \
"logo_patrimonial.png" ; do
if [ ! -f ${ATLAS_STATIC_FOLDER}/custom/images/${custom_file} ]; then
cp ${ATLAS_STATIC_FOLDER}/images/sample.${custom_file} ${ATLAS_STATIC_FOLDER}/custom/images/${custom_file}
fi
done
# lancement l'application avec gunicorn
echo Lancement de l''application atlas
gunicorn "atlas.wsgi:create_app()" \
--name=geonature-atlas \
--bind=0.0.0.0:8080 \
--access-logfile=- \
--error-logfile=- \
--reload \
--reload-extra-file=config/config.py # pour relancer l'application en cas de modification du fichier de configuration