diff --git a/README.md b/README.md index b7e9f22890b69c2a012bb25e6a9389537f35f19f..4aeaa4e69f580e7b574b82b56ade9f6b2068e468 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,14 @@ Python requirements are listed in ``requirements.txt``. They can be installed wi * change into that directory ``cd AKPlanning`` * clone this repository ``git clone URL .`` + +**Automatic Setup** + +1. execute the setup bash script ``Utils/setup.sh`` + + +**Manual Setup** + 1. setup a virtual environment using the proper python version ``virtualenv env -p python3.7`` 1. activate virtualenv ``source env/bin/activate`` 1. install python requirements ``pip install -r requirements.txt`` @@ -41,7 +49,17 @@ Python requirements are listed in ``requirements.txt``. They can be installed wi 1. create a priviledged user, credentials are entered interactively on CLI ``python manage.py createsuperuser`` 1. deactivate virtualenv ``deactivate`` + +**Development Server** + To start the application for development use ``python manage.py runserver 0:8000`` from the root directory. *Do not use this for deployment!* In your browser, access ``http://127.0.0.1:8000/wannaDB/`` and continue from there. + + +### Updates + +To update the setup to the current version on the main branch of the repository use the update script ``Utils/update.sh`` or ``Utils/update.sh --prod`` in production. + +Afterwards, you may check your setup by executing ``Utils/check.sh`` or ``Utils/check.sh --prod`` in production. diff --git a/Utils/README.md b/Utils/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b601f952c96e4a8a54675da35113d9e7a485844c --- /dev/null +++ b/Utils/README.md @@ -0,0 +1,9 @@ +# AKPlanning Utility Scripts + +This directory contains helper scripts for setup and updating/checking of AKPlanning. + +All scripts should be executed from the project folder (repository root). + +* **setup** installation script for development setup +* **update** update script for development or production (--prod) setup +* **check** setup checking script for development and production (--prod) setup diff --git a/Utils/check.sh b/Utils/check.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f10486b705f19c5e3f9a1a1b15cbcf6b6736b5a --- /dev/null +++ b/Utils/check.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Check the AKPlanning setup for potential problems +# execute as Utils/check.sh + +# activate virtualenv when necessary +if [ -z ${VIRTUAL_ENV+x} ]; then + source env/bin/activate +fi + +# enable really all warnings, some of them are silenced by default +if [[ "$@" == *"--all"* ]]; then + export PYTHONWARNINGS=all +fi + +# in case of checking production setup +if [[ "$@" == *"--prod"* ]]; then + export DJANGO_SETTINGS_MODULE=AKPlanning.settings_production + ./manage.py check --deploy +fi + +./manage.py check diff --git a/Utils/setup.sh b/Utils/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e9d7a2ac0efdb278f18ffa0796fb9e127888f3e --- /dev/null +++ b/Utils/setup.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Setup AKPlanning +# execute as Utils/check.sh + +# abort on error, print executed commands +set -ex + +# remove old virtualenv +rm -rf env/ + +# Setup Python Environment +# Requires: Virtualenv, appropriate Python installation +virtualenv env -p python3.7 +source env/bin/activate +pip install --upgrade setuptools pip wheel +pip install -r requirements.txt + +# Setup database +python manage.py migrate + +# Create superuser +# Credentials are entered interactively on CLI +python manage.py createsuperuser + +deactivate diff --git a/Utils/update.sh b/Utils/update.sh new file mode 100644 index 0000000000000000000000000000000000000000..240767427bb0f37243481ee45e3f583ccd3bc534 --- /dev/null +++ b/Utils/update.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Update AKPlanning +# execute as Utils/check.sh + +# abort on error, print executed commands +set -ex + +# activate virtualenv if necessary +if [ -z ${VIRTUAL_ENV+x} ]; then + source env/bin/activate +fi + +# set environment variable when we want to update in production +if [ "$1" = "--prod" ]; then + export DJANGO_SETTINGS_MODULE=AKPlanning.settings_production +fi + +git pull +pip install --upgrade setuptools pip wheel +pip install --upgrade -r requirements.txt + +if [ "$1" = "--prod" ]; then + ./manage.py collectstatic --noinput +fi + +./manage.py migrate +touch AKPlanning/wsgi.py