aboutsummaryrefslogtreecommitdiff
path: root/cli/setup-template.sh
blob: 49a432590b451b4c31055e8ea056c1d6adb8e255 (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
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
#!/bin/bash

# Such template sets an env up using the Python CLI.
# The setup goes until exchanging keys with the sandbox.

set -e

EBICS_HOST_ID=ebicshost
EBICS_PARTNER_ID=ebicspartner
EBICS_USER_ID=ebicsuser
EBICS_BASE_URL="$SANDBOX_URL/ebicsweb"

IBAN=x
BIC=y
PERSON_NAME=z
ACCOUNT_NAME=a

NEXUS_USER=u
NEXUS_PASSWORD=p
NEXUS_BANK_CONNECTION_NAME=b

if test -z $1; then
  echo usage: ./setup-template.sh PATH-TO-NEXUS-DB
  exit 1
fi

########## setup sandbox #############

# make ebics host at sandbox
echo Making a ebics host at the sandbox
sleep 2
./libeufin-cli \
  sandbox \
    make-ebics-host \
      --host-id=$EBICS_HOST_ID \
      $SANDBOX_URL

# activate a ebics subscriber on that host
echo Activating the ebics subscriber at the sandbox
sleep 2
./libeufin-cli \
  sandbox \
    activate-ebics-subscriber \
      --host-id=$EBICS_HOST_ID \
      --partner-id=$EBICS_PARTNER_ID \
      --user-id=$EBICS_USER_ID \
      $SANDBOX_URL

# give a bank account to such user
echo Giving a bank account to such subscriber
./libeufin-cli \
  sandbox \
    associate-bank-account \
      --iban=$IBAN \
      --bic=$BIC \
      --person-name=$PERSON_NAME \
      --account-name=$ACCOUNT_NAME \
      --ebics-user-id=$EBICS_USER_ID \
      --ebics-host-id=$EBICS_HOST_ID \
      --ebics-partner-id=$EBICS_PARTNER_ID \
      $SANDBOX_URL
sleep 2

########## setup nexus #############

# create a user
echo "Creating a nexus user (giving time to settle)"
nexus superuser --db-name $1 --password $NEXUS_PASSWORD $NEXUS_USER
sleep 2

# create a bank connection
echo Creating a bank connection for such user
./libeufin-cli \
  bank-connection \
    new-ebics-connection \
      --connection-name $NEXUS_BANK_CONNECTION_NAME \
      --ebics-url $EBICS_BASE_URL \
      --host-id $EBICS_HOST_ID \
      --partner-id $EBICS_PARTNER_ID \
      --ebics-user-id $EBICS_USER_ID \
      --nexus-user-id $NEXUS_USER \
      --nexus-password $NEXUS_PASSWORD \
      $NEXUS_URL
sleep 2

# Bootstrapping such connection
echo Bootstrapping the bank connection
./libeufin-cli \
  bank-connection \
    bootstrap-bank-connection \
      --connection-name $NEXUS_BANK_CONNECTION_NAME \
      --nexus-user-id $NEXUS_USER \
      --nexus-password $NEXUS_PASSWORD \
      $NEXUS_URL