Mercurial > gemma
annotate schema/install-db.sh @ 3450:213b703bdd85
afdLNWL: CSV-Export
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 24 May 2019 12:51:12 +0200 |
parents | 5470aa3ffb9a |
children | 1fe3b378544a |
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 { |
2009
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
50 PW='' |
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
51 until [ "$(grep '[^[:alnum:]]' <<<$PW)" -a "$(grep '[[:digit:]]' <<<$PW)" ] |
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
52 do |
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
53 PW=$(dd count=1 if=/dev/urandom 2>/dev/null \ |
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
54 | tr -cd '[:alnum:],._!?-' | tail -c "$1") |
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
55 done |
ce294a8635a5
Ensure generated passwords contain a non-alphanumeric character and digit
Tom Gottfried <tom@intevation.de>
parents:
1833
diff
changeset
|
56 echo "$PW" |
330
fd04bccae6ca
Create standard roles as part of the base schema.
Sascha Wilde <wilde@intevation.de>
parents:
319
diff
changeset
|
57 } |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
58 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
59 # Defaults: |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
60 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
61 db=gemma |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
62 port=5432 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
63 demo=0 |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
64 geonames=0 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
65 drop=0 |
331
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
66 adminpw=`genpw 15` |
463
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
67 metapw=`genpw 15` |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
68 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
69 # Parse options: |
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 OPTS=`getopt \ |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
72 -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
|
73 -o DGd:p: -n "$ME" -- "$@"` |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
74 [ $? -eq 0 ] || { usage ; exit 1 ; } |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
75 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
76 eval set -- "$OPTS" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
77 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
78 while true ; do |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
79 case "$1" in |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
80 --db|-d) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
81 db="$2" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
82 shift 2 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
83 ;; |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
84 --port|-p) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
85 port="$2" |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
86 shift 2 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
87 ;; |
331
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
88 --adminpw) |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
89 adminpw="$2" |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
90 shift 2 |
a85f56207d80
db-setup script: Allow to set passwords manually.
Sascha Wilde <wilde@intevation.de>
parents:
330
diff
changeset
|
91 ;; |
463
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
92 --metapw) |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
93 metapw="$2" |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
94 shift 2 |
5611cf72cc92
Add metamorphic database role and user e.g. for GeoServer
Tom Gottfried <tom@intevation.de>
parents:
436
diff
changeset
|
95 ;; |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
96 --demo|-D) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
97 demo=1 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
98 shift 1 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
99 ;; |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
100 --geonames|-G) |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
101 geonames=1 |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
102 shift 1 |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
103 ;; |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
104 --drop) |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
105 drop=1 |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
106 shift 1 |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
107 ;; |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
108 --help) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
109 { usage ; exit 0 ; } |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
110 ;; |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
111 --) |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
112 shift |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
113 break |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
114 ;; |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
115 esac |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
116 done |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
117 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
118 |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
119 # Main ------------------------------------------------------------ |
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
120 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
121 if [[ drop -eq 0 ]] ; then |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
122 # Default operation: create schema |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
123 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
|
124 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
|
125 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
|
126 -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
|
127 -f "$BASEDIR/isrs.sql" \ |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
128 -f "$BASEDIR/gemma.sql" \ |
1832
661597546ed9
Move not only authentication related functions to own file
Tom Gottfried <tom@intevation.de>
parents:
1629
diff
changeset
|
129 -f "$BASEDIR/geo_functions.sql" \ |
1833
b9c59050014a
Make search functions self-replacing and indicate that in filename
Tom Gottfried <tom@intevation.de>
parents:
1832
diff
changeset
|
130 -f "$BASEDIR/search_functions.sql" \ |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
131 -f "$BASEDIR/geonames.sql" \ |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
132 -f "$BASEDIR/manage_users.sql" \ |
3024
5470aa3ffb9a
Fix privileges for GeoServer views
Tom Gottfried <tom@intevation.de>
parents:
3008
diff
changeset
|
133 -f "$BASEDIR/geoserver_views.sql" \ |
833
d135274a4c92
Fixed db setup: default sys config is no demo data.
Sascha Wilde <wilde@intevation.de>
parents:
831
diff
changeset
|
134 -f "$BASEDIR/auth.sql" \ |
1629
9d51f022b8ee
Introduce SQL function to clip an area to a stretch
Tom Gottfried <tom@intevation.de>
parents:
1339
diff
changeset
|
135 -f "$BASEDIR/isrs_functions.sql" \ |
833
d135274a4c92
Fixed db setup: default sys config is no demo data.
Sascha Wilde <wilde@intevation.de>
parents:
831
diff
changeset
|
136 -f "$BASEDIR/default_sysconfig.sql" |
470
638371a0e557
Do not touch existing roles on database setup
Tom Gottfried <tom@intevation.de>
parents:
465
diff
changeset
|
137 |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
138 |
470
638371a0e557
Do not touch existing roles on database setup
Tom Gottfried <tom@intevation.de>
parents:
465
diff
changeset
|
139 # 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
|
140 psql -qt -P pager=off -p "$port" -d "$db" \ |
478
3af7ca761f6a
Purge password reset role
Tom Gottfried <tom@intevation.de>
parents:
470
diff
changeset
|
141 -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
|
142 -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
|
143 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
144 if [[ $demo -eq 1 ]] ; then |
1110
ed8fbbc48440
Add demo-data for published OGC services
Tom Gottfried <tom@intevation.de>
parents:
1109
diff
changeset
|
145 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
|
146 -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
|
147 -f "$BASEDIR/demo-data/users.sql" \ |
ed8fbbc48440
Add demo-data for published OGC services
Tom Gottfried <tom@intevation.de>
parents:
1109
diff
changeset
|
148 -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
|
149 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
|
150 -d "$db" |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
151 fi |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
152 |
1109
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
153 if [[ $geonames -eq 1 ]] ; then |
74a75a5ce770
Added geonames data and extended search for villages/cities.
Sascha Wilde <wilde@intevation.de>
parents:
1107
diff
changeset
|
154 "$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
|
155 fi |
470
638371a0e557
Do not touch existing roles on database setup
Tom Gottfried <tom@intevation.de>
parents:
465
diff
changeset
|
156 |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
157 else |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
158 # Evil mode: drop everything gemma |
377
220a893318fa
Ignore only role creation errors in database setup
Tom Gottfried <tom@intevation.de>
parents:
331
diff
changeset
|
159 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
|
160 read a |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
161 if [[ $a == "yes" ]] ; then |
2679
a3cab473304d
Drop roles even if database does not exist
Tom Gottfried <tom@intevation.de>
parents:
2009
diff
changeset
|
162 dropdb --if-exists -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
|
163 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
|
164 '$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
|
165 { system("dropuser -p " port " \"" $1 "\"") }' |
255
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
166 else |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
167 echo "No harm done." |
c36bd39782c1
Added simple --drop to db setup script.
Sascha Wilde <wilde@intevation.de>
parents:
252
diff
changeset
|
168 fi |
244
4ebb791b8278
Added simple script to install db schema.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
169 fi |