summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephen Finucane <stephen.finucane@intel.com>2016-02-09 22:26:13 +0000
committerStephen Finucane <stephen.finucane@intel.com>2016-02-10 20:12:38 +0000
commit6def775af3a727ace056be7de4df8fce35458536 (patch)
tree751c131958859cc7c5adf9eb3944dcbd9f4e4bfd /tools
parentf47701c7e403aef520956c4d3ba1587960c4ca41 (diff)
downloadpatchwork-6def775af3a727ace056be7de4df8fce35458536.tar
patchwork-6def775af3a727ace056be7de4df8fce35458536.tar.gz
vagrant: Add Vagrant-based development environment
Integrate Vagrant by way of a Vagrantfile and a simple install script. This follows many of the instructions found in the development guide with the exceptions of the superuser creation, which is optional, the loading of archives, which requires per-user authentication, and the use of virtual environments, which are unnecessary in a teardown environment such as this. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/install/install.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/tools/install/install.sh b/tools/install/install.sh
new file mode 100644
index 0000000..b2a074b
--- /dev/null
+++ b/tools/install/install.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# Script to set up patchwork on a Vagrant-powered Ubuntu Trusty host
+
+echo -e "\n--- Configuring environment ---\n"
+
+PROJECT_NAME=patchwork
+PROJECT_HOME=/vagrant
+WORKON_HOME=$PROJECT_HOME/.virtualenvs
+
+db_user=root
+db_pass=password
+
+export DJANGO_SETTINGS_MODULE=patchwork.settings.dev
+export DEBIAN_FRONTEND=noninteractive
+
+echo "mysql-server mysql-server/root_password password $db_pass" | debconf-set-selections
+echo "mysql-server mysql-server/root_password_again password $db_pass" | debconf-set-selections
+
+echo -e "\n--- Updating packages list ---\n"
+
+apt-get update -qq
+
+echo -e "\n--- Installing system packages ---\n"
+
+apt-get install -y python python3-dev python3-pip mysql-server \
+ libmysqlclient-dev curl > /dev/null
+
+echo -e "\n--- Installing Python dependencies ---\n"
+
+pip3 -q install virtualenv tox
+pip3 -q install -r $PROJECT_HOME/requirements-dev.txt
+
+echo -e "\n--- Configuring database ---\n"
+
+mysql -u$db_user -p$db_pass << EOF
+DROP DATABASE IF EXISTS patchwork;
+CREATE DATABASE patchwork CHARACTER SET utf8;
+GRANT ALL ON patchwork.* TO 'patchwork'@'localhost' IDENTIFIED BY 'password';
+EOF
+
+chmod a+x $PROJECT_HOME/manage.py
+
+echo -e "\n--- Loading initial data ---\n"
+
+sudo -E -u vagrant python3 $PROJECT_HOME/manage.py migrate > /dev/null
+sudo -E -u vagrant python3 $PROJECT_HOME/manage.py loaddata \
+ $PROJECT_HOME/patchwork/fixtures/default_tags.xml > /dev/null
+sudo -E -u vagrant python3 $PROJECT_HOME/manage.py loaddata \
+ $PROJECT_HOME/patchwork/fixtures/default_states.xml > /dev/null
+sudo -E -u vagrant python3 $PROJECT_HOME/manage.py loaddata \
+ $PROJECT_HOME/patchwork/fixtures/default_projects.xml > /dev/null
+
+echo -e "\n--- Configuring environment ---\n"
+
+cat >> /home/vagrant/.bashrc << EOF
+export DJANGO_SETTINGS_MODULE='patchwork.settings.dev'
+
+alias runserver='python3 /vagrant/manage.py runserver 0.0.0.0:8000'
+alias createsu='python3 /vagrant/manage.py createsuperuser'
+cd /vagrant
+EOF
+
+echo "Done."
+echo "You may now log in:"
+echo " $ vagrant ssh"
+echo "Once logged in, start the server using the 'runserver' alias:"
+echo " $ runserver"
+echo "You may wish to create a superuser for use with the admin console:"
+echo " $ createsuperuser"
+echo "For information on the above, and some examples on loading sample date,"
+echo "please refer to the documentation found in the 'doc' folder."
+echo "Alternatively, check out the docs online:"
+echo " https://patchwork.readthedocs.org/en/latest/development/"
+echo "Happy patchworking."