Skip to content

Instantly share code, notes, and snippets.

@tr00st
Created June 22, 2015 14:02
Show Gist options
  • Save tr00st/a67eb065a6747fc22a5f to your computer and use it in GitHub Desktop.
Save tr00st/a67eb065a6747fc22a5f to your computer and use it in GitHub Desktop.
GeoDjango Setup - Ubuntu 12.04/14.04
The MIT License (MIT)
Copyright (c) 2015 James Cheese
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
#!/bin/bash
# Sets up dependencies and initializes a database for GeoDjango usage.
# Compatible with Ubuntu 12.04/14.04.
# Config follows.
DB_USER="geodjango"
DB_PASS="my_passwd"
DB_NAME="my_db"
# End of config - don't edit below unless you're feeling particularly adventurous :)
# For compatibility with more than one Ubuntu release...
# This will need to be changed to a different value depending on the version of Ubuntu you're running.
# This sets a sensible value like: POSTGIS_PACKAGE="postgresql-9.3-postgis-2.1"
POSTGIS_PACKAGE="$(apt-cache search "postgis-2"|grep -v "scripts"|sed 's/ - .*//')"
# Install all our dependencies
sudo apt-get install binutils libproj-dev gdal-bin postgis spatialite-bin ${POSTGIS_PACKAGE}
# Setup a DB and a user
sudo -u postgres psql -c "CREATE USER ${DB_USER} PASSWORD '${DB_PASS}';"
sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER ${DB_USER};"
sudo -u postgres psql "$DB_NAME" -c 'create extension postgis;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment