tom@5284: #!/bin/bash tom@5284: # $1: user name for new DB tom@5284: # $2: path to directory with schema-scripts 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 tom@5284: psql -d $1 -f /usr/share/postgresql/contrib/postgis-1.5/postgis.sql tom@5284: psql -d $1 -f /usr/share/postgresql/contrib/postgis-1.5/spatial_ref_sys.sql tom@5284: psql -d $1 -c "ALTER USER $1 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 tom@5284: psql -d $1 -U $1 -h $HOST -f $2/postgresql.sql tom@5284: psql -d $1 -U $1 -h $HOST -f $2/postgresql-spatial.sql tom@5284: psql -d $1 -U $1 -h $HOST -f $2/postgresql-minfo.sql