diff options
Diffstat (limited to 'regional-currency/functions.sh')
-rwxr-xr-x | regional-currency/functions.sh | 41 |
1 files changed, 27 insertions, 14 deletions
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 |