commit 7aeccdebcf27eba4a347c55beff8438fa7bcaf05
parent 4543e8562f1e6cb4a49a5557126658ee4840576c
Author: Antoine A <>
Date: Thu, 5 Dec 2024 17:03:37 +0100
regio: clean logs and variables checks
Diffstat:
3 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/regional-currency/functions.sh b/regional-currency/functions.sh
@@ -34,3 +34,13 @@ function detect_distro() {
echo "Unsupported distro, should be either ubuntu or debian" >&2
return 1
}
+
+# Fails if some required variables are not set
+function expect_vars() {
+ for VAR_NAME in "$@"; do
+ if test -z "${!VAR_NAME:-}"; then
+ say "Error: ${VAR_NAME} not set"
+ exit 1
+ fi
+ done
+}
+\ No newline at end of file
diff --git a/regional-currency/setup-exchange.sh b/regional-currency/setup-exchange.sh
@@ -5,10 +5,9 @@
#
# The environment must provide the following variables:
#
-# - BANK_EXCHANGE_PASSWORD (exchange password for libeufin-bank)
-# - EXCHANGE_WIRE_GATEWAY_URL (where is the exchange wire gateway / libeufin-nexus)
+# - BANK_EXCHANGE_TOKEN (exchange token for libeufin-bank)
# - EXCHANGE_PAYTO (exchange account PAYTO)
-# - ENABLE_TLS (http or https?)
+# - PROTO (http or https?)
# - DOMAIN_NAME: DNS domain name to use for the setup
#
@@ -38,14 +37,7 @@ EXCHANGE_DB="taler-exchange"
say "Beginning Exchange setup"
-if test -z "${BANK_EXCHANGE_PASSWORD:-}"; then
- say "Failure: BANK_EXCHANGE_PASSWORD not set"
- exit 1
-fi
-if test -z "${EXCHANGE_PAYTO:-}"; then
- say "Failure: EXCHANGE_PAYTO not set"
- exit 1
-fi
+expect_vars BANK_EXCHANGE_TOKEN EXCHANGE_PAYTO PROTO DOMAIN_NAME
function die() {
say "$1"
@@ -187,12 +179,14 @@ curl -sS --max-time 2 \
--retry-all-errors \
--retry-delay 2 \
--retry 10 \
+ --fail \
"${EXCHANGE_BASE_URL}"config &>> setup.log
say "Waiting for exchange management keys (this may take a while)..."
curl -sS --max-time 30 \
--retry-delay 2 \
--retry 60 \
+ --fail \
"${EXCHANGE_BASE_URL}"management/keys &>> setup.log
if test ${DO_OFFLINE} == y; then
diff --git a/regional-currency/setup-libeufin.sh b/regional-currency/setup-libeufin.sh
@@ -12,22 +12,7 @@ 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
+expect_vars BANK_NAME DOMAIN_NAME BANK_ADMIN_PASSWORD BANK_EXCHANGE_PASSWORD
if test ${DO_CONVERSION} == y; then
say "Configuring libeufin-nexus with ${FIAT_CURRENCY}..."
@@ -113,6 +98,7 @@ curl -sS --max-time 2 \
--retry-all-errors \
--retry-delay 2 \
--retry 10 \
+ --fail \
${PROTO}://bank.${DOMAIN_NAME}/config &>> setup.log
if test ${DO_CONVERSION} == y; then