commit de205bf2fe0a8c2ffa5c69832c1a610e16755d15
parent 4dbe7abbdc39f48c5a482ca1e32e41039a4c48e6
Author: Antoine A <>
Date: Fri, 9 Feb 2024 15:35:40 +0100
Fix libeufin setup
Diffstat:
5 files changed, 130 insertions(+), 161 deletions(-)
diff --git a/regional-currency/config_libeufin.sh b/regional-currency/config_libeufin.sh
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-set -eu
-
-libeufin-dbconfig
-./config_libeufin_nexus.sh
-./config_libeufin_bank.sh
diff --git a/regional-currency/config_libeufin_bank.sh b/regional-currency/config_libeufin_bank.sh
@@ -1,130 +0,0 @@
-#!/bin/bash
-# This file is in the public domain.
-#
-# This script configure and launches libeufin-bank.
-# The setup provides the admin account at the bank, and
-# another account for the exchange at the bank.
-#
-# The environment must provide the following variables:
-# - BANK_ADMIN_PASSWORD: password of the Netzbon administrator.
-# - BANK_EXCHANGE_PASSWORD: password of the exchange
-# bank account hosted at Sandbox. The related
-# username is: exchange-at-sandbox
-# - BANK_NAME: human-readable name for the bank
-# - DOMAIN_NAME: DNS domain name to use for the setup
-# - ENABLE_TLS (http or https?)
-#
-# OUTPUTS:
-#
-# EXCHANGE_PAYTO -- payto-URI of the exchange
-# EXCHANGE_WIRE_GATEWAY_URL -- URL of the wire gateway for the exchange
-
-set -eu
-
-source functions.sh
-source config/user.conf
-source config/internal.conf
-
-if test -z "${BANK_NAME:-}"; then
- say "Error: config/user.conf does not specify BANK_NAME"
- exit 1
-fi
-if test -z "${DOMAIN_NAME:-}"; then
- say "Error: config/user.conf does not specify DOMAIN_NAME"
- exit 1
-fi
-if test -z "${BANK_ADMIN_PASSWORD:-}"; then
- say "Error: config/user.conf does not specify BANK_ADMIN_PASSWORD"
- exit 1
-fi
-if test -z "${BANK_EXCHANGE_PASSWORD:-}"; then
- say "Error: config/user.conf does not specify BANK_EXCHANGE_PASSWORD"
- exit 1
-fi
-
-say "Configure the bank with ${CURRENCY}..."
-
-cat <<EOF > /etc/libeufin/libeufin-bank.conf
-[libeufin-bank]
-CURRENCY=${CURRENCY}
-WIRE_TYPE = x-taler-bank
-X_TALER_BANK_PAYTO_HOSTNAME = ${PROTO}://bank.${DOMAIN_NAME}
-DEFAULT_EXCHANGE=${PROTO}://exchange.${DOMAIN_NAME}
-SERVE=tcp
-PORT=${BANK_PORT}
-ALLOW_CONVERSION=yes
-FIAT_CURRENCY=${FIAT_CURRENCY}
-TAN_SMS=libeufin-tan-sms.sh
-TAN_EMAIL=libeufin-tan-email.sh
-ALLOW_EDIT_CASHOUT_PAYTO_URI=yes
-
-[CURRENCY-NETZBON]
-enabled=yes
-name=NetzBon
-code=NETZBON
-fractional_input_digits=2
-fractional_normal_digits=2
-fractional_trailing_zero_digits=2
-alt_unit_names={"0":"NETZBON"}
-
-EOF
-
-# FIXME: include this in the bank _and_ make sure it gets loaded
-
-say "Setting up libeufin-bank admin account..."
-sudo -u libeufin-bank \
- libeufin-bank passwd \
- -c /etc/libeufin/libeufin-bank.conf \
- admin "${BANK_ADMIN_PASSWORD}"
-
-say "Setting up admin's debt limit..."
-sudo -u libeufin-bank \
- libeufin-bank edit-account \
- -c /etc/libeufin/libeufin-bank.conf \
- admin --debit_threshold=${CURRENCY}:200000000
-
-say "Setting up SPA configuration..."
-echo "settings = { bankName: \"${BANK_NAME}\" }" >/etc/libeufin/settings.js
-
-say "Create exchange account..."
-if test -z "${EXCHANGE_PAYTO:-}"; then
- EXCHANGE_PAYTO_NEW="$(sudo -u libeufin-bank libeufin-bank create-account -c /etc/libeufin/libeufin-bank.conf --username exchange --password "${BANK_EXCHANGE_PASSWORD}" --name Exchange --exchange)?receiver-name=Exchange"
- echo "EXCHANGE_PAYTO=\"${EXCHANGE_PAYTO_NEW}\"" >> config/internal.conf
-fi
-
-if test -z "${EXCHANGE_WIRE_GATEWAY_URL:-}"; then
- EXCHANGE_WIRE_GATEWAY_URL_NEW="${PROTO}://bank.$DOMAIN_NAME/accounts/exchange/taler-wire-gateway/"
- echo "EXCHANGE_WIRE_GATEWAY_URL=\"${EXCHANGE_WIRE_GATEWAY_URL_NEW}\"" >> config/internal.conf
-fi
-
-say "Start the bank..."
-systemctl enable --now libeufin-bank
-
-say "Waiting for the bank (/config)..."
-curl --max-time 2 \
- --retry-all-errors \
- --retry-delay 4 \
- --retry 10 \
- ${PROTO}://bank.${DOMAIN_NAME}/config
-say "DONE"
-
-say "Setting conversion figures..."
-
-curl -u "admin:${BANK_ADMIN_PASSWORD}" \
- -H 'Content-Type: application/json; charset=utf-8' \
- ${PROTO}://bank.${DOMAIN_NAME}/conversion-info/conversion-rate \
---data-binary @- << EOF
-{
- "cashin_ratio": "1",
- "cashin_fee": "${CURRENCY}:0",
- "cashin_tiny_amount": "${CURRENCY}:2",
- "cashin_rounding_mode": "nearest",
- "cashin_min_amount": "${FIAT_CURRENCY}:1",
- "cashout_ratio": "1",
- "cashout_fee": "${FIAT_CURRENCY}:0",
- "cashout_tiny_amount": "${FIAT_CURRENCY}:2",
- "cashout_rounding_mode": "zero",
- "cashout_min_amount": "${CURRENCY}:1"
-}
-EOF
-say "DONE"
diff --git a/regional-currency/config_libeufin_nexus.sh b/regional-currency/config_libeufin_nexus.sh
@@ -1,23 +0,0 @@
-#!/bin/bash
-# This file is in the public domain.
-#
-# This script configure and launches libeufin-bank.
-# The setup provides the admin account at the bank, and
-# another account for the exchange at the bank.
-#
-# The environment must provide the following variables:
-set -eu
-
-source functions.sh
-source config/user.conf
-
-taler-config -s nexus-ebics -o currency \
- -V $FIAT_CURRENCY -c /etc/libeufin/libeufin-nexus.conf
-
-# Note: this seems dangerious: the user has had
-# no chance to actually configure conversion yet!
-# Let's keep this off!
-#
-# say "Start nexus tasks..."
-# systemctl enable --now libeufin-nexus-ebics-fetch
-# systemctl enable --now libeufin-nexus-ebics-submit
diff --git a/regional-currency/functions.sh b/regional-currency/functions.sh
@@ -81,7 +81,7 @@ function detect_distro() {
function config_services() {
./config_nginx.sh
- ./config_libeufin.sh
+ ./setup-libeufin.sh
./setup-exchange.sh
./setup-merchant.sh
}
diff --git a/regional-currency/setup-libeufin.sh b/regional-currency/setup-libeufin.sh
@@ -0,0 +1,128 @@
+#!/bin/bash
+# This file is in the public domain.
+#
+# This script configure libeufin-bank and libeufin-nexus.
+
+
+set -eu
+
+source functions.sh
+source config/user.conf
+source config/internal.conf
+
+say "Beginning LibEuFin setup"
+
+if test -z "${BANK_NAME:-}"; then
+ say "Error: config/user.conf does not specify BANK_NAME"
+ exit 1
+fi
+if test -z "${DOMAIN_NAME:-}"; then
+ say "Error: config/user.conf does not specify DOMAIN_NAME"
+ exit 1
+fi
+if test -z "${BANK_ADMIN_PASSWORD:-}"; then
+ say "Error: config/user.conf does not specify BANK_ADMIN_PASSWORD"
+ exit 1
+fi
+if test -z "${BANK_EXCHANGE_PASSWORD:-}"; then
+ say "Error: config/user.conf does not specify BANK_EXCHANGE_PASSWORD"
+ exit 1
+fi
+
+say "Configure libeufin-nexus with ${FIAT_CURRENCY}..."
+
+taler-config -s nexus-ebics -o currency \
+ -V $FIAT_CURRENCY -c /etc/libeufin/libeufin-nexus.conf
+
+say "Configure libeufin-bank with ${CURRENCY}..."
+
+cat <<EOF > /etc/libeufin/libeufin-bank.conf
+[libeufin-bank]
+CURRENCY=${CURRENCY}
+WIRE_TYPE = x-taler-bank
+X_TALER_BANK_PAYTO_HOSTNAME = ${PROTO}://bank.${DOMAIN_NAME}
+DEFAULT_EXCHANGE=${PROTO}://exchange.${DOMAIN_NAME}
+SERVE=tcp
+PORT=${BANK_PORT}
+ALLOW_CONVERSION=yes
+FIAT_CURRENCY=${FIAT_CURRENCY}
+TAN_SMS=libeufin-tan-sms.sh
+TAN_EMAIL=libeufin-tan-email.sh
+ALLOW_EDIT_CASHOUT_PAYTO_URI=yes
+
+[CURRENCY-NETZBON]
+enabled=yes
+name=NetzBon
+code=NETZBON
+fractional_input_digits=2
+fractional_normal_digits=2
+fractional_trailing_zero_digits=2
+alt_unit_names={"0":"NETZBON"}
+
+EOF
+
+say "Setting up libeufin database..."
+
+libeufin-dbconfig
+
+say "Setting up libeufin-bank..."
+
+
+say "Setting up libeufin-bank admin account..."
+sudo -u libeufin-bank \
+ libeufin-bank passwd \
+ -c /etc/libeufin/libeufin-bank.conf \
+ admin "${BANK_ADMIN_PASSWORD}"
+
+say "Setting up admin's debt limit..."
+sudo -u libeufin-bank \
+ libeufin-bank edit-account \
+ -c /etc/libeufin/libeufin-bank.conf \
+ admin --debit_threshold=${CURRENCY}:200000000
+
+say "Setting up SPA configuration..."
+echo "settings = { bankName: \"${BANK_NAME}\" }" >/etc/libeufin/settings.js
+
+say "Create exchange account..."
+if test -z "${EXCHANGE_PAYTO:-}"; then
+ EXCHANGE_PAYTO_NEW="$(sudo -u libeufin-bank libeufin-bank create-account -c /etc/libeufin/libeufin-bank.conf --username exchange --password "${BANK_EXCHANGE_PASSWORD}" --name Exchange --exchange)?receiver-name=Exchange"
+ echo "EXCHANGE_PAYTO=\"${EXCHANGE_PAYTO_NEW}\"" >> config/internal.conf
+fi
+
+if test -z "${EXCHANGE_WIRE_GATEWAY_URL:-}"; then
+ EXCHANGE_WIRE_GATEWAY_URL_NEW="${PROTO}://bank.$DOMAIN_NAME/accounts/exchange/taler-wire-gateway/"
+ echo "EXCHANGE_WIRE_GATEWAY_URL=\"${EXCHANGE_WIRE_GATEWAY_URL_NEW}\"" >> config/internal.conf
+fi
+
+say "Start the bank..."
+systemctl enable --now libeufin-bank
+
+say "Waiting for the bank (/config)..."
+curl --max-time 2 \
+ --retry-all-errors \
+ --retry-delay 4 \
+ --retry 10 \
+ ${PROTO}://bank.${DOMAIN_NAME}/config
+say "DONE"
+
+say "Setting conversion figures..."
+curl -u "admin:${BANK_ADMIN_PASSWORD}" \
+ -H 'Content-Type: application/json; charset=utf-8' \
+ ${PROTO}://bank.${DOMAIN_NAME}/conversion-info/conversion-rate \
+--data-binary @- << EOF
+{
+ "cashin_ratio": "1",
+ "cashin_fee": "${CURRENCY}:0",
+ "cashin_tiny_amount": "${CURRENCY}:2",
+ "cashin_rounding_mode": "nearest",
+ "cashin_min_amount": "${FIAT_CURRENCY}:1",
+ "cashout_ratio": "1",
+ "cashout_fee": "${FIAT_CURRENCY}:0",
+ "cashout_tiny_amount": "${FIAT_CURRENCY}:2",
+ "cashout_rounding_mode": "zero",
+ "cashout_min_amount": "${CURRENCY}:1"
+}
+EOF
+say "DONE"
+
+say "LibEuFin setup finished"
+\ No newline at end of file