<commit_before>#!/bin/sh

PARENT_SCRIPT_URL=https://github.com/mysociety/commonlib/blob/master/bin/install-site.sh

misuse() {
  echo The variable $1 was not defined, and it should be.
  echo This script should not be run directly - instead, please run:
  echo   $PARENT_SCRIPT_URL
  exit 1
}

# Strictly speaking we don't need to check all of these, but it might
# catch some errors made when changing install-site.sh

[ -z "$DIRECTORY" ] && misuse DIRECTORY
[ -z "$UNIX_USER" ] && misuse UNIX_USER
[ -z "$REPOSITORY" ] && misuse REPOSITORY
[ -z "$REPOSITORY_URL" ] && misuse REPOSITORY_URL
[ -z "$BRANCH" ] && misuse BRANCH
[ -z "$SITE" ] && misuse SITE
[ -z "$DEFAULT_SERVER" ] && misuse DEFAULT_SERVER
[ -z "$HOST" ] && misuse HOST
[ -z "$DISTRIBUTION" ] && misuse DISTRIBUTION
[ -z "$DISTVERSION" ] && misuse DISTVERSION
[ -z "$DEVELOPMENT_INSTALL" ] && misuse DEVELOPMENT_INSTALL

if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
    apt-get install -qq -y python-flup gunicorn
    install_nginx
    add_website_to_nginx
fi

# XXX packages file e.g. asks for Apache and central script doesn't
# like comments or alternatives at present
#install_website_packages
apt-get install -y -qq postgresql postgis postgresql-9.1-postgis libpq-dev python-gdal python-dev python-pip python-virtualenv libxml2-dev libxslt1-dev openjdk-7-jre-headless libjpeg-dev >/dev/null

if ! dpkg -l elasticsearch 2>/dev/null | grep -q ^.i; then
    echo "Installing elasticsearch..."
    curl -s -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.3.deb
    dpkg -i elasticsearch-0.90.3.deb
    echo $DONE_MSG
fi

install_postgis
add_postgresql_user

su -l -c "$REPOSITORY/bin/install-as-user '$UNIX_USER' '$HOST' '$DIRECTORY' '$DEVELOPMENT_INSTALL'" "$UNIX_USER"

if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
    install_sysvinit_script
    echo Installation complete - you should now be able to view the site at:
    echo   http://$HOST/
    echo Or you can run the tests by switching to the "'$UNIX_USER'" user and
    echo running something like: $REPOSITORY/manage.py test<commit_msg>Vagrantfile: yui-compressor must be installed for django-pipeline<commit_after>#!/bin/sh

PARENT_SCRIPT_URL=https://github.com/mysociety/commonlib/blob/master/bin/install-site.sh

misuse() {
  echo The variable $1 was not defined, and it should be.
  echo This script should not be run directly - instead, please run:
  echo   $PARENT_SCRIPT_URL
  exit 1
}

# Strictly speaking we don't need to check all of these, but it might
# catch some errors made when changing install-site.sh

[ -z "$DIRECTORY" ] && misuse DIRECTORY
[ -z "$UNIX_USER" ] && misuse UNIX_USER
[ -z "$REPOSITORY" ] && misuse REPOSITORY
[ -z "$REPOSITORY_URL" ] && misuse REPOSITORY_URL
[ -z "$BRANCH" ] && misuse BRANCH
[ -z "$SITE" ] && misuse SITE
[ -z "$DEFAULT_SERVER" ] && misuse DEFAULT_SERVER
[ -z "$HOST" ] && misuse HOST
[ -z "$DISTRIBUTION" ] && misuse DISTRIBUTION
[ -z "$DISTVERSION" ] && misuse DISTVERSION
[ -z "$DEVELOPMENT_INSTALL" ] && misuse DEVELOPMENT_INSTALL

if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
    apt-get install -qq -y python-flup gunicorn
    install_nginx
    add_website_to_nginx
fi

# XXX packages file e.g. asks for Apache and central script doesn't
# like comments or alternatives at present
#install_website_packages
apt-get install -y -qq postgresql postgis postgresql-9.1-postgis libpq-dev python-gdal python-dev python-pip python-virtualenv libxml2-dev libxslt1-dev openjdk-7-jre-headless libjpeg-dev yui-compressor >/dev/null

if ! dpkg -l elasticsearch 2>/dev/null | grep -q ^.i; then
    echo "Installing elasticsearch..."
    curl -s -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.3.deb
    dpkg -i elasticsearch-0.90.3.deb
    echo $DONE_MSG
fi

install_postgis
add_postgresql_user

su -l -c "$REPOSITORY/bin/install-as-user '$UNIX_USER' '$HOST' '$DIRECTORY' '$DEVELOPMENT_INSTALL'" "$UNIX_USER"

if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
    install_sysvinit_script
    echo Installation complete - you should now be able to view the site at:
    echo   http://$HOST/
    echo Or you can run the tests by switching to the "'$UNIX_USER'" user and
    echo running something like: $REPOSITORY/manage.py test
{'fraction_non_alphanumeric': 0.11629542790152403, 'fraction_numerical': 0.007502930832356389, 'mean_word_length': 3.9547038327526134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1852718', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1450, 'n_words': 434}