[Dive4elements-commits] [PATCH 1 of 2] added script to setup postgres-DB for testing
Wald Commits
scm-commit at wald.intevation.org
Thu Mar 14 11:56:30 CET 2013
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1363258504 -3600
# Node ID 4e79267c3af83d6aa06cc2bbd50c94226f06a880
# Parent 14db045d63688a1c1c3bdde97a80e08c6ab51d9f
added script to setup postgres-DB for testing
diff -r 14db045d6368 -r 4e79267c3af8 flys-backend/doc/schema/postgresql-setup.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/doc/schema/postgresql-setup.sh Thu Mar 14 11:55:04 2013 +0100
@@ -0,0 +1,24 @@
+#!/bin/bash
+# $1: user name for new DB
+# $2: path to directory with schema-scripts
+
+# run as user postgres (postgresql super-user)
+# it is assumed that the owner of the DB has the same name as the DB!
+
+# create PostGIS-DB
+createuser -S -D -R $1
+createdb $1
+createlang plpgsql $1
+psql -d $1 -f /usr/share/postgresql/contrib/postgis-1.5/postgis.sql
+psql -d $1 -f /usr/share/postgresql/contrib/postgis-1.5/spatial_ref_sys.sql
+psql -d $1 -c "ALTER USER $1 PASSWORD $1;"
+psql -d $1 -c "GRANT ALL ON geometry_columns TO $1; GRANT ALL ON geography_columns TO $1; GRANT ALL ON spatial_ref_sys TO $1;"
+
+# add credentials to .pgpass (or create .pgpass)
+echo "*:*:$1:$1:$1" >> ~/.pgpass
+chmod 0600 ~/.pgpass
+
+# apply schema-scripts
+psql -d $1 -U $1 -h $HOST -f $2/postgresql.sql
+psql -d $1 -U $1 -h $HOST -f $2/postgresql-spatial.sql
+psql -d $1 -U $1 -h $HOST -f $2/postgresql-minfo.sql
More information about the Dive4elements-commits
mailing list