#!/bin/bash # Message # ----------------------------------- function say() { echo "TALER: " "$@" } # Check user if the user is root # ----------------------------------- function check_user() { if [ $(whoami) != "root" ]; then say "Please run this script as root" exit 1 fi } # Asks several questions to the user # ----------------------------------- function ask() { # DOMAIN_NAME if [ $1 == "DOMAIN_NAME" ]; then read -p "Enter the domain name: " DOMAIN_NAME fi # ENABLE_TLS if [ $1 == "ENABLE_TLS" ]; then read -p "Use TLS? (y/n): " ENABLE_TLS fi # CURRENCY if [ $1 == "CURRENCY" ]; then read -p "Enter the name of the currency (e.g. 'EUR'):" CURRENCY fi # BANK_NAME if [ $1 == "BANK_NAME" ]; then read -p "Enter the human-readable name of the bank (e.g. 'Taler Bank'): " BANK_NAME fi # DO_OFFLINE if [ $1 == "DO_OFFLINE" ]; then read -p "Run taler-exchange offline? (y/n): " DO_OFFLINE fi # MASTER_PUBLIC_KEY if [ $1 == "MASTER_PUBLIC_KEY" ]; then if [ $2 == "DO_OFFLINE" ] && [ $DO_OFFLINE == 'n' ]; then read -p "Enter the exchange-offline master public key: " MASTER_PUBLIC_KEY fi fi # SANDBOX_ADMIN_PASSWORD if [ $1 == "SANDBOX_ADMIN_PASSWORD" ]; then read -s -p "Enter the admin password for the bank: " SANDBOX_ADMIN_PASSWORD echo "" # force new line fi # SANDBOX_EXCHANGE_PASSWORD if [ $1 == "SANDBOX_EXCHANGE_PASSWORD" ]; then SANDBOX_EXCHANGE_PASSWORD=`uuidgen` fi # NEXUS_EXCHANGE_PASSWORD if [ $1 == "NEXUS_EXCHANGE_PASSWORD" ]; then NEXUS_EXCHANGE_PASSWORD=`uuidgen` fi } function check_nexus_exchange () { if test -z ${LIBEUFIN_NEXUS_USERNAME:-} then say "Failure: LIBEUFIN_NEXUS_USERNAME not set" exit 1 fi if test -z ${NEXUS_EXCHANGE_PASSWORD:-} then say "Failure: NEXUS_EXCHANGE_PASSWORD not set" exit 1 fi if test -z ${EXCHANGE_IBAN:-} then say "Failure: EXCHANGE_IBAN not set" exit 1 fi if test -z ${EXCHANGE_PAYTO:-} then say "Failure: EXCHANGE_PAYTO not set" exit 1 fi } # Ask about whether use TLS or not # ----------------------------------- function ask_tls() { read -p "Use TLS? (y/n): " ENABLE_TLS if test ${ENABLE_TLS} == "y" then PROTO="https" else PROTO="http" fi } # Check network # ----------------------------------- check_dns() { ping -c1 exchange.${DOMAIN_NAME} # &> /dev/null if test 0 != $? then say "Could not ping TO exchange.${DOMAIN_NAME}." say "Please make sure your DNS/network are working." exit 1 fi }