summaryrefslogtreecommitdiff
path: root/buildbot/make_auditor_reports.sh
blob: da69699cd9c6a495e0883353ab458e9dd1ba46de (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
62
63
64
65
66
67
68
69
#!/bin/sh


# Remove once ready!
# echo "Auditor report generation is work in progress.."
# return 1

# 1 generate reports.

if test -z ${TALER_DEPLOYMENT}; then
  echo "Please export env variable TALER_DEPLOYMENT=(test|demo) before running this script"
  exit 1
fi

ACTIVE_COLOR=$(sudo -u ${TALER_DEPLOYMENT} cat /home/${TALER_DEPLOYMENT}/active)
echo "Active color is: $ACTIVE_COLOR"

if test -z ${ACTIVE_COLOR}; then
  echo "Could not outline what the active color is"
  exit 1
fi

DATE=$(date +%Y-%m-%d)
REPORT_FILE=/home/${ACTIVE_COLOR}/audit_report.${DATE}
WIRE_REPORT_FILE=/home/${ACTIVE_COLOR}/wire_audit_report.${DATE}
SUDO_COLOR="sudo -u ${ACTIVE_COLOR}"
JINJA_TEMPLATE="auditor-report.tex.j2"
REPORTS_DIRECTORY="/home/${TALER_DEPLOYMENT}/reports"

CMD=$(printf "%s; %s" \
  "source /home/${ACTIVE_COLOR}/activate" \
  'taler-auditor-exchange -m $(taler-config -s exchange -o master_public_key) -u $(taler-config -s exchange -o base_url)')

${SUDO_COLOR} bash -c "$CMD"

${SUDO_COLOR} bash -c \
  "source /home/${ACTIVE_COLOR}/activate; \
   taler-auditor > ${REPORT_FILE}.txt"

${SUDO_COLOR} bash -c \
  "source /home/${ACTIVE_COLOR}/activate; \
  taler-wire-auditor > ${WIRE_REPORT_FILE}.txt"

# 2 convert them into PDF.
# 3 put them into nginx-served directory.

if ! ${SUDO_COLOR} sh -c \
  "./render_auditor_reports.py \
    ${REPORT_FILE}.txt \
    ${WIRE_REPORT_FILE}.txt \
    > ${REPORT_FILE}.tex \
    < ${JINJA_TEMPLATE}"; then
echo
echo "Could not generate the TEX template (from Jinja)."
exit 1
fi

# POLISHING ENDS HERE.

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

${SUDO_COLOR} rm
  "${REPORT_FILE}.log"
  "${REPORT_FILE}.tex"
  "${REPORT_FILE}.txt"

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