Skip to content

Instantly share code, notes, and snippets.

@dlo
Last active September 30, 2015 20:57
Show Gist options
  • Save dlo/1860599 to your computer and use it in GitHub Desktop.
Save dlo/1860599 to your computer and use it in GitHub Desktop.
Ubuntu 11.10 & OS X PostGIS Setup Script

Installing PostGIS

Ubuntu 11.10

sudo apt-get install postgresql-9.3-postgis-2.1
sudo su postgres
bash <(curl -s https://gist.githubusercontent.com/dlo/1860599/raw/514276029c43e6e68a2e2164f2a77fd53354b8e9/create_template.sh)

OS X

brew install postgis
bash <(curl -s https://gist.githubusercontent.com/dlo/1860599/raw/514276029c43e6e68a2e2164f2a77fd53354b8e9/create_template.sh)
#!/bin/bash
# For Ubuntu 11.10
if [ -d "/usr/share/postgresql/9.3/contrib/postgis-2.1" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql/9.3/contrib/postgis-2.1
fi
if [ -d `brew --prefix postgis`/share/postgis ]
then
POSTGIS_SQL_PATH=`brew --prefix postgis`/share/postgis
fi
createdb -E UTF8 template_postgis && \
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';" && \
psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql && \
psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql && \
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" && \
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" && \
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment