ansible-taler-exchange

Ansible playbook to deploy a production Taler Exchange
Log | Files | Refs | README | LICENSE

setup-challenger-client-id-fact (543B)


      1 #!/usr/bin/env bash
      2 
      3 # Helper script, intented to be used by ansible
      4 # to generate a fact file.
      5 
      6 if [ $# -lt 5 ];
      7 then
      8   echo "Usage: $0 <fact_file> <user> <conf> <client_secret> <url>" >&2
      9   exit 1
     10 fi
     11 
     12 set -eu
     13 
     14 fact_file=$1
     15 myuser=$2
     16 conf=$3
     17 client_secret=$4
     18 url=$5
     19 
     20 client_id=$(sudo -u "$myuser" challenger-admin -c "$conf" --quiet --add="$client_secret" "$url")
     21 
     22 if [ -z "$client_id" ]; then
     23   echo "$0: challenger-admin returned an empty client id" >&2
     24   exit 1
     25 fi
     26 
     27 # Output as JSON string
     28 jq -n --arg id "$client_id" '$id' > "$fact_file"