Permalink
Browse files

Fix and improve broken install script.

It wouldn't work at all, because it wasn't using a virtualenv and e.g.
on Ubuntu precise you'll only get Django 1.3 that way. Now, use the
separate post deploy script that now exists, and run gunicorn using the
virtualenv's python. Don't install compass, it isn't needed; update the
example config files; add more output.
  • Loading branch information...
1 parent e639caa commit 24a4408862b1ccd336f651f21ef0f9be8db53d09 @dracos dracos committed Dec 4, 2013
Showing with 50 additions and 66 deletions.
  1. +22 −35 bin/install-as-user
  2. +3 −4 conf/httpd.conf-example
  3. +0 −4 conf/nginx.conf.example
  4. +10 −11 conf/packages
  5. +6 −5 conf/packages.debian-squeeze
  6. +8 −6 conf/packages.ubuntu-precise
  7. +1 −1 conf/sysvinit.example
View
57 bin/install-as-user
@@ -1,7 +1,10 @@
#!/bin/sh
set -e
-set -x
+error_msg() { printf "\033[31m%s\033[0m\n" "$*"; }
+notice_msg() { printf "\033[33m%s\033[0m " "$*"; }
+done_msg() { printf "\033[32m%s\033[0m\n" "$*"; }
+DONE_MSG=$(done_msg done)
if [ $# -ne 3 ]
then
@@ -22,19 +25,19 @@ IP_ADDRESS_FOR_HOST="$(dig +short $HOST)"
if [ x = x"$IP_ADDRESS_FOR_HOST" ]
then
- echo "The hostname $HOST didn't resolve to an IP address"
+ error_msg "The hostname $HOST didn't resolve to an IP address"
exit 1
fi
if ! id "$UNIX_USER" 2> /dev/null > /dev/null
then
- echo "The user '$UNIX_USER' didn't exist."
+ error_msg "The user '$UNIX_USER' didn't exist."
exit 1
fi
if [ "$(whoami)" != "$UNIX_USER" ]
then
- echo "This script should be run by the user '$UNIX_USER'."
+ error_msg "This script should be run by the user '$UNIX_USER'."
exit 1
fi
@@ -44,41 +47,25 @@ LINK_DESTINATION="$HOME/mapit"
ln -sfn "$REPOSITORY" $LINK_DESTINATION
cd "$REPOSITORY"
-# Install the compass gem locally - it's required for generating the
-# CSS:
-
-export GEM_HOME="$DIRECTORY/gems"
-mkdir -p "$GEM_HOME"
-export GEM_PATH=
-export PATH="$GEM_HOME/bin:$PATH"
-
-gem install --no-ri --no-rdoc compass
-
-# Use compass to generate the CSS, if it doesn't seem to already
-# exist:
-
-if [ ! -f web/cobrands/default/base.css ]
-then
- bin/mapit_make_css
-fi
-
# Write sensible values into the config file:
-
-RANDOM_STRING=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c32)
-
-sed -r \
- -e "s,^( *MAPIT_DB_NAME:).*,\\1 '$DB_NAME'," \
- -e "s,^( *MAPIT_DB_USER:).*,\\1 '$UNIX_USER'," \
- -e "s,^( *COUNTRY:).*,\\1 ''," \
- -e "s,^( *AREA_SRID:).*,\\1 4326," \
- -e "s,^( *DJANGO_SECRET_KEY:).*,\\1 '$RANDOM_STRING'," \
- conf/general.yml-example > conf/general.yml
+if [ ! -f conf/general.yml ]; then
+ echo -n "Setting up default conf/general.yml file... "
+ RANDOM_STRING=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c32)
+ sed -r \
+ -e "s,^( *MAPIT_DB_NAME:).*,\\1 '$DB_NAME'," \
+ -e "s,^( *MAPIT_DB_USER:).*,\\1 '$UNIX_USER'," \
+ -e "s,^( *COUNTRY:).*,\\1 ''," \
+ -e "s,^( *AREA_SRID:).*,\\1 4326," \
+ -e "s,^( *DJANGO_SECRET_KEY:).*,\\1 '$RANDOM_STRING'," \
+ conf/general.yml-example > conf/general.yml
+ echo $DONE_MSG
+fi
# Create the database if it doesn't exist:
+echo -n "Setting up database... "
if ! psql -l | egrep "^ *$DB_NAME *\|" > /dev/null
then
createdb -T template_postgis --owner "$UNIX_USER" "$DB_NAME"
- cd $REPOSITORY/project
- ./manage.py syncdb --noinput
- ./manage.py migrate mapit
fi
+
+conf/post_deploy_actions.bash
View
7 conf/httpd.conf-example
@@ -6,10 +6,9 @@
# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org
-WSGIDaemonProcess example.mapit.mysociety.org user=exampleuser group=examplegroup processes=5 threads=1 display-name=example.mapit.mysociety.org
+WSGIDaemonProcess example.mapit.mysociety.org user=exampleuser group=examplegroup processes=5 threads=1 display-name=example.mapit.mysociety.org python-path=/data/vhost/example.mapit.mysociety.org/virtualenv-mapit/lib/python/site-packages
WSGIProcessGroup example.mapit.mysociety.org
-WSGIScriptAlias / /data/vhost/example.mapit.mysociety.org/mapit/web/django.wsgi
+WSGIScriptAlias / /data/vhost/example.mapit.mysociety.org/mapit/project/wsgi.py
-Alias /media /usr/share/pyshared/django/contrib/admin/media
-Alias /static /data/vhost/example.mapit.mysociety.org/mapit/mapit/static
+Alias /static /data/vhost/example.mapit.mysociety.org/collected_static
View
4 conf/nginx.conf.example
@@ -20,10 +20,6 @@ server {
root /var/www/mapit/mapit/mapit;
}
- location /media {
- root /usr/share/pyshared/django/contrib/admin;
- }
-
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
View
21 conf/packages
@@ -1,17 +1,16 @@
-python-yaml
-python-beautifulsoup
-python-django
-libapache2-mod-wsgi
-python-psycopg2
-
-libgdal1 | libgdal1-1.6.0 | libgdal1-1.5.0
postgresql
postgresql-9.1-postgis | postgresql-8.4-postgis | postgresql-8.3-postgis
-
-ruby-sass
-
+libgdal1 | libgdal1-1.6.0 | libgdal1-1.5.0
memcached
+python-virtualenv
+python-django
+python-django-south
+python-psycopg2
+python-yaml
python-memcache
python-gdal
-python-django-south
+python-beautifulsoup
+
+libapache2-mod-wsgi
+ruby-sass
python-shapely
View
11 conf/packages.debian-squeeze
@@ -1,11 +1,12 @@
-python-yaml
-python-django
-python-psycopg2
-libgdal1-1.6.0
postgresql
postgresql-8.4-postgis
+libgdal1-1.6.0
memcached
+python-virtualenv
+python-django
+python-django-south
+python-psycopg2
+python-yaml
python-memcache
python-gdal
-python-django-south
python-beautifulsoup
View
14 conf/packages.ubuntu-precise
@@ -1,11 +1,13 @@
-python-beautifulsoup
-python-yaml
-python-django
-python-psycopg2
-libgdal1-1.7.0
postgresql
postgresql-9.1-postgis
+libgdal1-1.7.0
memcached
+python-virtualenv
+python-django
+python-django-south
+python-psycopg2
+python-yaml
python-memcache
python-gdal
-python-django-south
+python-beautifulsoup
+ruby-sass
View
2 conf/sysvinit.example
@@ -21,7 +21,7 @@ test -f $DAEMON || exit 0
set -e
start_daemon() {
- cd $SITE_HOME/mapit/project && gunicorn_django \
+ cd $SITE_HOME/mapit && ../virtualenv-mapit/bin/python /usr/bin/gunicorn project.wsgi:application \
--user=$USER \
--group=$USER \
-D \

0 comments on commit 24a4408

Please sign in to comment.