summaryrefslogtreecommitdiff
path: root/regional-currency/list-incoming.sh
blob: 3ef7da7e7b8373ff7256c2aa7af033c77b2e9110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash

# This file is in the public domain.

# Script for basic diagnostics of a Taler regio deployment.
# @author Florian Dold <dold@taler.net>

if [ "$(id -u)" -ne 0 ]; then
  echo "FATAL: Please run as root." >&2
  exit 1
fi

libeufin_bank_db=$(libeufin-bank config get libeufin-bankdb-postgres config)
libeufin_nexus_db=$(libeufin-nexus config get libeufin-nexusdb-postgres config)
exchange_db=$(taler-config -s exchangedb-postgres -o config)

if [[ $libeufin_nexus_db != $libeufin_bank_db ]]; then
  echo "FATAL: libeufin-bank and libeufin-nexus don't share the same database" >&2
  exit 1
fi

libeufin_db=$libeufin_bank_db

# runsql db RESNAME < query
function runsql() {
  local sql
  read -r -d '' sql
  res=$(cd / && sudo -u postgres psql "$1" -t --csv -c "$sql")
  printf -v "$2" '%s' "$res"
}

#
# Check for conversion trigger
#

runsql "$exchange_db" reserves_in <<EOF
select reserve_pub from exchange.reserves_in;
EOF

echo $reserves_in