Skip to content
This repository
tree: cea82a257e
Fetching contributors…

Cannot retrieve contributors at this time

file 80 lines (62 sloc) 2.597 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#! /bin/sh

set -e

#DEBHELPER#

confdir=/usr/share/pyshared/sapling/etc/install_config
datadir=/usr/share/localwiki

case "$1" in
    configure)
        # we want our setup to run last, so just activate our trigger
        dpkg-trigger localwiki-setup
;;
    triggered)
        # do the real work here
        cd "$confdir"
        echo "Configuring jetty ..."
        ./setup_jetty.sh

        if [ ! -d "$datadir/env" ]; then
            echo "Creating virtualenv ..."
        fi
        # run virtualenv, even if it's been created, to upgrade python executable
        cd "$datadir"
        virtualenv --quiet env

        . "$datadir/env/bin/activate"
        cd "$confdir"
        echo "Installing required python packages ..."
        pip install --upgrade -r requirements.txt
        deactivate

        # For Ubuntu 11.10, 12.04 (with PostgreSQL 9.1), we have an issue with
        # GeoDjango. We have to turn off standard string formatting. We can
        # re-enable it once it's fixed, in Django 1.3.2

        if [ -d "/etc/postgresql/9.1/main" ]
        then
            echo "#" >> /etc/postgresql/9.1/main/postgresql.conf
            echo "# Following line added by localwiki" >> /etc/postgresql/9.1/main/postgresql.conf
            echo "standard_conforming_strings = off" >> /etc/postgresql/9.1/main/postgresql.conf
            echo "#" >> /etc/postgresql/9.1/main/postgresql.conf

            /etc/init.d/postgresql restart
        fi

        echo "Configuring localwiki ..."
        localwiki-manage setup_all

        # Enable mod_wsgi
        a2enmod wsgi > /dev/null 2>&1

        # If first time setup, initialize site and wiki
        if [ ! -d "$datadir/deploy" ]; then
            echo "Configuring apache ..."
            mkdir "$datadir/deploy"
            cp "$confdir/localwiki.wsgi.template" "$datadir/deploy/localwiki.wsgi"
            cp "$confdir/apache.conf.template" "/etc/apache2/sites-available/example.com"

            # Allow apache to save uploads
            chown www-data:www-data "$datadir/media"

            # Enable mod_headers
            a2enmod headers > /dev/null 2>&1

            # Disable default apache site
            [ -e /etc/apache2/sites-enabled/000-default ] && a2dissite default > /dev/null 2>&1

            # Enable localwiki site
            a2ensite example.com > /dev/null 2>&1

            /etc/init.d/apache2 restart
            echo "LocalWiki site enabled. Configuration in /etc/apache2/sites-available/example.com"
        fi

        # Ask mod_wsgi to reload
        touch "$datadir/deploy/localwiki.wsgi"
;;
esac
Something went wrong with that request. Please try again.