summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-05-17 21:19:55 +0200
committerFlorian Dold <florian@dold.me>2023-05-17 21:19:55 +0200
commitadadd13f7b6fbf10b1842c2d5931dec4d7a25981 (patch)
tree88d798164b655f4f2a09ce72c02056b4de8d29db
parentb6f987f37ec777aecd0a7c221d100f2a3a50c03c (diff)
downloaddeployment-adadd13f7b6fbf10b1842c2d5931dec4d7a25981.tar.gz
deployment-adadd13f7b6fbf10b1842c2d5931dec4d7a25981.tar.bz2
deployment-adadd13f7b6fbf10b1842c2d5931dec4d7a25981.zip
refactor instance creation
-rw-r--r--sandcastle/images/libeufin/startup.sh10
-rw-r--r--sandcastle/images/merchant/create_instances.sh67
2 files changed, 53 insertions, 24 deletions
diff --git a/sandcastle/images/libeufin/startup.sh b/sandcastle/images/libeufin/startup.sh
index 26c3b4b..9480781 100644
--- a/sandcastle/images/libeufin/startup.sh
+++ b/sandcastle/images/libeufin/startup.sh
@@ -11,12 +11,12 @@ export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:${MAYBE_VOLUME_MOUNTPOINT}/nexu
# once. It helps against some non idempotent commands.
INIT_MARKER=${MAYBE_VOLUME_MOUNTPOINT}/init-done
export LD_LIBRARY_PATH=/usr/local/lib # helps taler-config
-CURRENCY=`taler-config -c /config/deployment.conf -s taler-deployment -o currency`
+CURRENCY=$(taler-config -c /config/deployment.conf -s taler-deployment -o currency)
SANDBOX_PORT=15000
NEXUS_PORT=15001
SANDBOX_BASE_URL="http://localhost:${SANDBOX_PORT}"
-EXCHANGE_URL=`taler-config -c /config/deployment.conf -s taler-deployment -o default-exchange`
-CAPTCHA_URL=`taler-config -c /config/deployment.conf -s taler-deployment -o bank-url`
+EXCHANGE_URL=$(taler-config -c /config/deployment.conf -s taler-deployment -o default-exchange)
+CAPTCHA_URL=$(taler-config -c /config/deployment.conf -s taler-deployment -o bank-url)
# As wanted by the Libeufin CLI:
export LIBEUFIN_SANDBOX_URL=${SANDBOX_BASE_URL}
export LIBEUFIN_NEXUS_URL="http://localhost:${NEXUS_PORT}"
@@ -52,6 +52,10 @@ is_serving() {
}
EXCHANGE_IBAN=DE159593
+BANK_SIGNUP_BONUS=$(taler-config -c /config/deployment.conf -s taler-deployment -o bank-signup-bonus)
+BANK_ALLOW_REGISTRATIONS=$(taler-config -c /config/deployment.conf -s taler-deployment -o bank-allow-registrations)
+
+
mkdir -p ${MAYBE_VOLUME_MOUNTPOINT}
export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=secret
echo -n "Creating ${CURRENCY} default demobank..."
diff --git a/sandcastle/images/merchant/create_instances.sh b/sandcastle/images/merchant/create_instances.sh
index 34a511c..80e1e75 100644
--- a/sandcastle/images/merchant/create_instances.sh
+++ b/sandcastle/images/merchant/create_instances.sh
@@ -1,22 +1,47 @@
-echo -n "Create default instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token","token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$DEFAULT_IBAN'?receiver-name=Merchant43"}],"id":"default","name":"GNU Taler","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
-echo -n "Create pos instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$POS_IBAN'?receiver-name=PoS"}],"id":"pos","name":"GNU Taler","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
-echo -n "Create blog instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$BLOG_IBAN'?receiver-name=BlogCompany"}],"id":"blog","name":"GNU Taler - Essay Shop","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
+function die() {
+ echo $1
+ exit 1
+}
+function create_instance() {
+ echo -n "Creating merchant backend instance $1 with IBAN $2..."
+ NAME=$1
+ IBAN=$2
+ RECV_NAME=$3
+ URI='payto://iban/SANDBOXX/'$IBAN'?receiver-name='$RECV_NAME
+ REQ="$(jq -n '
+ {
+ auth: { method: "token", "token": $TOKEN },
+ payto_uris: [$URI],
+ accounts: [{payto_uri: $URI}],
+ id: $NAME,
+ name: "GNU Taler",
+ address: {},
+ jurisdiction: {},
+ default_max_wire_fee: "\($CURRENCY):1",
+ default_max_deposit_fee: "\($CURRENCY):1",
+ default_wire_fee_amortization: 1,
+ default_wire_transfer_delay: {d_us: 1},
+ default_pay_delay: {d_us: 3600000000},
+ }' \
+ --arg URI "$URI" \
+ --arg TOKEN "$BACKEND_APIKEY" \
+ --arg CURRENCY "$CURRENCY" \
+ --arg NAME "$NAME"
+ )"
-echo -n "Create GNUnet instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$GNUNET_IBAN'?receiver-name=GNUnet"}],"id":"GNUnet","name":"GNU Taler - Donations","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
-echo -n "Create Taler instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$TALER_IBAN'?receiver-name=GNUnet"}],"id":"Taler","name":"GNU Taler","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
-echo -n "Create Tor instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$TOR_IBAN'?receiver-name=GNUnet"}],"id":"Tor","name":"GNU Taler","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
-echo -n "Create survey instance..."
-curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"accounts":[{"payto_uri":"payto://iban/SANDBOXX/'$SURVEY_IBAN'?receiver-name=GNUnet"}],"id":"survey","name":"GNU Taler","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
-echo DONE
+ curl --silent --show-error \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer $BACKEND_APIKEY" \
+ -X POST \
+ -d "$REQ" \
+ http://merchant/management/instances || die "instance creation failed"
+ echo DONE
+}
+
+create_instance default "$DEFAULT_IBAN" "Test Merchant"
+create_instance pos "$POS_IBAN" PoS
+create_instance blog "$BLOG_IBAN" BlogCompany
+create_instance GNUnet "$GNUNET_IBAN" GNUnet
+create_instance Taler "$TALER_IBAN" Taler
+create_instance Tor "$TOR_IBAN" Tor
+create_instance survey "$SURVET_IBAN" Survey