X-Git-Url: http://git.auf.org/?p=auf_skeleton_django.git;a=blobdiff_plain;f=bin%2Fdeploy;h=3f830f3015c51582bc218b4539e8d3488785f1a8;hp=8eaf77cce53aa8859f57e4637fa1d8e7cb7f5643;hb=aeef52ddf344bb2291cf46f69da202189b70ec1b;hpb=5e7eed6a03028d1f46866e3b7c57c11183e59c09 diff --git a/bin/deploy b/bin/deploy index 8eaf77c..3f830f3 100755 --- a/bin/deploy +++ b/bin/deploy @@ -2,21 +2,60 @@ ROOT_PATH=. PROJECT_NAME="{{ project_name }}" +PRODUCTION="production" +################################################################################ +# Prerequis pour le fonctionnement du script +################################################################################ if [ ! -e "$ROOT_PATH/README.rst" ]; then echo "Placez vous a la racine du projet." exit -1 fi +################################################################################ +# Selection de la configuration +################################################################################ BUILD=$1 if [ "$BUILD" = "" ]; then - BUILD='production' + BUILD=$PRODUCTION fi REQUIREMENTS=$ROOT_PATH/requirements/$BUILD.txt SETTINGS=$PROJECT_NAME.settings.$BUILD +################################################################################ +# VCS +################################################################################ +if [ "$BUILD" = "$PRODUCTION" ]; then + echo "Commandes du VCS" + GIT_CLEAN="# On branch master nothing to commit (working directory clean)" + GIT_STATUS=`git status` + if [ "$GIT_STATUS" != "$GIT_CLEAN" ]; then + echo "Le depot local n'est pas dans un etat acceptable pour deployer" + exit -1 + fi +fi + + +################################################################################ +# Tests concerant la configuration +################################################################################ +if [ ! -e "$ROOT_PATH/conf.py" ]; then + echo "Il n'y a pas le fichier conf.py a la racine du projet." + exit -1 +fi + +DIFF=`diff -y conf.py.edit conf.py | grep '<' | colordiff` +if [ "$DIFF" != "" ]; then + echo 'Ajuster le conf.py' + diff -y conf.py.edit conf.py | grep '<' | colordiff + exit -1 +fi + +################################################################################ +# Preparation de l'environnement +################################################################################ VENV_PATH=$ROOT_PATH/.virtualenv if [ -e "$VENV_PATH" ]; then echo "l'environnement virtuel existe deja." @@ -26,15 +65,21 @@ else rm -f distribute*.tar.gz fi -echo "Activation de l'environnement virtuel." -source $VENV_PATH/bin/activate -which python - - echo "Installation des dependances." -pip install -r $REQUIREMENTS +echo $VENV_PATH/bin/pip +$VENV_PATH/bin/pip install -r $REQUIREMENTS + +if [ "$BUILD" != "$PRODUCTION" ]; then + exit -1 +fi +################################################################################ +# Preparation du projet (en production uniquement) +################################################################################ echo "Commandes Django" +echo "settings: " $SETTINGS $ROOT_PATH/bin/django syncdb --settings=$SETTINGS --noinput $ROOT_PATH/bin/django migrate --settings=$SETTINGS --noinput $ROOT_PATH/bin/django collectstatic --settings=$SETTINGS --noinput + +