#!/bin/bash set -e if [ "$#" -ne 4 ]; then echo "Usage: $0 " exit fi PGH=$1 PGP=$2 PGD=$3 PGU=$4 echo "Host/path to postgres: $PGH" echo " Port: $PGP" echo " Database: $PGD" echo " User: $PGU" echo "Verifying postgres connection..." psql -w "host=$PGH port=$PGP dbname=$PGD user=$PGU" -c "SELECT 1" >/dev/null # Start from script directory to be safe! cd "${0%/*}" virtualenv --python=python3 venv_dev # Newer virtualenvs can't handle symlinks, so create a tiny binary rm -f python cat >../../python < postgresqleu/local_settings.py < devserver-uwsgi.ini echo "" echo "Creating a django superuser, and setting password!" result=`psql -A -n -q -t -w -X -h $PGH -p $PGP -d $PGD -U $PGU -c "SELECT COUNT(*) FROM public.auth_user WHERE is_superuser IS true"` echo "" if [ $result -eq "0" ]; then echo "creating a Django superuser, and setting password!" ./python manage.py createsuperuser else echo "superuser already exists, skipping" fi echo "All ready to go. To start the development server, go to" pwd echo "and run:" echo "uwsgi --ini devserver-uwsgi.ini" echo "" echo "or for a slightly more limited version:" echo "./python manage.py runserver"