#!/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) REPORT_FILE_NOEXT="${HOME}/audit_report.${DATE}" WIRE_REPORT_FILE_NOEXT="${HOME}/wire_audit_report.${DATE}" JINJA_TEMPLATE="auditor-report.tex.j2" REPORTS_DIRECTORY=$(taler-config -s auditor -o reports -f) clean_files () { # Remove garbage and set permissions. echo Removing "${REPORT_FILE_NOEXT}.aux" rm -f "${REPORT_FILE_NOEXT}.aux" echo Removing "${REPORT_FILE_NOEXT}.tex" rm -f "${REPORT_FILE_NOEXT}.tex" echo Removing "${REPORT_FILE_NOEXT}.log" rm -f "${REPORT_FILE_NOEXT}.log" echo Removing "${REPORT_FILE_NOEXT}.txt", "${WIRE_REPORT_FILE_NOEXT}.txt" rm -f "${REPORT_FILE_NOEXT}.txt" "${WIRE_REPORT_FILE_NOEXT}.txt" } if test -a ${REPORTS_DIRECTORY}/$(basename "${REPORT_FILE_NOEXT}.pdf"); then echo "Today's report already compiled!" exit 0 fi CONFIG_FILE="${TALER_HOME}/.config/taler.conf" # Generate first report. echo "Running taler-auditor" if ! taler-auditor -c ${CONFIG_FILE} > "${REPORT_FILE_NOEXT}.txt"; then echo "taler-auditor failed" clean_files exit 1 fi # Generate "wire" report. echo "Running taler-wire-auditor" if ! taler-wire-auditor -c ${CONFIG_FILE} > "${WIRE_REPORT_FILE_NOEXT}.txt"; then echo "taler-wire-auditor failed" # clean_files exit 1 fi echo "Rendering report" if ! python3 ${PWD}/render_auditor_reports.py \ "${REPORT_FILE_NOEXT}.txt" \ "${WIRE_REPORT_FILE_NOEXT}.txt" \ > "${REPORT_FILE_NOEXT}.tex" \ < "${JINJA_TEMPLATE}"; then echo "Rendering failed" # clean_files exit 1 fi cd ${HOME} echo "TeXing report" if ! pdflatex "${REPORT_FILE_NOEXT}.tex" && pdflatex "${REPORT_FILE_NOEXT}.tex"; then echo "pdflatex failed" # clean_files exit 1 fi clean_files if ! test -f "${REPORT_FILE_NOEXT}.pdf"; then echo Could not produce the report exit 1 fi mkdir -p "${REPORTS_DIRECTORY}" chmod 444 "${REPORT_FILE_NOEXT}.pdf" mv "${REPORT_FILE_NOEXT}.pdf" "${REPORTS_DIRECTORY}" echo Reports moved in "${REPORTS_DIRECTORY}". exit 0