4 PROJECT_NAME="{{ project_name }}"
5 PRODUCTION="production"
7 ################################################################################
8 # Prerequis pour le fonctionnement du script
9 ################################################################################
10 if [ ! -e "$ROOT_PATH/README.rst" ]; then
11 echo "KO: Placez vous a la racine du projet."
16 ################################################################################
17 # Selection de la configuration
18 ################################################################################
20 if [ "$BUILD" = "" ]; then
23 REQUIREMENTS=$ROOT_PATH/requirements/$BUILD.txt
24 SETTINGS=$PROJECT_NAME.settings.$BUILD
27 ################################################################################
29 ################################################################################
30 if [ "$BUILD" = "$PRODUCTION" ]; then
31 echo "Commandes du VCS"
32 GIT_CLEAN="# On branch master
33 nothing to commit (working directory clean)"
34 GIT_STATUS=`git status`
35 if [ "$GIT_STATUS" != "$GIT_CLEAN" ]; then
36 echo "KO: Le depot a des modifications locales"
42 ################################################################################
43 # Tests concerant la configuration
44 ################################################################################
45 if [ ! -e "$ROOT_PATH/conf.py" ]; then
46 echo "KO: Il n'y a pas le fichier conf.py a la racine du projet."
50 DIFF=`diff -y conf.py.edit conf.py | grep '<' | colordiff`
51 if [ "$DIFF" != "" ]; then
52 echo 'KO: Ajuster le conf.py'
53 diff -y conf.py.edit conf.py | grep '<' | colordiff
57 ################################################################################
58 # Preparation de l'environnement
59 ################################################################################
60 VENV_PATH=$ROOT_PATH/.virtualenv
61 if [ -e "$VENV_PATH" ]; then
62 echo "l'environnement virtuel existe deja."
64 echo "Creation de l'environnement virtuel."
66 rm -f distribute*.tar.gz
69 echo "Installation des dependances."
70 echo $VENV_PATH/bin/pip
71 $VENV_PATH/bin/pip install -r $REQUIREMENTS
73 ################################################################################
75 ################################################################################
76 if [ "$BUILD" != "$PRODUCTION" ]; then
80 echo "test des permissions"
81 MEDIA_PATH=$ROOT_PATH/media
82 MEDIA_PERMS=`stat -c %a $MEDIA_PATH`
83 if [ "$MEDIA_PERMS" != "2775" ]; then
84 echo "KO: les permissions sur $MEDIA_PATH ne sont pas bonnes (attendu 2775)"
87 MEDIA_GRP=`stat -c %G $MEDIA_PATH`
88 if [ "$MEDIA_GRP" != "www-data" ]; then
89 echo "KO: le groupe sur $MEDIA_PATH n'est pas bon (attendu www-data)"
93 ################################################################################
94 # Preparation du projet (en production uniquement)
95 ################################################################################
96 echo "Commandes Django"
97 echo "settings: " $SETTINGS
98 $ROOT_PATH/bin/django syncdb --settings=$SETTINGS --noinput
99 $ROOT_PATH/bin/django migrate --settings=$SETTINGS --noinput
100 $ROOT_PATH/bin/django collectstatic --settings=$SETTINGS --noinput