setup.sh (1986B)
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 unset XDG_DATA_HOME 14 unset XDG_CONFIG_HOME 15 16 17 # Cleanup to run whenever we exit 18 function exit_cleanup() 19 { 20 if [ ! -z ${SETUP_PID+x} ] 21 then 22 echo "Killing taler-unified-setup ($SETUP_PID)" >&2 23 kill -TERM "$SETUP_PID" 2> /dev/null || true 24 wait "$SETUP_PID" 2> /dev/null || true 25 fi 26 } 27 28 # Install cleanup handler (except for kill -9) 29 trap exit_cleanup EXIT 30 31 function setup() 32 { 33 echo "Starting test system ..." >&2 34 # Create a named pipe in a temp directory we own. 35 FIFO_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d fifo-XXXXXX) 36 FIFO_OUT=$(echo "$FIFO_DIR/out") 37 mkfifo "$FIFO_OUT" 38 # Open pipe as FD 3 (RW) and FD 4 (RO) 39 exec 3<> "$FIFO_OUT" 4< "$FIFO_OUT" 40 rm -rf "$FIFO_DIR" 41 # We require '-W' for our termination logic to work. 42 taler-unified-setup.sh -W "$@" >&3 & 43 SETUP_PID=$! 44 # Close FD3 45 exec 3>&- 46 sed -u '/<<READY>>/ q' <&4 47 # Close FD4 48 exec 4>&- 49 echo "Test system ready" >&2 50 } 51 52 # Exit, with status code "skip" (no 'real' failure) 53 function exit_fail() { 54 echo "$@" >&2 55 exit 1 56 } 57 58 # Exit, with status code "skip" (no 'real' failure) 59 function exit_skip() { 60 echo "SKIPPING: $1" 61 exit 77 62 } 63 64 function get_payto_uri() { 65 libeufin-bank create-account -u "$1" -p "$2" --name "$1" 2> /dev/null 66 } 67 68 echo -n "Checking for curl ..." 69 curl --version 2> /dev/null > /dev/null || exit_skip " no curl" 70 echo " OK" 71 echo -n "Checking for jq ..." 72 jq --version 2> /dev/null > /dev/null || exit_skip " no jq" 73 echo " OK"