Last active
December 28, 2016 03:13
-
-
Save dooman87/88d83815ed2a1189efd6cf5227fc4b39 to your computer and use it in GitHub Desktop.
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/sh | |
set -e | |
# Perform all actions as $POSTGRES_USER | |
export PGUSER="$POSTGRES_USER" | |
# Create the 'template_postgis' template db | |
psql --dbname="$POSTGRES_DB" <<- 'EOSQL' | |
CREATE DATABASE template_postgis; | |
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; | |
EOSQL | |
# Load PostGIS into both template_database and $POSTGRES_DB | |
for DB in template_postgis "$POSTGRES_DB"; do | |
echo "Loading PostGIS extensions into $DB" | |
psql --dbname="$DB" <<-'EOSQL' | |
CREATE EXTENSION postgis; | |
CREATE EXTENSION postgis_topology; | |
CREATE EXTENSION fuzzystrmatch; | |
CREATE EXTENSION postgis_tiger_geocoder; | |
CREATE EXTENSION hstore; | |
EOSQL | |
done | |
#import Melbourne city | |
osm2pgsql --style /openstreetmap-carto/openstreetmap-carto.style -d gis -U postgres -k --slim /melbourne_australia.osm.pbf | |
touch /var/lib/postgresql/data/DB_INITED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment