-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathstart-devenv.sh
executable file
·453 lines (379 loc) · 13.4 KB
/
start-devenv.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
#!/usr/bin/env bash
# This script allows one to manage the individual services that are needed
# to run a completely local NL Wallet development environment.
#
# - nl-rdo-max (digid-connector)
# - mock_relying_party
# - verification_server
# - pid_issuer
# - wallet_provider
# - wallet
set -e # break on error
set -u # warn against undefined variables
set -o pipefail
# set -x # echo statements before executing, useful while debugging
########################################################################
# Globals and includes
########################################################################
SCRIPTS_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
BASE_DIR=$(dirname "${SCRIPTS_DIR}")
DOCKER_COMPOSE_FILE=${SCRIPTS_DIR}/docker-compose.yml
source "${SCRIPTS_DIR}/utils.sh"
source "${SCRIPTS_DIR}/configuration.sh"
########################################################################
# Functions
########################################################################
# Echo help information about this script
function usage() {
echo -e "$(basename "${BASH_SOURCE[0]}"): Manage the Wallet Development environment
Usage: $(basename "${BASH_SOURCE[0]}") [OPTIONS] <SERVICES>
Starts or restarts the services that are part of the development environment.
Where:
SERVICE is any of:
wallet: Start the wallet Flutter application.
This requires a simulator to be running.
wp, wallet_provider: Start the wallet_provider.
This requires a PostgreSQL database to be running, which can be provided by the
'docker' service.
vs, verification_server: Start the verification_server.
pi, pid_issuer: Start the pid_issuer.
mrp, mock_relying_party: Start the mock_relying_party.
digid, digid_connector: Start the digid_connector and a redis on docker.
cs, configuration_server: Start the configuration server
brp: Start the Haal-Centraal BRP proxy with GBA HC converter.
brpproxy: Start the Haal-Centraal BRP proxy.
gba, gba_hc_converter: Start the GBA HC converter.
postgres: Start a PostgreSQL database, using Docker.
OPTION is any of:
--all Start all of the above services.
--default Start all of the above services, excluding postgres and wallet.
This option is provided when a PostgreSQL database is run and managed by the user.
--stop Combine with --all, --default or specific service name(s) to stop said services.
-h, --help Show this help
"
}
########################################################################
# Check prerequisites
########################################################################
have cargo docker flutter
########################################################################
# Commandline arguments
########################################################################
MOCK_RELYING_PARTY=1
WALLET_PROVIDER=1
VERIFICATION_SERVER=1
PID_ISSUER=1
WALLET=1
DIGID_CONNECTOR=1
CONFIG_SERVER=1
BRP_PROXY=1
GBA_HC=1
POSTGRES=1
USAGE=1
STOP=0
START=0
if [ "$#" == "0" ]
then
USAGE=0
fi
while [[ $# -gt 0 ]]
do
case $1 in
wallet)
WALLET=0
shift # past argument
;;
wp|wallet_provider)
WALLET_PROVIDER=0
shift # past argument
;;
vs|verification_server)
VERIFICATION_SERVER=0
shift # past argument
;;
pi|pid_issuer)
PID_ISSUER=0
shift # past argument
;;
mrp|mock_relying_party)
MOCK_RELYING_PARTY=0
shift # past argument
;;
digid|digid_connector)
DIGID_CONNECTOR=0
shift # past argument
;;
cs|configuration_server)
CONFIG_SERVER=0
shift
;;
brp)
BRP_PROXY=0
GBA_HC=0
shift
;;
brpproxy)
BRP_PROXY=0
shift
;;
gba|gba_hc_converter)
GBA_HC=0
shift
;;
postgres)
POSTGRES=0
shift # past argument
;;
--default)
DIGID_CONNECTOR=0
MOCK_RELYING_PARTY=0
VERIFICATION_SERVER=0
PID_ISSUER=0
WALLET_PROVIDER=0
CONFIG_SERVER=0
BRP_PROXY=0
GBA_HC=0
shift # past argument
;;
--all)
DIGID_CONNECTOR=0
POSTGRES=0
MOCK_RELYING_PARTY=0
VERIFICATION_SERVER=0
PID_ISSUER=0
WALLET_PROVIDER=0
WALLET=0
CONFIG_SERVER=0
BRP_PROXY=0
GBA_HC=0
shift # past argument
;;
-h|--help)
USAGE=0
shift # past argument
;;
--stop)
START=1
shift # past argument
;;
*)
error "Unknown argument: $1"
shift # past argument
usage
exit 1
;;
esac
done
if [ "${USAGE}" == "0" ]
then
usage
exit 0
fi
########################################################################
# Manage digid-connector
########################################################################
if [ "${DIGID_CONNECTOR}" == "0" ]
then
echo
echo -e "${SECTION}Manage digid-connector${NC}"
cd "${DIGID_CONNECTOR_PATH}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Stopping ${ORANGE}digid-connector${NC}"
docker compose down || true
fi
if [ "${START}" == "0" ]
then
echo -e "Building and starting ${ORANGE}digid-connector${NC}"
docker compose up --detach --build --force-recreate
fi
fi
########################################################################
# Manage postgres
########################################################################
if [ "${POSTGRES}" == "0" ]
then
echo
echo -e "${SECTION}Manage postgres services${NC}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Stopping postgres services${NC}"
docker compose --file "${DOCKER_COMPOSE_FILE}" down postgres || true
fi
if [ "${START}" == "0" ]
then
echo -e "${INFO}Starting postgres services${NC}"
docker compose --file "${DOCKER_COMPOSE_FILE}" up --detach postgres
fi
fi
########################################################################
# Manage mock_relying_party
########################################################################
if [ "${MOCK_RELYING_PARTY}" == "0" ]
then
echo
echo -e "${SECTION}Manage mock_relying_party${NC}"
cd "${MOCK_RELYING_PARTY_DIR}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Kill any running ${ORANGE}mock_relying_party${NC}"
killall mock_relying_party || true
fi
if [ "${START}" == "0" ]
then
echo -e "${INFO}Start ${ORANGE}mock_relying_party${NC}"
RUST_LOG=debug cargo run --features "allow_insecure_url" --bin mock_relying_party > "${TARGET_DIR}/mock_relying_party.log" 2>&1 &
echo -e "mock_relying_party logs can be found at ${CYAN}${TARGET_DIR}/mock_relying_party.log${NC}"
fi
fi
########################################################################
# Manage pid_issuer
########################################################################
if [ "${PID_ISSUER}" == "0" ]
then
echo
echo -e "${SECTION}Manage pid_issuer${NC}"
cd "${WALLET_SERVER_DIR}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Kill any running ${ORANGE}pid_issuer${NC}"
killall pid_issuer || true
fi
if [ "${START}" == "0" ]
then
pushd "${WALLET_CORE_DIR}"
echo -e "${INFO}Running pid_issuer database migrations${NC}"
DATABASE_URL="postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:5432/pid_issuer" cargo run --bin wallet_server_migrations -- fresh
popd
echo -e "${INFO}Start ${ORANGE}pid_issuer${NC}"
RUST_LOG=debug cargo run --no-default-features --features "issuance,postgres" --bin pid_issuer > "${TARGET_DIR}/pid_issuer.log" 2>&1 &
echo -e "pid_issuer logs can be found at ${CYAN}${TARGET_DIR}/pid_issuer.log${NC}"
fi
fi
########################################################################
# Manage verification_server
########################################################################
if [ "${VERIFICATION_SERVER}" == "0" ]
then
# As part of the MRP a verification_server is started
echo
echo -e "${SECTION}Manage verification_server${NC}"
cd "${WALLET_SERVER_DIR}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Kill any running ${ORANGE}verification_server${NC}"
killall verification_server || true
fi
if [ "${START}" == "0" ]
then
pushd "${WALLET_CORE_DIR}"
echo -e "${INFO}Running verification_server database migrations${NC}"
DATABASE_URL="postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:5432/verification_server" cargo run --bin wallet_server_migrations -- fresh
popd
echo -e "${INFO}Start ${ORANGE}verification_server${NC}"
RUST_LOG=debug cargo run --no-default-features --features "allow_insecure_url,disclosure,postgres" --bin verification_server > "${TARGET_DIR}/mrp_verification_server.log" 2>&1 &
echo -e "verification_server logs can be found at ${CYAN}${TARGET_DIR}/mrp_verification_server.log${NC}"
fi
fi
########################################################################
# Manage wallet_provider
########################################################################
if [ "${WALLET_PROVIDER}" == "0" ]
then
echo
echo -e "${SECTION}Manage wallet_provider${NC}"
cd "${WP_DIR}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Kill any running ${ORANGE}wallet_provider${NC}"
killall wallet_provider || true
fi
if [ "${START}" == "0" ]
then
echo -e "${INFO}Running wallet_provider database migrations${NC}"
pushd "${WALLET_CORE_DIR}"
cargo run --bin wallet_provider_migrations -- fresh
popd
echo -e "${INFO}Start ${ORANGE}wallet_provider${NC}"
RUST_LOG=debug cargo run --bin wallet_provider > "${TARGET_DIR}/wallet_provider.log" 2>&1 &
echo -e "wallet_provider logs can be found at ${CYAN}${TARGET_DIR}/wallet_provider.log${NC}"
fi
fi
########################################################################
# Manage configuration_server
########################################################################
if [ "${CONFIG_SERVER}" == "0" ]
then
echo
echo -e "${SECTION}Manage configuration_server${NC}"
cd "${CS_DIR}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Kill any running ${ORANGE}configuration_server${NC}"
killall configuration_server || true
fi
if [ "${START}" == "0" ]
then
echo -e "${INFO}Start ${ORANGE}configuration_server${NC}"
RUST_LOG=debug cargo run --bin configuration_server > "${TARGET_DIR}/configuration_server.log" 2>&1 &
echo -e "configuration_server logs can be found at ${CYAN}${TARGET_DIR}/configuration_server.log${NC}"
fi
fi
########################################################################
# Manage brpproxy
########################################################################
if [ "${BRP_PROXY}" == "0" ]
then
echo
echo -e "${SECTION}Manage brpproxy${NC}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Stopping ${ORANGE}brpproxy${NC}"
docker compose --file "${DOCKER_COMPOSE_FILE}" down brpproxy || true
fi
if [ "${START}" == "0" ]
then
echo -e "Building and starting ${ORANGE}brpproxy${NC}"
docker compose --file "${DOCKER_COMPOSE_FILE}" up --detach brpproxy
fi
fi
########################################################################
# Manage gba_hc_converter
########################################################################
if [ "${GBA_HC}" == "0" ]
then
echo
echo -e "${SECTION}Manage gba_hc_converter${NC}"
cd "${GBA_HC_CONVERTER_DIR}"
if [ "${STOP}" == "0" ]
then
echo -e "${INFO}Stopping ${ORANGE}gba_hc_converter${NC}"
killall gba_hc_converter || true
fi
if [ "${START}" == "0" ]
then
echo -e "Starting ${ORANGE}gba_hc_converter${NC}"
encrypt_gba_v_responses
RUST_LOG=debug cargo run --bin gba_hc_converter > "${TARGET_DIR}/gba_hc_converter.log" 2>&1 &
echo -e "gba_hc_converter logs can be found at ${CYAN}${TARGET_DIR}/gba_hc_converter.log${NC}"
fi
fi
########################################################################
# Manage wallet
########################################################################
if [ "${WALLET}" == "0" ]
then
echo
echo -e "${SECTION}Manage wallet${NC}"
if [ "${START}" == "0" ]
then
cd "${BASE_DIR}"/wallet_app
flutter run \
--dart-define MOCK_REPOSITORIES=false \
--dart-define ALLOW_INSECURE_URL=true \
--dart-define ENV_CONFIGURATION=true \
--dart-define UL_HOSTNAME="${UL_HOSTNAME:-}" \
--dart-define SENTRY_DSN="${SENTRY_DSN:-}" \
--dart-define SENTRY_ENVIRONMENT="${SENTRY_ENVIRONMENT}"
fi
fi