-
Notifications
You must be signed in to change notification settings - Fork 24
/
init_qwat.sh
executable file
·312 lines (268 loc) · 15.7 KB
/
init_qwat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#!/usr/bin/env bash
# ##########
#
# QWAT initialization script
# 10.07.2015
# Denis Rouzaud
#
# ##########
GNUGETOPT="getopt"
if [[ "$OSTYPE" =~ FreeBSD* ]] || [[ "$OSTYPE" =~ darwin* ]]; then
GNUGETOPT="/usr/local/bin/getopt"
elif [[ "$OSTYPE" =~ openbsd* ]]; then
GNUGETOPT="gnugetopt"
fi
# Exit on error
set -e
usage() {
cat <<EOF
Usage: $0 [options]
-p| --pgservice PG service to connect to the database.
-s|--srid PostGIS SRID. Default to 21781 (ch1903)
-d|--drop-schema drop schemas (cascaded) if they exist
--demo load some demo data (not complete yet)
-r|--create-roles create roles in the database
-v|--verbose be verbose
-n|--no-baseline If this param is given, then the 1.0.0 baseline is applied instead of current version
EOF
}
ARGS=$(${GNUGETOPT} -o p:s:drvn -l "pgservice:,srid:,drop-schema,create-roles,verbose,demo,no-baseline" -- "$@");
if [ $? -ne 0 ];
then
usage
exit 1
fi
eval set -- "$ARGS";
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Default values
SRID=21781
DROPSCHEMA=0
CREATEROLES=0
VERBOSE=0
DEMO=0
NOBASELINE=0
NUMVERSION=$(cat $DIR/system/CURRENT_VERSION.txt)
while true; do
case "$1" in
-p|--pgservice)
shift;
if [ -n "$1" ]; then
PGSERVICE=$1
shift;
fi
;;
-s|--srid)
shift;
if [ -n "$1" ]; then
SRID=$1
shift;
fi
;;
--demo)
DEMO=1
shift;
;;
-d|--drop-schema)
DROPSCHEMA=1
shift;
;;
-r|--create-roles)
CREATEROLES=1
shift;
;;
-v|--verbose)
VERBOSE=1
shift;
;;
-n|--no-baseline)
NOBASELINE=1
shift;
;;
--)
shift;
break;
;;
esac
done
# Check if pum is installed (will fail and stop the script in case of error)
PUM_VERSION=$(pum -v)
echo "PUM version: $PUM_VERSION"
echo
if [[ -z "$PGSERVICE" ]]; then
echo "No PG service given."
usage
exit 0
fi
# config pgsql
if [[ "$VERBOSE" -eq 0 ]]; then
export PGOPTIONS='--client-min-messages=warning'
fi
# Drop schema
if [[ "$DROPSCHEMA" -eq 1 ]]; then
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "BEGIN; \
DROP SCHEMA IF EXISTS qwat_dr CASCADE; \
DROP SCHEMA IF EXISTS qwat_od CASCADE; \
DROP SCHEMA IF EXISTS qwat_sys CASCADE; \
DROP SCHEMA IF EXISTS qwat_vl CASCADE; \
COMMIT;"
fi
# Create extensions
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE EXTENSION IF NOT EXISTS hstore;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c 'CREATE EXTENSION IF NOT EXISTS "pgcrypto";'
# System
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE SCHEMA qwat_sys;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/settings.sql
# psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/versions.sql
# psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/versions_insert.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/system/settings_insert.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/audit.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/fn_enable_schemavisible.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/fn_label.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/upgrades_table.sql
echo "Starting qwat_vl insertion..."
# Value lists
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE SCHEMA qwat_vl;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/value_list_base.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_object_reference.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_bedding.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_cistern.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_cover_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_document_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_hydrant_model.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_hydrant_material.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_hydrant_output.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_hydrant_provider.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_leak_cause.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_leak_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_locationtype.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_nominal_diameter.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_overflow.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_part_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pipe_function.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pipe_installmethod.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pipe_material.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pipe_protection.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_precisionalti.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_precision.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pressurecontrol_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_protectionzone_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pump_operating.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_pump_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_remote.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_source_quality.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_source_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_status.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_subscriber_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_survey_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_tank_firestorage.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_valve_actuation.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_valve_function.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_valve_maintenance.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_valve_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_visible.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_watertype.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/value_lists/vl_worker_type.sql
echo "Starting qwat_dr insertion..."
# Drawings
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE SCHEMA qwat_dr;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/drawing/annotationline.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/drawing/annotationpoint.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/drawing/constructionpoint.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/drawing/dimension_distance.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/drawing/dimension_orientation.sql
echo "Starting qwat_od insertion..."
# Ordinary data
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE SCHEMA qwat_od;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/ft_geom3d_altitude.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/ft_alternative_geom.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/worker/od_worker.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_consumptionzone.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_distributor.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_pressurezone.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_district.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_folder.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_printmap.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/areas/od_protectionzone.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/document/document.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_get_district.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_get_printmap.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_pressurezone.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/nodes/od_node.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/nodes/od_network_element.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_node_create.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_node_get_id.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_node_set_type.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_node_set_distributors.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_node_set_status.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_node_update_id.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_element_part_set_orientation.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/hydrant/od_hydrant.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/pipe/od_pipe.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/pipe/od_pipe_geom.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/pipe/od_crossing.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_pipe_get_id.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_update_pipe_crossing.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/nodes/od_part.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/valve/od_valve.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/valve/od_meter.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/valve/od_meter_reference.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/subscriber/od_subscriber.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/subscriber/od_subscriber_reference.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_base.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_cover.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_chamber.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_pressurecontrol.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_pump.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_source.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_tank.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_installation_treatment.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/installation/od_remote.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/samplingpoint/od_samplingpoint.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/surveypoint/od_surveypoint.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/leak/od_leak.sql
echo "Starting tr_valve_pipe fn_valve_set_orientation..."
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/functions/fn_valve_set_orientation.sql
echo "Starting tr_valve_pipe insertion..."
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -v SRID=$SRID -f ${DIR}/ordinary_data/valve/tr_valve_pipe.sql
echo "Starting view creation..."
PGSERVICE=${PGSERVICE} SRID=$SRID ${DIR}/ordinary_data/views/insert_views.sh
# Network
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "CREATE SCHEMA IF NOT EXISTS qwat_network;"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/pipe_reference.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_pipe_.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_all_pipes.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/vw_pipe_reference.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_element_valve_status.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_create_network.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_search_path.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "SELECT qwat_network.ft_all_pipes();"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -c "SELECT qwat_network.ft_create_network()"
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_network_cutoff.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_check_node_is_hydrant.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_check_node_is_closed_valve.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_check_node_is_valve.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_check_valve_is_network.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_search_opened_valves.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_check_valve_is_subscriber.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_search_network_and_subscribers.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/network/functions/ft_check_valve_is_active.sql
# Finalize System
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/audit_tables.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/audit_views.sql
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/system/update_sequences.sql
# Baseline PUM
if [[ "$NOBASELINE" -eq 1 ]]; then
NUMVERSION="1.0.0"
fi
pum baseline -p $PGSERVICE -t qwat_sys.info -d ${DIR}/update/delta -b $NUMVERSION
# Demo data
if [[ "$DEMO" -eq 1 ]]; then
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/demo/minimal.sql
fi
# Create roles
if [[ "$CREATEROLES" -eq 1 ]]; then
psql service=${PGSERVICE} -v ON_ERROR_STOP=1 -f ${DIR}/roles.sql
fi
echo " *** QWAT was successfully initialized! ***"
exit 0