Skip to content

Instantly share code, notes, and snippets.

@jamesjohnson
Forked from dlo/README.md
Created February 19, 2012 22:07
Show Gist options
  • Save jamesjohnson/1866117 to your computer and use it in GitHub Desktop.
Save jamesjohnson/1866117 to your computer and use it in GitHub Desktop.
Ubuntu 11.10, PostGIS 1.5 Setup Script

Installing PostGIS

Ubuntu 11.10

sudo apt-get install postgresql-9.1-postgis
sudo su postgres
bash <(curl -s https://raw.github.com/gist/18660599/create_template.sh)

Ubuntu 11.04

sudo apt-get install postgresql-8.4-postgis
sudo su postgres
bash <(curl -s https://raw.github.com/gist/1866117/create_template_add_lang.sh)

OS X 10.7.3

brew install postgis
bash <(curl -s https://raw.github.com/gist/1860599/create_template.sh)
#!/bin/bash
if [ -d "/usr/share/postgresql/8.4/contrib/postgis-1.5" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib/postgis-1.5
fi
if [ -d "/usr/share/postgresql/9.1/contrib/postgis-1.5" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql/9.1/contrib/postgis-1.5
fi
if [ -d "/usr/local/Cellar/postgis/1.5.3/share/postgis" ]
then
POSTGIS_SQL_PATH=/usr/local/Cellar/postgis/1.5.3/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;"
#!/bin/bash
if [ -d "/usr/share/postgresql/8.4/contrib/postgis-1.5" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib/postgis-1.5
fi
if [ -d "/usr/share/postgresql/9.1/contrib/postgis-1.5" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql/9.1/contrib/postgis-1.5
fi
if [ -d "/usr/local/Cellar/postgis/1.5.3/share/postgis" ]
then
POSTGIS_SQL_PATH=/usr/local/Cellar/postgis/1.5.3/share/postgis
fi
createdb -E UTF8 template_postgis && \
createlang -d template_postgis plpgsql && \
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