diff options
author | Antoine A <> | 2024-02-14 17:13:26 +0100 |
---|---|---|
committer | Antoine A <> | 2024-02-14 17:13:26 +0100 |
commit | 27a15d3c52388a34199f262e2757a47f7bf425f8 (patch) | |
tree | ff3cf8e314e05e40bc4383bddfed6e86de7626be | |
parent | 111add82aae5fec79d6f5f7356d6ae6eda17db56 (diff) | |
download | deployment-27a15d3c52388a34199f262e2757a47f7bf425f8.tar.gz deployment-27a15d3c52388a34199f262e2757a47f7bf425f8.tar.bz2 deployment-27a15d3c52388a34199f262e2757a47f7bf425f8.zip |
Hide excessive logging in a setup.log file and add a missing package
-rw-r--r-- | regional-currency/.gitignore | 3 | ||||
-rwxr-xr-x | regional-currency/functions.sh | 41 | ||||
-rwxr-xr-x | regional-currency/install_packages.sh | 15 | ||||
-rwxr-xr-x | regional-currency/main.sh | 64 | ||||
-rwxr-xr-x | regional-currency/setup-exchange.sh | 22 | ||||
-rwxr-xr-x | regional-currency/setup-libeufin.sh | 20 | ||||
-rwxr-xr-x | regional-currency/setup-merchant.sh | 4 |
7 files changed, 94 insertions, 75 deletions
diff --git a/regional-currency/.gitignore b/regional-currency/.gitignore index 4492389..26790f8 100644 --- a/regional-currency/.gitignore +++ b/regional-currency/.gitignore @@ -1,3 +1,2 @@ -nexus.log -sandbox.log config/ +setup.log
\ No newline at end of file diff --git a/regional-currency/functions.sh b/regional-currency/functions.sh index 7f4640b..af217e7 100755 --- a/regional-currency/functions.sh +++ b/regional-currency/functions.sh @@ -1,7 +1,16 @@ #!/bin/bash +notify_err() { + say "errexit on line $(caller)" + say "Error messages can be found at the end of setup.log" + exit 1 +} + +trap notify_err ERR + # Message function say() { + echo "TALER: " "$@" >> setup.log echo "TALER: " "$@" } @@ -40,6 +49,13 @@ function ask_questions() { read -r -p "Enter the human-readable name of the bank (e.g. 'Taler Bank'): " BANK_NAME echo "BANK_NAME=\"${BANK_NAME}\"" >>config/user.conf fi + if test -z "${DOMAIN_NAME:-}"; then + read -r -p "Enter the domain name: " DOMAIN_NAME + # convert to lower-case + DOMAIN_NAME=$(echo "${DOMAIN_NAME}" | tr A-Z a-z) + check_dns + echo "DOMAIN_NAME=${DOMAIN_NAME}" >>config/user.conf + fi if test -z "${ENABLE_TLS:-}"; then read -r -p "Use TLS? (y/n): " ENABLE_TLS echo "ENABLE_TLS=${ENABLE_TLS}" >>config/user.conf @@ -59,12 +75,16 @@ function ask_questions() { echo "BANK_ADMIN_PASSWORD=$(printf '%q' "${BANK_ADMIN_PASSWORD}")" >>config/user.conf echo "" # force new line fi - if test -z "${DOMAIN_NAME:-}"; then - read -r -p "Enter the domain name: " DOMAIN_NAME - # convert to lower-case - DOMAIN_NAME=$(echo "${DOMAIN_NAME}" | tr A-Z a-z) - echo "DOMAIN_NAME=${DOMAIN_NAME}" >>config/user.conf - fi +} + +function check_dns() { + for prefix in "exchange" "bank" "backend"; do + if ! ping -c1 "${prefix}.${DOMAIN_NAME}" &>>setup.log; then + say "Could not ping ${prefix}.${DOMAIN_NAME}." + say "Please make sure your DNS/network are working." + exit 1 + fi + done } # Set DISTRO to the detected distro or return non-zero @@ -77,11 +97,4 @@ function detect_distro() { uname -a | grep Debian >/dev/null && DISTRO=debian && return 0 echo "Unsupported distro, should be either ubuntu or debian" >&2 return 1 -} - -function config_services() { - ./config_nginx.sh - ./setup-libeufin.sh - ./setup-exchange.sh - ./setup-merchant.sh -} +}
\ No newline at end of file diff --git a/regional-currency/install_packages.sh b/regional-currency/install_packages.sh index 6d5519e..0ef5031 100755 --- a/regional-currency/install_packages.sh +++ b/regional-currency/install_packages.sh @@ -12,9 +12,11 @@ detect_distro # Program versions PG_VERSION=15 +say "Installing necessary packages (this may take a while)..." + ## Update -apt update +apt update &>> setup.log ## General requirements @@ -28,7 +30,7 @@ apt install uuid-runtime \ postgresql-client-${PG_VERSION} \ dbconfig-pgsql \ certbot \ - python3-certbot-nginx -y + python3-certbot-nginx -y &>> setup.log ## Add GNU Taler deb.taler.net to /etc/apt/sources.list @@ -48,14 +50,17 @@ ubuntu) ;; esac -wget -P /etc/apt/keyrings https://taler.net/taler-systems.gpg +wget -P /etc/apt/keyrings https://taler.net/taler-systems.gpg &>> setup.log ## Specific GNU Taler packages -apt update +say "Installing GNU Taler packages (this may take a while)..." + +apt update &>> setup.log apt install taler-exchange \ taler-merchant \ taler-harness \ taler-wallet-cli \ + taler-exchange-offline \ libeufin-bank \ - libeufin-nexus -y + libeufin-nexus -y &>> setup.log
\ No newline at end of file diff --git a/regional-currency/main.sh b/regional-currency/main.sh index 7e7f68d..5492de7 100755 --- a/regional-currency/main.sh +++ b/regional-currency/main.sh @@ -11,6 +11,10 @@ set -eu source functions.sh +# Clear logs + +> setup.log + # include variables from configuration mkdir -p config/ touch config/user.conf config/internal.conf @@ -21,10 +25,12 @@ source config/internal.conf # Ask questions to user # START USER INTERACTION -say "Welcome to the GNU Taler Debian setup!" +say "Welcome to the GNU Taler regional currency setup!" say "" say "All configuration values asked during the setup script" -say "can be changed in config/user.conf" +say "can be changed in config/user.conf." +say "Logs are written in setup.log." +say "" ask_questions @@ -34,19 +40,11 @@ ask_questions check_user # Installation of deb packages required +say "" +say "Installing packages (step 1 of 5)" . install_packages.sh -# Check DNS settings -if ! ping -c1 "exchange.${DOMAIN_NAME}" &>/dev/null; then - say "Could not ping exchange.${DOMAIN_NAME}." - say "Please make sure your DNS/network are working." - exit 1 -fi -if ! ping -c1 "bank.${DOMAIN_NAME}" &>/dev/null; then - say "Could not ping bank.${DOMAIN_NAME}." - say "Please make sure your DNS/network are working." - exit 1 -fi +check_dns if test -z "${BANK_EXCHANGE_PASSWORD:-}"; then BANK_EXCHANGE_PASSWORD=$(uuidgen) @@ -57,23 +55,35 @@ if test -z "${BANK_PORT:-}"; then echo "BANK_PORT=8080" >>config/user.conf fi -if test -z "${PROTO:-}"; then - if test "${ENABLE_TLS:-}" == "y"; then - PROTO="https" - else - PROTO="http" - fi - echo "PROTO=$PROTO">>config/internal.conf +if test "${ENABLE_TLS:-}" == "y"; then + export PROTO="https" +else + export PROTO="http" fi # FIXME: remove once the merchant .deb gets updated -rm /usr/bin/taler-merchant-dbconfig -wget -P /usr/bin/ https://git.taler.net/merchant.git/plain/contrib/taler-merchant-dbconfig -chmod a+x /usr/bin/taler-merchant-dbconfig +rm /usr/bin/taler-merchant-dbconfig +wget -P /usr/bin/ https://git.taler.net/merchant.git/plain/contrib/taler-merchant-dbconfig &>> setup.log +chmod a+x /usr/bin/taler-merchant-dbconfig &>> setup.log + +say "" +say "Configuring nginx (step 2 of 5)" +./config_nginx.sh + +say "" +say "Setting up libeufin (step 3 of 5)" +./setup-libeufin.sh -config_services +say "" +say "Setting up exchange (step 4 of 5)" +./setup-exchange.sh + +say "" +say "Setting up merchant (step 5 of 5)" +./setup-merchant.sh # Final message to the user +say "" say "Congratulations, you have successfully installed GNU Taler" say "Your bank is at ${PROTO}://bank.${DOMAIN_NAME}/" say "A merchant is at ${PROTO}://backend.${DOMAIN_NAME}/" @@ -82,10 +92,8 @@ say "For the SMS cash-out TAN, make sure that telesign-secret" say "is found in the PATH and that it defines the CUSTOMER_ID" say "and API_KEY environment variables." -say "If you want a setup with currency conversion, you" -say "should first complete the EBICS setup," -say "then configure currency conversion and" -say "finally start the libeufin-nexus services." +say "For currency conversion to work, you must manually complete" +say "the EBICS configuration." exit 0 # END INSTALLATION diff --git a/regional-currency/setup-exchange.sh b/regional-currency/setup-exchange.sh index 6e84f5e..103cb90 100755 --- a/regional-currency/setup-exchange.sh +++ b/regional-currency/setup-exchange.sh @@ -178,8 +178,7 @@ done # NOTE: already fixed in exchange.git, leaving in place # until 0.9.4 release of fixed exchange Debian package. -CG say "Initializing exchange database" -taler-exchange-dbconfig -c /etc/taler/taler.conf || true # FIXME-CG: no exit 77 if DB exist -# NOTE: latest exchange.git dbconfig no longer exits with 77, should remove || true with 0.9.4 exchange release. +taler-exchange-dbconfig -c /etc/taler/taler.conf &>> setup.log say "Launching exchange" systemctl enable --now taler-exchange.target @@ -187,17 +186,15 @@ systemctl enable --now taler-exchange.target say "Waiting for exchange HTTP service (/config)..." curl --max-time 2 \ --retry-all-errors \ - --retry-delay 1 \ + --retry-delay 2 \ --retry 10 \ - "${EXCHANGE_BASE_URL}"config &>/dev/null -say "DONE" + "${EXCHANGE_BASE_URL}"config &>> setup.log say "Waiting for exchange management keys (this may take a while)..." curl --max-time 30 \ - --retry-delay 1 \ + --retry-delay 4 \ --retry 60 \ - "${EXCHANGE_BASE_URL}"management/keys &>/dev/null -say "DONE" + "${EXCHANGE_BASE_URL}"management/keys &>> setup.log if test ${DO_OFFLINE} == y; then say "Offline interaction..." @@ -207,22 +204,21 @@ if test ${DO_OFFLINE} == y; then -c /etc/taler/taler.conf \ download \ sign \ - upload + upload &>> setup.log sudo -i -u taler-exchange-offline \ taler-exchange-offline \ enable-account "${EXCHANGE_PAYTO}" \ wire-fee now iban "${CURRENCY}":0 "${CURRENCY}":0 \ global-fee now "${CURRENCY}":0 "${CURRENCY}":0 "${CURRENCY}":0 1h 6a 0 \ - upload + upload &>> setup.log fi say "Waiting for exchange /keys..." curl --max-time 2 \ --retry-connrefused \ - --retry-delay 1 \ + --retry-delay 2 \ --retry 10 \ - "${EXCHANGE_BASE_URL}"keys &>/dev/null -say "DONE" + "${EXCHANGE_BASE_URL}"keys &>> setup.log say "Exchange setup finished" diff --git a/regional-currency/setup-libeufin.sh b/regional-currency/setup-libeufin.sh index 26dc03b..aea4121 100755 --- a/regional-currency/setup-libeufin.sh +++ b/regional-currency/setup-libeufin.sh @@ -29,12 +29,12 @@ if test -z "${BANK_EXCHANGE_PASSWORD:-}"; then exit 1 fi -say "Configure libeufin-nexus with ${FIAT_CURRENCY}..." +say "Configuring 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}..." +say "Configuring libeufin-bank with ${CURRENCY}..." cat <<EOF > /etc/libeufin/libeufin-bank.conf [libeufin-bank] @@ -63,7 +63,7 @@ EOF say "Setting up libeufin database..." -libeufin-dbconfig +libeufin-dbconfig &>> setup.log say "Setting up libeufin-bank..." @@ -72,20 +72,20 @@ say "Setting up libeufin-bank admin account..." sudo -u libeufin-bank \ libeufin-bank passwd \ -c /etc/libeufin/libeufin-bank.conf \ - admin "${BANK_ADMIN_PASSWORD}" + admin "${BANK_ADMIN_PASSWORD}" &>> setup.log 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 + admin --debit_threshold=${CURRENCY}:200000000 &>> setup.log 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" + 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" 2>> setup.log echo "EXCHANGE_PAYTO=\"${EXCHANGE_PAYTO_NEW}\"" >> config/internal.conf fi @@ -100,16 +100,15 @@ systemctl enable --now libeufin-bank say "Waiting for the bank (/config)..." curl --max-time 2 \ --retry-all-errors \ - --retry-delay 4 \ + --retry-delay 2 \ --retry 10 \ - ${PROTO}://bank.${DOMAIN_NAME}/config -say "DONE" + ${PROTO}://bank.${DOMAIN_NAME}/config &>> setup.log 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 +--data-binary @- &>> setup.log << EOF { "cashin_ratio": "1", "cashin_fee": "${CURRENCY}:0", @@ -123,6 +122,5 @@ curl -u "admin:${BANK_ADMIN_PASSWORD}" \ "cashout_min_amount": "${CURRENCY}:1" } EOF -say "DONE" say "LibEuFin setup finished"
\ No newline at end of file diff --git a/regional-currency/setup-merchant.sh b/regional-currency/setup-merchant.sh index 917e653..7c857b2 100755 --- a/regional-currency/setup-merchant.sh +++ b/regional-currency/setup-merchant.sh @@ -7,7 +7,7 @@ source config/user.conf source config/internal.conf say "Setting up merchant database" -taler-merchant-dbconfig +taler-merchant-dbconfig &>> setup.log say "Launching taler-merchant-httpd" -systemctl enable --now taler-merchant-httpd +systemctl enable --now taler-merchant-httpd &>> setup.log |