summaryrefslogtreecommitdiff
path: root/buildbot/make_auditor_reports.sh
blob: 17299b71c67096ca1b7b5f148cc92fb3df8a1ca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

# Logic that creates auditor reports, respecting
# the config file that lives under ${HOME}/.config/taler.conf.
#
# Therefore, if the config file mentions the "demo" ("test") DB,
# then the report will reflect the "demo" ("test") deployment.


DATE=$(date +%Y-%m-%d)
REPORT_FILE_NOEXT=${HOME}/audit_report.${DATE}
WIRE_REPORT_FILE_NOEXT=${HOME}/wire_audit_report.${DATE}
JINJA_TEMPLATE="auditor-report.tex.j2"
REPORTS_DIRECTORY="${HOME}/reports"

# Add the exchange into the auditor DB.
TALER_AUDITOR_EXCHANGE=$(printf "taler-auditor-exchange -c %s -m %s -u %s" \
  '${HOME}/.config/taler.conf' \
  '$(taler-config -s exchange -o master_public_key)' \
  '$(taler-config -s exchange -o base_url)')

CMD=$(printf "%s; %s" \
  "source ${HOME}/activate" \
  "${TALER_AUDITOR_EXCHANGE}")

bash -c "$CMD"

# Generate first report.
bash -c \
  "source ${HOME}/activate; \
   taler-auditor > ${REPORT_FILE_NOEXT}.txt"

# Generate "wire" report.
bash -c \
  "source ${HOME}/activate; \
  taler-wire-auditor > ${WIRE_REPORT_FILE_NOEXT}.txt"

# Convert them into PDF and put them into nginx-served directory.
if ! sh -c \
  "./render_auditor_reports.py \
    ${REPORT_FILE_NOEXT}.txt \
    ${WIRE_REPORT_FILE_NOEXT}.txt \
    > ${REPORT_FILE_NOEXT}.tex \
    < ${JINJA_TEMPLATE}"; then
echo
echo "Could not generate the TEX template (from Jinja)."
exit 1
fi

# POLISHING ENDS HERE.

pdflatex \
  --output-directory $REPORTS_DIRECTORY \
  "${REPORT_FILE_NOEXT}.tex"

rm \
  "${REPORT_FILE_NOEXT}.log" \
  "${REPORT_FILE_NOEXT}.tex" \
  "${REPORT_FILE_NOEXT}.txt"

echo "The file ${REPORT_FILE_NOEXT}.pdf" has been correctly generated.