tom@5284: #!/bin/bash felix@5287: felix@5287: # $1: user name and password for new DB (equals DB name) tom@5284: # $2: path to directory with schema-scripts felix@5288: # $3: host tom@5284: tom@5284: # run as user postgres (postgresql super-user) tom@5284: # it is assumed that the owner of the DB has the same name as the DB! tom@5284: tom@5284: # create PostGIS-DB tom@5284: createuser -S -D -R $1 tom@5284: createdb $1 tom@5284: createlang plpgsql $1 felix@5288: # Appears e.g. as /usr/share/postgresql/contrib/postgis-1.5/ on other systems. felix@5288: psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql felix@5288: psql -d $1 -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql felix@5288: psql -d $1 -c "ALTER USER $1 WITH PASSWORD '$1';" tom@5284: 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;" tom@5284: tom@5284: # add credentials to .pgpass (or create .pgpass) tom@5284: echo "*:*:$1:$1:$1" >> ~/.pgpass tom@5284: chmod 0600 ~/.pgpass tom@5284: tom@5284: # apply schema-scripts felix@5288: psql -d $1 -U $1 -h $3 -f $2/postgresql.sql felix@5288: psql -d $1 -U $1 -h $3 -f $2/postgresql-spatial.sql felix@5288: psql -d $1 -U $1 -h $3 -f $2/postgresql-minfo.sql