taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

generate-letter.sh (973B)


      1 #!/bin/bash
      2 # This script is in the public domain.
      3 #
      4 # Call with the JSON file (like test.json) with
      5 # an array of merchants to generate letters for!
      6 #
      7 # You must export
      8 #
      9 # export BASE_DOMAIN=https://e.netzbon-basel.ch/
     10 #
     11 # before running this script!
     12 #
     13 
     14 set -eu
     15 LENGTH=$(jq length < $1)
     16 echo "Generating $LENGTH letters for ${BASE_DOMAIN}"
     17 mkdir -p export
     18 mkdir -p tmp
     19 
     20 for n in $(seq 1 $LENGTH)
     21 do
     22     echo "Processing merchant $n"
     23     INDEX=$(expr $n - 1 || true)
     24     ID=$(jq -r .[$INDEX].id < $1)
     25 
     26     jq ".[$INDEX]" < $1 | jq '.domain="'"${BASE_DOMAIN}"'"' > "tmp/${ID}.json"
     27     cd tmp
     28     ../render.py "${ID}.json" < ../template_de.tex.j2 > "${ID}.tex"
     29     pdflatex "${ID}.tex" < /dev/null &> /dev/null || true
     30     pdflatex "${ID}.tex" < /dev/null &> /dev/null || true
     31     pdflatex "${ID}.tex" < /dev/null
     32     mv "${ID}.pdf" ../export/
     33     cd ..
     34 
     35     echo "Done with ${ID}"
     36 done
     37 
     38 pdftk export/*.pdf cat output result.pdf
     39 echo "Combined letters are in 'result.pdf'"