summaryrefslogtreecommitdiff
path: root/netzbon/setup-merchants.sh
blob: 7fa1d3bd59d8cadf1186c8c4126fb6cbbad5c1d9 (plain)
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
#!/bin/bash
# This script is in the public domain.
#
# You must export
#
# export BASE_URL=e.netzbon-basel.ch
# export MERCHANT_TOKEN=password
# export BANK_TOKEN=password
#
# before running this script!
#
# Call with the JSON file (like test.json) with
# an array of merchants to set up as the first argument!
#
# FIXME: nice error handling is non-existent...
#
set -eu
LENGTH=$(jq length < $1)
echo "Setting up $LENGTH merchants at ${BASE_URL}"

for n in $(seq 1 $LENGTH)
do
    echo "Processing merchant $n"
    INDEX=$(expr $n - 1 || true)
    NAME=$(jq ".[$INDEX].name" < $1)
    ID=$(jq .[$INDEX].id < $1)
    PW=$(jq .[$INDEX].pass < $1)

    taler-harness deployment provision-bank-and-merchant \
                  "merchant.${BASE_URL}" \
                  "bank.${BASE_URL}" \
                  "--merchant-management-token=${MERCHANT_TOKEN}" \
                  "--bank-admin-token=${BANK_ADMIN_TOKEN}" \
                  "--id=${ID}" \
                  "--legal-name=${NAME}" \
                  "--password=${PW}"

    echo "Done with ${ID}"
done