/docs/ref/contrib/gis/create_template_postgis-debian.sh

https://code.google.com/p/mango-py/ · Shell · 38 lines · 29 code · 5 blank · 4 comment · 10 complexity · 86c881183dd4c7f33432312d255488e5 MD5 · raw file

  1. #!/bin/bash
  2. # For Ubuntu 8.x and 9.x releases.
  3. if [ -d "/usr/share/postgresql-8.3-postgis" ]
  4. then
  5. POSTGIS_SQL_PATH=/usr/share/postgresql-8.3-postgis
  6. POSTGIS_SQL=lwpostgis.sql
  7. fi
  8. # For Ubuntu 10.04
  9. if [ -d "/usr/share/postgresql/8.4/contrib" ]
  10. then
  11. POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib
  12. POSTGIS_SQL=postgis.sql
  13. fi
  14. # For Ubuntu 10.10 (with PostGIS 1.5)
  15. if [ -d "/usr/share/postgresql/8.4/contrib/postgis-1.5" ]
  16. then
  17. POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib/postgis-1.5
  18. POSTGIS_SQL=postgis.sql
  19. GEOGRAPHY=1
  20. else
  21. GEOGRAPHY=0
  22. fi
  23. createdb -E UTF8 template_postgis && \
  24. createlang -d template_postgis plpgsql && \
  25. psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';" && \
  26. psql -d template_postgis -f $POSTGIS_SQL_PATH/$POSTGIS_SQL && \
  27. psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql && \
  28. psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" && \
  29. psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
  30. if ((GEOGRAPHY))
  31. then
  32. psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
  33. fi