anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

setup.sh (2141B)


      1 #!/bin/sh
      2 # This file is in the public domain
      3 
      4 # Script to be inlined into the main test scripts. Defines function 'setup()'
      5 # which wraps around 'taler-unified-setup.sh' to launch GNU Taler services.
      6 # Call setup() with the arguments to pass to 'taler-unified-setup'. setup()
      7 # will then launch GNU Taler, wait for the process to be complete before
      8 # returning. The script will also install an exit handler to ensure the GNU
      9 # Taler processes are stopped when the shell exits.
     10 
     11 set -eu
     12 
     13 # Cleanup to run whenever we exit
     14 function exit_cleanup()
     15 {
     16     if [ ! -z ${SETUP_PID+x} ]
     17     then
     18         echo "Killing taler-unified-setup ($SETUP_PID)" >&2
     19         kill -TERM "$SETUP_PID" 2> /dev/null || true
     20         wait "$SETUP_PID" 2> /dev/null || true
     21     fi
     22 }
     23 
     24 # Install cleanup handler (except for kill -9)
     25 trap exit_cleanup EXIT
     26 
     27 function setup()
     28 {
     29     echo "Starting test system ..." >&2
     30     # Create a named pipe in a temp directory we own.
     31     FIFO_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d fifo-XXXXXX)
     32     FIFO_OUT=$(echo "$FIFO_DIR/out")
     33     mkfifo "$FIFO_OUT"
     34     # Open pipe as FD 3 (RW) and FD 4 (RO)
     35     exec 3<> "$FIFO_OUT" 4< "$FIFO_OUT"
     36     rm -rf "$FIFO_DIR"
     37     # We require '-W' for our termination logic to work.
     38     taler-unified-setup.sh -W "$@" >&3 &
     39     SETUP_PID=$!
     40     # Close FD3
     41     exec 3>&-
     42     sed -u '/<<READY>>/ q' <&4
     43     # Close FD4
     44     exec 4>&-
     45     echo "Test system ready" >&2
     46 }
     47 
     48 # Exit, with status code "skip" (no 'real' failure)
     49 function exit_fail() {
     50     echo "$@" >&2
     51     exit 1
     52 }
     53 
     54 # Exit, with status code "skip" (no 'real' failure)
     55 function exit_skip() {
     56     echo "SKIPPING: $1"
     57     exit 77
     58 }
     59 
     60 function get_payto_uri() {
     61     export LIBEUFIN_SANDBOX_USERNAME="$1"
     62     export LIBEUFIN_SANDBOX_PASSWORD="$2"
     63     export LIBEUFIN_SANDBOX_URL="http://localhost:18082"
     64     libeufin-cli sandbox demobank info --bank-account "$1" | jq --raw-output '.paytoUri'
     65 }
     66 
     67 function get_bankaccount_transactions() {
     68     export LIBEUFIN_SANDBOX_USERNAME=$1
     69     export LIBEUFIN_SANDBOX_PASSWORD=$2
     70     export LIBEUFIN_SANDBOX_URL="http://localhost:18082"
     71     libeufin-cli sandbox demobank list-transactions --bank-account $1
     72 }