setup-merchants.sh (1170B)
1 #!/bin/bash 2 # This script is in the public domain. 3 # 4 # You must export 5 # 6 # export BASE_DOMAIN=e.netzbon-basel.ch 7 # export MERCHANT_TOKEN='secret-token:...' 8 # export BANK_ADMIN_PASSWORD='password' 9 # 10 # before running this script! 11 # 12 # Call with the JSON file (like test.json) with 13 # an array of merchants to set up as the first argument! 14 # 15 # FIXME: nice error handling is non-existent... 16 # 17 [ -z "$1" ] && echo missing json file && exit 1 18 19 set -eu 20 LENGTH=$(jq length < $1) 21 echo "Setting up $LENGTH merchants at ${BASE_DOMAIN}" 22 23 for n in $(seq 1 $LENGTH) 24 do 25 echo "Processing merchant $n" 26 INDEX=$(expr $n - 1 || true) 27 NAME=$(jq ".[$INDEX].name" < $1) 28 ID=$(jq -r .[$INDEX].id < $1) 29 PW=$(jq -r .[$INDEX].pass < $1) 30 taler-harness deployment provision-bank-and-merchant \ 31 "https://backend.${BASE_DOMAIN}" \ 32 "https://bank.${BASE_DOMAIN}" \ 33 "--merchant-management-token=${MERCHANT_TOKEN}" \ 34 "--bank-admin-password=${BANK_ADMIN_PASSWORD}" \ 35 "--id=${ID}" \ 36 "--legal-name=${NAME}" \ 37 "--password=${PW}" 38 39 echo "Done with ${ID}" 40 done