summaryrefslogtreecommitdiff
path: root/buildbot/make_auditor_reports.sh
blob: df7fdc4a704f4f852773060c1be624b59c6cfedb (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
#!/bin/bash

# Logic that creates auditor reports, respecting
# the config file that lives under ${HOME}/.config/taler.conf.
# The results will be found under ${HOME}/reports/

set -eu
echo "Running taler-deployment bootstrap"
source ${HOME}/activate
taler-deployment bootstrap

echo "Running taler-deployment build"
source ${HOME}/activate
taler-deployment build

DATE=$(date +%Y-%m-%d)
REPORTS_DIRECTORY=$(taler-config -s auditor -o reports -f)
mkdir -p "${REPORTS_DIRECTORY}"
REPORT_FILE="${REPORTS_DIRECTORY}/${DATE}-report.pdf"

if test -a "${REPORT_FILE}"
then
  echo "Today's report already compiled!"
  exit 0
fi


CONFIG_FILE="${TALER_HOME}/.config/taler.conf"
# Generate today's report.
echo "Running taler-auditor"
if ! taler-auditor -c ${CONFIG_FILE} | tee build-log.txt; then
  echo "taler-auditor failed"
  clean_files
  exit 1
fi

REPORT=`tail -n1 build-log.txt | grep "Result is in" | awk '{print $4}'`

if ! test -f "${REPORT}"; then
  echo Could not produce the report
  exit 1
fi

chmod 444 "${REPORT}"
mv "${REPORT}" "${REPORT_FILE}"
echo "Report moved to ${REPORTS_DIRECTORY}."

rm -r `dirname $REPORT`

exit 0