From 6d8e536282ff7e20950f36321989c94d6e44b363 Mon Sep 17 00:00:00 2001
From: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Date: Mon, 3 Dec 2012 13:44:07 +0100
Subject: [PATCH] syncdb in bootstrap, fix fab

---
 bin/fnpdjango_bootstrap.sh   | 3 +++
 bin/git-archive-all.sh       | 7 +++++--
 fnpdjango/deploy/__init__.py | 6 +++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/bin/fnpdjango_bootstrap.sh b/bin/fnpdjango_bootstrap.sh
index ecb80a0..5e7babe 100755
--- a/bin/fnpdjango_bootstrap.sh
+++ b/bin/fnpdjango_bootstrap.sh
@@ -63,6 +63,9 @@ echo -e "${strong}Installing requirements...${normal}"
 pip install -r requirements.txt
 echo -e "${strong}Installing developer requirements...${normal}"
 pip install -r requirements-dev.txt
+echo -e "${strong}Running syncdb...${normal}"
+./manage.py syncdb --noinput
+
 echo -e "${strong}Starting new git repository...${normal}"
 git init
 
diff --git a/bin/git-archive-all.sh b/bin/git-archive-all.sh
index 883c029..1f8b222 100755
--- a/bin/git-archive-all.sh
+++ b/bin/git-archive-all.sh
@@ -159,10 +159,13 @@ fi
 if [ $SEPARATE -eq 1 -a ! -d $OUT_FILE ]; then
     echo "When creating multiple archives, your destination must be a directory."
     echo "If it's not, you risk being surprised when your files are overwritten."
-    exit
+    exit 1
 elif [ `git config -l | grep -q '^core\.bare=false'; echo $?` -ne 0 ]; then
     echo "$PROGRAM must be run from a git working copy (i.e., not a bare repository)."
-    exit
+    exit 1
+elif ! git rev-parse HEAD &> /dev/null; then
+    echo "You must have some commit in the git working copy."
+    exit 1
 fi
 
 # Create the superproject's git-archive
diff --git a/fnpdjango/deploy/__init__.py b/fnpdjango/deploy/__init__.py
index 50a0d62..3256584 100644
--- a/fnpdjango/deploy/__init__.py
+++ b/fnpdjango/deploy/__init__.py
@@ -108,7 +108,7 @@ class DebianGunicorn(Task):
     def run(self):
         print '>>> restart webserver using gunicorn-debian'
         with path('/sbin'):
-            sudo('gunicorn-debian restart %s' % self.site_name, shell=False)
+            sudo('gunicorn-debian restart %s' % self.name, shell=False)
 
 class Apache(Task):
     def run(self):
@@ -209,7 +209,7 @@ def migrate():
     "Update the database"
     print '>>> migrate'
     require('app_path', 'project_name')
-    with cd('%(app_path)s/releases/current/%(project_name)s' % env):
+    with cd('%(app_path)s/releases/current' % env):
         run('%(app_path)s/ve/bin/python manage.py syncdb --noinput' % env, pty=True)
         run('%(app_path)s/ve/bin/python manage.py migrate' % env, pty=True)
 
@@ -217,5 +217,5 @@ def collectstatic():
     """Collect static files"""
     print '>>> collectstatic'
     require('app_path', 'project_name')
-    with cd('%(app_path)s/releases/current/%(project_name)s' % env):
+    with cd('%(app_path)s/releases/current' % env):
         run('%(app_path)s/ve/bin/python manage.py collectstatic --noinput' % env, pty=True)
-- 
2.20.1