gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: -script now works with pingenv2


From: gnunet
Subject: [taler-anastasis] 01/02: -script now works with pingenv2
Date: Wed, 28 Dec 2022 11:28:27 +0100

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

grothoff pushed a commit to branch master
in repository anastasis.

commit f581f54f8de3df9787eb2777259912b44c49be0e
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Dec 28 11:27:48 2022 +0100

    -script now works with pingenv2
---
 src/authorization/anastasis-authorization-post.sh | 44 +++++++++++++----------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/src/authorization/anastasis-authorization-post.sh 
b/src/authorization/anastasis-authorization-post.sh
index f74f382..171fd65 100755
--- a/src/authorization/anastasis-authorization-post.sh
+++ b/src/authorization/anastasis-authorization-post.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 # This file is in the public domain.
-set -eux
+set -eu
 
 # Theses are Anastasis SARL specific, do not share!
 # CLIENT_ID=
@@ -49,7 +49,7 @@ cat - | sed -e "s/%NAME%/$NAME/g" \
            -e "s/%COUNTRY%/$COUNTRY/g" \
            -e "s/%MESSAGE%/$MESSAGE/g" > input.tex <<EOF
 \NeedsTeXFormat{LaTeX2e}
-\documentclass[fontsize=11pt,a4paper,DE]{scrlttr2}
+\documentclass[fontsize=11pt,a4paper]{scrlttr2}
 \makeatletter
 \KOMAoptions{foldmarks=off}
 %\@setplength{toaddrvpos}{30mm}
@@ -70,9 +70,9 @@ cat - | sed -e "s/%NAME%/$NAME/g" \
 \end{letter}
 \end{document}
 EOF
-pdflatex input.tex
+pdflatex input.tex > /dev/null 2> /dev/null
 
-REPLY=`curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
+REPLY=`curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "grant_type=client_credentials" \
     --data-urlencode "client_id=$CLIENT_ID" \
     --data-urlencode "client_secret=$CLIENT_SECRET" \
@@ -81,14 +81,14 @@ REPLY=`curl -X POST -H "Content-Type: 
application/x-www-form-urlencoded" \
 
 ACCESS_TOKEN=`echo $REPLY | jq -r .access_token`
 
-REPLY=`curl \
+REPLY=`curl -s \
     -X GET "$ENDPOINT/file-upload" \
     -H  "Authorization: Bearer $ACCESS_TOKEN"`
 ATTRS=`echo $REPLY | jq .data.attributes`
 UPLOAD_URL=`echo $ATTRS | jq -r .url`
 URL_SIG=`echo $ATTRS | jq -r .url_signature`
 
-curl -X PUT -T input.pdf $UPLOAD_URL
+curl -s -X PUT -T input.pdf $UPLOAD_URL
 
 
 RECIPIENT="$(jq -n '
@@ -139,7 +139,7 @@ REQUEST="$(jq -n '
     --arg URL_SIG "$URL_SIG" \
   )"
 
-STATUS=$(curl --request POST \
+STATUS=$(curl -s --request POST \
      --url $ENDPOINT/organisations/${ORG_ID}/letters \
      --header 'Content-Type: application/vnd.api+json' \
      --header "Authorization: Bearer $ACCESS_TOKEN" \
@@ -156,22 +156,30 @@ case $STATUS in
         exit 1;
         ;;
 esac
-LETTER_ID=`echo $REPLY | jq -r .data.id`
-
-REPLY=`mktemp /tmp/authorization-delete-replyXXXXXX`
-STATUS=$(curl --request DELETE \
-        --url $ENDPOINT/organisations/$ORG_ID/letters/$LETTER_ID \
-        --header "Authorization: Bearer $ACCESS_TOKEN" \
-        -o $REPLY \
-        -w "%{http_code}" -s)
-cat $REPLY >> $LOGS
-case $STATUS in
+LETTER_ID=`cat $MYDIR/final-reply.txt | jq -r .data.id`
+REPLY=$MYDIR/delete-reply.txt
+STATUS=409
+sleep 1;
+while test $STATUS = 409;
+do
+  STATUS=$(curl -s --request DELETE \
+          --url $ENDPOINT/organisations/$ORG_ID/letters/$LETTER_ID \
+          --header "Authorization: Bearer $ACCESS_TOKEN" \
+          -o $REPLY \
+          -w "%{http_code}" -s)
+  case $STATUS in
     204)
+       cat $REPLY >> $LOGS
         ;;
+    409)
+       # Happens, likely still in processing...
+       ;;
     *)
         echo "Failed to delete letter: $STATUS" >> $LOGS
         ;;
-esac
+  esac
+done
+
 rm -r $MYDIR
 
 exit 0

-- 
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]