comparison db_schema/setup-db.sh @ 928:6ab17d8b5558

erase mpr_id values in lada_data.sql
author Michael Stanko <mstanko@bfs.de>
date Wed, 04 May 2016 08:07:31 +0200
parents 2b746f4e97d6
children d3d9cd5e18f8
comparison
equal deleted inserted replaced
927:690b6506e0a2 928:6ab17d8b5558
1 #!/bin/sh 1 #!/bin/sh
2 DIR=`dirname $0` 2 DIR=`dirname $0`
3 3
4 ROLE_NAME=${1:-lada} 4 ROLE_NAME=${1:-lada}
5 echo "DROLE_NAME = $ROLE_NAME=" 5 echo "DROLE_NAME = $ROLE_NAME"
6 ROLE_PW=${2:-$ROLE_NAME} 6 ROLE_PW=${2:-$ROLE_NAME}
7 echo "ROLE_PW = $ROLE_PW" 7 echo "ROLE_PW = $ROLE_PW"
8 DB_NAME=${3:-$ROLE_NAME} 8 DB_NAME=${3:-$ROLE_NAME}
9 echo "DB_NAME = $DB_NAME" 9 echo "DB_NAME = $DB_NAME"
10 10
12 if [ -n "$DB_SRV" ] ; then DB_CONNECT_STRING="-h $DB_SRV" ; fi 12 if [ -n "$DB_SRV" ] ; then DB_CONNECT_STRING="-h $DB_SRV" ; fi
13 if [ -n "$DB_SRV" -a -n "$DB_PORT" ] ; then 13 if [ -n "$DB_SRV" -a -n "$DB_PORT" ] ; then
14 DB_CONNECT_STRING="$DB_CONNECT_STRING -p $DB_PORT" 14 DB_CONNECT_STRING="$DB_CONNECT_STRING -p $DB_PORT"
15 fi 15 fi
16 DB_CONNECT_STRING="$DB_CONNECT_STRING -U postgres" 16 DB_CONNECT_STRING="$DB_CONNECT_STRING -U postgres"
17 echo "DB_CONNECT_STRING = $DB_CONNECT_STRING" 17 echo "DB_CONNECT_STRING = $DB_CONNECT_STRING"
18 18
19 if [ `psql $DB_CONNECT_STRING -t --command "SELECT count(*) FROM pg_catalog.pg_user WHERE usename = '$ROLE_NAME'"` -eq 0 ] ; then 19 if [ `psql $DB_CONNECT_STRING -t --command "SELECT count(*) FROM pg_catalog.pg_user WHERE usename = '$ROLE_NAME'"` -eq 0 ] ; then
20 echo create user $ROLE_NAME 20 echo create user $ROLE_NAME
21 psql $DB_CONNECT_STRING --command "CREATE USER $ROLE_NAME PASSWORD '$ROLE_PW';" 21 psql $DB_CONNECT_STRING --command "CREATE USER $ROLE_NAME PASSWORD '$ROLE_PW';"
22 fi 22 fi
23 exit
24 23
25 if psql -h test-pgsql1-fr.lab.bfs.de -U postgres -l | grep -q "^ $DB_NAME " ; then 24 if psql -h test-pgsql1-fr.lab.bfs.de -U postgres -l | grep -q "^ $DB_NAME " ; then
26 echo drop db $DB_NAME 25 echo drop db $DB_NAME
27 psql $DB_CONNECT_STRING --command "DROP DATABASE $DB_NAME" 26 psql $DB_CONNECT_STRING --command "DROP DATABASE $DB_NAME"
28 fi 27 fi
29 28
30 echo create db $DB_NAME 29 echo create db $DB_NAME
31 psql $DB_CONNECT_STRING --command \ 30 psql $DB_CONNECT_STRING --command \
32 "CREATE DATABASE $DB_NAME WITH OWNER = $ROLE_NAME ENCODING = 'UTF8'" 31 "CREATE DATABASE $DB_NAME WITH OWNER = $ROLE_NAME ENCODING = 'UTF8'"
33 exit
34 32
35 echo create postgis extention 33 echo create postgis extention
36 psql $DB_CONNECT_STRING -d $DB_NAME --command \ 34 psql $DB_CONNECT_STRING -d $DB_NAME --command \
37 "CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public" 35 "CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public"
38 36
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)