Created
July 16, 2012 02:05
-
-
Save glenrobertson/3119867 to your computer and use it in GitHub Desktop.
postgis_template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run with path to postgis share dir | |
# e.g. ./postgis_template.sh /usr/local/Cellar/postgis/2.0.1/share/postgis | |
POSTGIS_TEMPLATE_PATH=$1; | |
# Creating the template spatial database | |
createdb -E UTF8 -T template0 template_postgis | |
# Loading the PostGIS SQL routines. | |
psql -d template_postgis -f $POSTGIS_TEMPLATE_PATH/postgis.sql | |
psql -d template_postgis -f $POSTGIS_TEMPLATE_PATH/spatial_ref_sys.sql | |
# Enabling users to alter spatial tables. | |
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" | |
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;" | |
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" | |
# Garbage-collect and freeze. | |
psql -d template_postgis -c "VACUUM FULL;" | |
psql -d template_postgis -c "VACUUM FREEZE;" | |
# Allows non-superusers the ability to create from this template. | |
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';" | |
psql -d postgres -c "UPDATE pg_database SET datallowconn='false' WHERE datname='template_postgis';" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment