diff options
Diffstat (limited to 'netzbon/main.sh')
-rwxr-xr-x | netzbon/main.sh | 159 |
1 files changed, 80 insertions, 79 deletions
diff --git a/netzbon/main.sh b/netzbon/main.sh index f442e98..f88db95 100755 --- a/netzbon/main.sh +++ b/netzbon/main.sh @@ -2,109 +2,111 @@ # This file is in the public domain. # main.sh is the main script that asks the questions and -# puts the answers into environment variables located at "config/internal.conf,user.conf" files +# puts the answers into environment variables located at "config/taler-internal.conf or config/taler.conf" files # Nginx configuration - Reads values directly from these "config files". set -eu -# Include functions source file +# include functions source file source functions.sh -# CHECK if user is "root", otherwise EXIT. - -check_user - - -# INSTALLATION of Debian packages - -. install_debian_packages.sh - - -# Create folder and configuration files - +# include variables from configuration mkdir -p config/ - -if [ -f config/user.conf ] || [ -f config/internal.conf ]; then - cat /dev/null > config/user.conf - cat /dev/null > config/internal.conf -else - touch config/user.conf - touch config/internal.conf -fi - -# Include configuration files (user and internal) - +touch config/user.conf config/internal.conf +# Values supplied by user source config/user.conf +# Values we generated source config/internal.conf +# Ask questions to user # START USER INTERACTION - echo "TALER: Welcome to the GNU Taler Debian setup!" -# ASK questions - -ask "DOMAIN_NAME" -ask_tls "ENABLE_TLS" - -ask "CURRENCY" -ask "BANK_NAME" -ask "DO_OFFLINE" - -ask "MASTER_PUBLIC_KEY" "DO_OFFLINE" - -ask "SANDBOX_ADMIN_PASSWORD" -ask "SANDBOX_EXCHANGE_PASSWORD" - -ask "NEXUS_ADMIN_PASSWORD" -ask "NEXUS_EXCHANGE_PASSWORD" - - +if test -z "${CURRENCY:-}" +then + read -p "Enter the name of the currency (e.g. 'EUR'): " CURRENCY + # convert to all-caps + CURRENCY=`echo ${CURRENCY} | tr a-z A-Z` + echo "CURRENCY=${CURRENCY}" >> config/user.conf +fi +if test -z "${BANK_NAME:-}" +then + read -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 "${ENABLE_TLS:-}" +then + read -p "Use TLS? (y/n): " ENABLE_TLS + echo "ENABLE_TLS=${ENABLE_TLS}" >> config/user.conf +fi +if test -z "${DO_OFFLINE:-}" +then + read -p "Run taler-exchange-offline? (y/n): " DO_OFFLINE + echo "DO_OFFLINE=${DO_OFFLINE}" >> config/user.conf +fi +if test -z "${MASTER_PUBLIC_KEY:-}" +then + if test ${DO_OFFLINE:-y} == n + then + read -p "Enter the exchange-offline master public key: " MASTER_PUBLIC_KEY + echo "MASTER_PUBLIC_KEY=${MASTER_PUBLIC_KEY}" >> config/user.conf + fi +fi +if test -z "${SANDBOX_ADMIN_PASSWORD:-}" +then + read -s -p "Enter the admin password for the bank: " SANDBOX_ADMIN_PASSWORD + echo "SANDBOX_ADMIN_PASSWORD=${SANDBOX_ADMIN_PASSWORD}" >> config/user.conf + echo "" # force new line +fi +if test -z "${DOMAIN_NAME:-}" +then + read -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 # END USER INTERACTION +# Check DNS settings +ping -c1 exchange.${DOMAIN_NAME} &> /dev/null +if test 0 != $? +then + say "Could not ping exchange.${DOMAIN_NAME}." + say "Please make sure your DNS/network are working." + exit 1 +fi -# COPY values from variables -> to the configuration files. - -# user.conf - -# Please note "^^" means convert to uppercase -echo "CURRENCY=${CURRENCY^^}" >> config/user.conf -echo "BANK_NAME=\"${BANK_NAME}\"" >> config/user.conf -echo "ENABLE_TLS=${ENABLE_TLS}" >> config/user.conf -echo "DO_OFFLINE=${DO_OFFLINE}" >> config/user.conf -echo "MASTER_PUBLIC_KEY=${MASTER_PUBLIC_KEY}" >> config/user.conf -echo "SANDBOX_ADMIN_PASSWORD=${SANDBOX_ADMIN_PASSWORD}" >> config/user.conf - -# Please note ",," means convert to lowercase -echo "DOMAIN_NAME=${DOMAIN_NAME,,}" >> config/user.conf - -# internal.conf - -echo "NEXUS_EXCHANGE_PASSWORD=${NEXUS_EXCHANGE_PASSWORD}" >> config/internal.conf -echo "SANDBOX_EXCHANGE_PASSWORD=${SANDBOX_EXCHANGE_PASSWORD}" >> config/internal.conf - - -# CHECK DNS settings +# Check if the user is root, otherwise EXIT. +check_user -check_dns +# Installation of Debian packages required +. install_debian_packages.sh -# LIBEUFIN (bank) +if test -z "${NEXUS_EXCHANGE_PASSWORD:-}" +then + NEXUS_EXCHANGE_PASSWORD=`uuidgen` + echo "NEXUS_EXCHANGE_PASSWORD=${NEXUS_EXCHANGE_PASSWORD}" >> config/internal.conf +fi +if test -z "${SANDBOX_EXCHANGE_PASSWORD:-}" +then + SANDBOX_EXCHANGE_PASSWORD=`uuidgen` + echo "SANDBOX_EXCHANGE_PASSWORD=${SANDBOX_EXCHANGE_PASSWORD}" >> config/internal.conf +fi . config_launch_libeufin.sh - -# EXCHANGE - +. config_nginx.sh . setup-exchange.sh - -# MERCHANT - . setup-merchant.sh -# CONFIG NGINX - -. config_nginx.sh -# FINAL message to the user +# Final message to the user +if test ${ENABLE_TLS:-} == "y" +then + PROTO="https" +else + PROTO="http" +fi say "Congratulations, you have successfully installed GNU Taler" say "Your bank is at ${PROTO}://bank.${DOMAIN_NAME}/" @@ -112,5 +114,4 @@ say "A merchant is at ${PROTO}://backend.${DOMAIN_NAME}/" say "You should set credentials for the merchant soon." exit 0 - # END INSTALLATION |