gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-deployment] 02/03: fund-rewards.sh script added to the --new fold


From: gnunet
Subject: [taler-deployment] 02/03: fund-rewards.sh script added to the --new folder: utils
Date: Fri, 15 Sep 2023 11:41:09 +0200

This is an automated email from the git hooks/post-receive script.

javier-sepulveda pushed a commit to branch master
in repository deployment.

commit 275d1ea9b3358efa76fe1588e9a60e72522dc874
Author: Javier Sepulveda <javier.sepulveda@uv.es>
AuthorDate: Fri Sep 15 11:29:29 2023 +0200

    fund-rewards.sh script added to the --new folder:  utils
---
 sandcastle/utils/fund-rewards.sh | 67 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/sandcastle/utils/fund-rewards.sh b/sandcastle/utils/fund-rewards.sh
new file mode 100755
index 0000000..cf09723
--- /dev/null
+++ b/sandcastle/utils/fund-rewards.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# This file is in the public domain.
+
+set -eu
+
+# Maybe add these to base Dockerfile as ENV?
+
+export LD_LIBRARY_PATH=/usr/local/lib
+export GNUNET_FORCE_LOG=";;;;WARNING"
+
+# Configuration variables - Please change to your needs
+
+DOMAIN="demo.taler.net"
+
+# Program variables - No need to be changed by the user.
+
+MERCHANT_URL="https://backend.${DOMAIN}/";
+MERCHANT_APIKEY=$(taler-config -c /config/deployment.conf -s taler-deployment 
-o merchant-apikey)
+BANK_ACCESS_URL="https://bank.${DOMAIN}/demobanks/default/access-api/";
+WIRE_METHOD="iban"
+AMOUNT="100" # Amount to add, on each new reserve (tiptopup option)
+BANK_ACCOUNT="survey-at-sandbox"
+BANK_PASSWORD="secret-at-sandbox"
+#BANK_PASSWORD=$(taler-config -c /config/deployment.conf -s taler-deployment 
-o db-password)
+EXCHANGE_URL=$(taler-config -c /config/deployment.conf -s taler-deployment -o 
default-exchange)
+EXCHANGE_URL="https://exchange.${DOMAIN}/";
+# shellcheck disable=SC2034
+CURRENCY=$(taler-config -c /config/deployment.conf -s taler-deployment -o 
currency)
+
+# Obtain current reserves in json format
+# Just one single call to the taler-harness program to avoid inconsistencies
+
+JSON=$(taler-harness deployment tip-status \
+       --merchant-url "$MERCHANT_URL" \
+       --merchant-apikey "$MERCHANT_APIKEY")
+
+# Calculate remaining funds
+
+ACTIVE_FUNDS=$(echo "$JSON" | jq '[.reserves[] | select(.active)]')
+TOTAL_EXCHANGE_INITIAL_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur 
"$CURRENCY" '[.[].exchange_initial_amount | sub($cur + ":"; "") | tonumber] | 
add')
+TOTAL_PICKUP_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur "$CURRENCY" 
'[.[].pickup_amount | sub($cur + ":"; "") | tonumber] | add')
+TOTAL_RESERVE_AMOUNT=$((TOTAL_EXCHANGE_INITIAL_AMOUNT - TOTAL_PICKUP_AMOUNT))
+
+# Decide whether add a new reserve, or leave it as is.
+
+if [ "$TOTAL_RESERVE_AMOUNT" -lt 100 ]; then
+       # Add new reserve amount  of 100 units
+       taler-harness deployment tip-topup \
+               --merchant-url "$MERCHANT_URL" \
+               --merchant-apikey="$MERCHANT_APIKEY" \
+               --bank-access-url "$BANK_ACCESS_URL" \
+               --wire-method="$WIRE_METHOD" \
+               --amount=KUDOS:"$AMOUNT" \
+               --bank-account="$BANK_ACCOUNT" \
+               --bank-password="$BANK_PASSWORD" \
+               --exchange-url "$EXCHANGE_URL"
+fi
+
+# If the json variable contains more than 100 records, wipe its content
+
+TOTAL_JSON_RECORDS=$(echo "$JSON" | jq '.[] | length')
+
+if [ "$TOTAL_JSON_RECORDS" -gt 100 ]; then
+       taler-harness deployment tip-cleanup --merchant-url "$BACKEND_URL"
+fi
+

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]