Mercurial > dive4elements > river
comparison flys-backend/doc/schema/postgresql-setup.sh @ 5288:b0f14ff573d7
postgresql-setup.sh: Introduced third (host) parameter, fixed alter user statement
and adjusted paths to my system.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 14 Mar 2013 12:24:06 +0100 |
parents | a7e8e9bbe6f5 |
children |
comparison
equal
deleted
inserted
replaced
5287:a7e8e9bbe6f5 | 5288:b0f14ff573d7 |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # $1: user name and password for new DB (equals DB name) | 3 # $1: user name and password for new DB (equals DB name) |
4 # $2: path to directory with schema-scripts | 4 # $2: path to directory with schema-scripts |
5 # $3: host | |
5 | 6 |
6 # run as user postgres (postgresql super-user) | 7 # run as user postgres (postgresql super-user) |
7 # it is assumed that the owner of the DB has the same name as the DB! | 8 # it is assumed that the owner of the DB has the same name as the DB! |
8 | 9 |
9 # create PostGIS-DB | 10 # create PostGIS-DB |
10 createuser -S -D -R $1 | 11 createuser -S -D -R $1 |
11 createdb $1 | 12 createdb $1 |
12 createlang plpgsql $1 | 13 createlang plpgsql $1 |
13 psql -d $1 -f /usr/share/postgresql/contrib/postgis-1.5/postgis.sql | 14 # Appears e.g. as /usr/share/postgresql/contrib/postgis-1.5/ on other systems. |
14 psql -d $1 -f /usr/share/postgresql/contrib/postgis-1.5/spatial_ref_sys.sql | 15 psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql |
15 psql -d $1 -c "ALTER USER $1 PASSWORD $1;" | 16 psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql |
17 psql -d $1 -c "ALTER USER $1 WITH PASSWORD '$1';" | |
16 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;" | 18 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;" |
17 | 19 |
18 # add credentials to .pgpass (or create .pgpass) | 20 # add credentials to .pgpass (or create .pgpass) |
19 echo "*:*:$1:$1:$1" >> ~/.pgpass | 21 echo "*:*:$1:$1:$1" >> ~/.pgpass |
20 chmod 0600 ~/.pgpass | 22 chmod 0600 ~/.pgpass |
21 | 23 |
22 # apply schema-scripts | 24 # apply schema-scripts |
23 psql -d $1 -U $1 -h $HOST -f $2/postgresql.sql | 25 psql -d $1 -U $1 -h $3 -f $2/postgresql.sql |
24 psql -d $1 -U $1 -h $HOST -f $2/postgresql-spatial.sql | 26 psql -d $1 -U $1 -h $3 -f $2/postgresql-spatial.sql |
25 psql -d $1 -U $1 -h $HOST -f $2/postgresql-minfo.sql | 27 psql -d $1 -U $1 -h $3 -f $2/postgresql-minfo.sql |