Commit | Line | Data |
---|---|---|
73d714db OL |
1 | #! /bin/bash |
2 | ||
3 | ROOT_PATH=. | |
7adc7f71 | 4 | PROJECT_NAME="{{ project_name }}" |
aeef52dd | 5 | PRODUCTION="production" |
7adc7f71 | 6 | |
aeef52dd OL |
7 | ################################################################################ |
8 | # Prerequis pour le fonctionnement du script | |
9 | ################################################################################ | |
73d714db | 10 | if [ ! -e "$ROOT_PATH/README.rst" ]; then |
7adc7f71 | 11 | echo "Placez vous a la racine du projet." |
73d714db OL |
12 | exit -1 |
13 | fi | |
14 | ||
15 | ||
aeef52dd OL |
16 | ################################################################################ |
17 | # Selection de la configuration | |
18 | ################################################################################ | |
73d714db OL |
19 | BUILD=$1 |
20 | if [ "$BUILD" = "" ]; then | |
aeef52dd | 21 | BUILD=$PRODUCTION |
73d714db OL |
22 | fi |
23 | REQUIREMENTS=$ROOT_PATH/requirements/$BUILD.txt | |
7adc7f71 | 24 | SETTINGS=$PROJECT_NAME.settings.$BUILD |
73d714db OL |
25 | |
26 | ||
aeef52dd OL |
27 | ################################################################################ |
28 | # VCS | |
29 | ################################################################################ | |
30 | if [ "$BUILD" = "$PRODUCTION" ]; then | |
31 | echo "Commandes du VCS" | |
32 | GIT_CLEAN="# On branch master nothing to commit (working directory clean)" | |
33 | GIT_STATUS=`git status` | |
34 | if [ "$GIT_STATUS" != "$GIT_CLEAN" ]; then | |
35 | echo "Le depot local n'est pas dans un etat acceptable pour deployer" | |
36 | exit -1 | |
37 | fi | |
38 | fi | |
39 | ||
40 | ||
41 | ################################################################################ | |
42 | # Tests concerant la configuration | |
43 | ################################################################################ | |
44 | if [ ! -e "$ROOT_PATH/conf.py" ]; then | |
45 | echo "Il n'y a pas le fichier conf.py a la racine du projet." | |
46 | exit -1 | |
47 | fi | |
48 | ||
49 | DIFF=`diff -y conf.py.edit conf.py | grep '<' | colordiff` | |
50 | if [ "$DIFF" != "" ]; then | |
51 | echo 'Ajuster le conf.py' | |
52 | diff -y conf.py.edit conf.py | grep '<' | colordiff | |
53 | exit -1 | |
54 | fi | |
55 | ||
56 | ################################################################################ | |
57 | # Preparation de l'environnement | |
58 | ################################################################################ | |
73d714db OL |
59 | VENV_PATH=$ROOT_PATH/.virtualenv |
60 | if [ -e "$VENV_PATH" ]; then | |
7adc7f71 | 61 | echo "l'environnement virtuel existe deja." |
73d714db | 62 | else |
7adc7f71 | 63 | echo "Creation de l'environnement virtuel." |
e5cceae7 | 64 | virtualenv $VENV_PATH |
73d714db OL |
65 | rm -f distribute*.tar.gz |
66 | fi | |
67 | ||
7adc7f71 | 68 | echo "Installation des dependances." |
aeef52dd OL |
69 | echo $VENV_PATH/bin/pip |
70 | $VENV_PATH/bin/pip install -r $REQUIREMENTS | |
71 | ||
72 | if [ "$BUILD" != "$PRODUCTION" ]; then | |
73 | exit -1 | |
74 | fi | |
73d714db | 75 | |
aeef52dd OL |
76 | ################################################################################ |
77 | # Preparation du projet (en production uniquement) | |
78 | ################################################################################ | |
73d714db | 79 | echo "Commandes Django" |
aeef52dd | 80 | echo "settings: " $SETTINGS |
73d714db OL |
81 | $ROOT_PATH/bin/django syncdb --settings=$SETTINGS --noinput |
82 | $ROOT_PATH/bin/django migrate --settings=$SETTINGS --noinput | |
83 | $ROOT_PATH/bin/django collectstatic --settings=$SETTINGS --noinput | |
aeef52dd OL |
84 | |
85 |