Mercurial > gemma
annotate schema/install-db.sh @ 1548:ccf4fc8a6402
Import queue: Give milliseconds in JSON output, too.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 10 Dec 2018 16:49:34 +0100 |
parents | 1d1fc92fc3ea |
children | 9d51f022b8ee |
rev | line source |
---|---|
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
1 #!/bin/bash -e |
1303
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
2 # This is Free Software under GNU Affero General Public License v >= 3.0 |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
3 # without warranty, see README.md and license for details. |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
4 # |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
5 # SPDX-License-Identifier: AGPL-3.0-or-later |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
6 # License-Filename: LICENSES/AGPL-3.0.txt |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
7 # |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
8 # Copyright (C) 2018 by via donau |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
9 # – Österreichische Wasserstraßen-Gesellschaft mbH |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
10 # Software engineering by Intevation GmbH |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
11 # |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
12 # Author(s): |
a8d1f2897c42
repair schema install scripts
Bernhard Reiter <bernhard@intevation.de>
parents:
1301
diff
changeset
|
13 # * Sascha Wilde <wilde@intevation.de> |
1336
f65d1767452c
add headers for licensing to some schema files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1303
diff
changeset
|
14 # * Tom Gottfried <tom@intevation.de> |
1339
1d1fc92fc3ea
Fixed authors in two schema files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1338
diff
changeset
|
15 # * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
17 ME=`basename "$0"` |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
18 BASEDIR=`dirname "$0"` |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
19 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
20 usage() |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
21 { |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
22 cat <<EOF |
260
c2cef3ce8853
db-setup script: Improved help message.
Sascha Wilde <wilde@intevation.de>
parents:
259
diff
changeset
|
23 $ME [OPTION]... |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
24 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
25 Options: |
260
c2cef3ce8853
db-setup script: Improved help message.
Sascha Wilde <wilde@intevation.de>
parents:
259
diff
changeset
|
26 -d, --db=NAME create the database NAME. Default: "gemma" |
c2cef3ce8853
db-setup script: Improved help message.
Sascha Wilde <wilde@intevation.de>
parents:
259
diff
changeset
|
27 -p, --port=PORT connect do the postgresql cluster at PORT. |
c2cef3ce8853
db-setup script: Improved help message.
Sascha Wilde <wilde@intevation.de>
parents:
259
diff
changeset
|
28 Default is the postgresql standard port 5432 |
c2cef3ce8853
db-setup script: Improved help message.
Sascha Wilde <wilde@intevation.de>
parents:
259
diff
changeset
|
29 -D, --demo also install demo accounts and data |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
30 -G, --geonames also import geonames data |
331
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
31 --adminpw set the password to use for the "sysadmin" account. |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
32 Default is a random password. |
463
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
33 --metapw set the password to use for the "meta_login" account. |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
34 Default is a random password. |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
35 --drop drop database and all roles |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
36 --help display this help and exit |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
37 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
38 EOF |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
39 } |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
40 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
41 fatal() |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
42 { |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
43 echo >&2 "$1" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
44 exit 23 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
45 } |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
46 |
330
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
47 genpw() |
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
48 # $1 - length |
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
49 { |
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
50 dd count=1 if=/dev/urandom 2>/dev/null \ |
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
51 | tr -cd '[:alnum:],._!?-' | tail -c "$1" |
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
52 } |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
53 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
54 # Defaults: |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
55 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
56 db=gemma |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
57 port=5432 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
58 demo=0 |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
59 geonames=0 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
60 drop=0 |
331
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
61 adminpw=`genpw 15` |
463
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
62 metapw=`genpw 15` |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
63 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
64 # Parse options: |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
65 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
66 OPTS=`getopt \ |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
67 -l help,demo,geonames,db:,port:,drop,adminpw:,metapw: \ |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
68 -o DGd:p: -n "$ME" -- "$@"` |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
69 [ $? -eq 0 ] || { usage ; exit 1 ; } |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
70 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
71 eval set -- "$OPTS" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
72 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
73 while true ; do |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
74 case "$1" in |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
75 --db|-d) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
76 db="$2" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
77 shift 2 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
78 ;; |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
79 --port|-p) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
80 port="$2" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
81 shift 2 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
82 ;; |
331
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
83 --adminpw) |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
84 adminpw="$2" |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
85 shift 2 |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
86 ;; |
463
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
87 --metapw) |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
88 metapw="$2" |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
89 shift 2 |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
90 ;; |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
91 --demo|-D) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
92 demo=1 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
93 shift 1 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
94 ;; |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
95 --geonames|-G) |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
96 geonames=1 |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
97 shift 1 |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
98 ;; |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
99 --drop) |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
100 drop=1 |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
101 shift 1 |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
102 ;; |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
103 --help) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
104 { usage ; exit 0 ; } |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
105 ;; |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
106 --) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
107 shift |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
108 break |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
109 ;; |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
110 esac |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
111 done |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
112 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
113 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
114 # Main ------------------------------------------------------------ |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
115 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
116 if [[ drop -eq 0 ]] ; then |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
117 # Default operation: create schema |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
118 createdb -p "$port" "$db" |
378
88aa790d1437
Do not assume existance of a specific database in setup
Tom Gottfried <tom@intevation.de>
parents:
377
diff
changeset
|
119 psql -q -p "$port" -f "$BASEDIR/roles.sql" -d "$db" |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
120 psql -qtv ON_ERROR_STOP= -p "$port" -d "$db" \ |
259
f1280801ba8c
db-setup script: Be even more quiet during creation.
Sascha Wilde <wilde@intevation.de>
parents:
256
diff
changeset
|
121 -c "SET client_min_messages TO WARNING;" \ |
569
ad07846b09d1
Add function to construct isrs from text
Tom Gottfried <tom@intevation.de>
parents:
478
diff
changeset
|
122 -f "$BASEDIR/isrs.sql" \ |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
123 -f "$BASEDIR/gemma.sql" \ |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
124 -f "$BASEDIR/search.sql" \ |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
125 -f "$BASEDIR/geonames.sql" \ |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
126 -f "$BASEDIR/manage_users.sql" \ |
833
d135274a4c92
Fixed db setup: default sys config is no demo data.
Sascha Wilde <wilde@intevation.de>
parents:
831
diff
changeset
|
127 -f "$BASEDIR/auth.sql" \ |
d135274a4c92
Fixed db setup: default sys config is no demo data.
Sascha Wilde <wilde@intevation.de>
parents:
831
diff
changeset
|
128 -f "$BASEDIR/default_sysconfig.sql" |
470
638371a0e557
Do not touch existing roles on database setup
Tom Gottfried <tom@intevation.de>
parents:
465
diff
changeset
|
129 |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
130 |
470
638371a0e557
Do not touch existing roles on database setup
Tom Gottfried <tom@intevation.de>
parents:
465
diff
changeset
|
131 # setup initial login roles with given passwords: |
1107
d1fb2babaa95
Avoid psql's usage of a pager
Tom Gottfried <tom@intevation.de>
parents:
833
diff
changeset
|
132 psql -qt -P pager=off -p "$port" -d "$db" \ |
478
3af7ca761f6a
Purge password reset role
Tom Gottfried <tom@intevation.de>
parents:
470
diff
changeset
|
133 -v adminpw="$adminpw" -v metapw="$metapw" \ |
330
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
134 -f "$BASEDIR/std_login_roles.sql" |
247
946baea3d280
Add view to list user profiles with role
Tom Gottfried <tom@intevation.de>
parents:
244
diff
changeset
|
135 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
136 if [[ $demo -eq 1 ]] ; then |
1110
ed8fbbc48440
Add demo-data for published OGC services
Tom Gottfried <tom@intevation.de>
parents:
1109
diff
changeset
|
137 psql -qv ON_ERROR_STOP= -p "$port" -d "$db" \ |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
138 -f "$BASEDIR/demo-data/responsibility_areas.sql" \ |
1110
ed8fbbc48440
Add demo-data for published OGC services
Tom Gottfried <tom@intevation.de>
parents:
1109
diff
changeset
|
139 -f "$BASEDIR/demo-data/users.sql" \ |
ed8fbbc48440
Add demo-data for published OGC services
Tom Gottfried <tom@intevation.de>
parents:
1109
diff
changeset
|
140 -f "$BASEDIR/demo-data/published_services.sql" |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
141 psql -q -p "$port" -f "$BASEDIR/demo-data/roles.sql" \ |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
142 -d "$db" |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
143 fi |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
144 |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
145 if [[ $geonames -eq 1 ]] ; then |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
146 "$BASEDIR/geonames-import/import-geonames.sh" -p "$port" -d "$db" |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
147 fi |
470
638371a0e557
Do not touch existing roles on database setup
Tom Gottfried <tom@intevation.de>
parents:
465
diff
changeset
|
148 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
149 else |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
150 # Evil mode: drop everything gemma |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
151 echo "Really drop database '$db' and all gemma roles? [type 'yes']: " |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
152 read a |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
153 if [[ $a == "yes" ]] ; then |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
154 dropdb -p "$port" "$db" |
436
8feb64128c34
Fixed install db script to cope with user roles containing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
378
diff
changeset
|
155 psql -p $port -A -t -c '\du' | awk -F '|' -v port=$port \ |
478
3af7ca761f6a
Purge password reset role
Tom Gottfried <tom@intevation.de>
parents:
470
diff
changeset
|
156 '$1 "." $3 ~ /waterway_user|waterway_admin|sys_admin|metamorph/ \ |
436
8feb64128c34
Fixed install db script to cope with user roles containing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
378
diff
changeset
|
157 { system("dropuser -p " port " \"" $1 "\"") }' |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
158 else |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
159 echo "No harm done." |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
160 fi |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
161 fi |