aboutsummaryrefslogtreecommitdiff
path: root/src/auditor/taler-auditor.in
blob: 6a8e88daa26c298a60209308b18e61c66207cb95 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash

set -eu

function usage {
  cat - <<EOF
taler-auditor
Audit Taler exchange database for consistency.
Arguments mandatory for long options are also mandatory for short options.
  -c, --config=FILENAME      use configuration file FILENAME
  -h, --help                 print this help
  -i, --internal             perform checks only applicable for
                               exchange-internal audits
  -I, --ignore-not-found     ignore problems with the exchange bank account not existing
  -L, --log=LOGLEVEL         configure logging to use LOGLEVEL
  -l, --logfile=FILENAME     configure logging to write logs to FILENAME
  -m, --exchange-key=KEY     public key of the exchange (Crockford base32
                               encoded)
  -T, --timetravel=[+/-]MICROSECONDS
                             modify system time by given offset (for
                               debugging/testing only)
  -v, --version              print the version number
Report bugs to taler@gnu.org.
Home page: http://www.gnu.org/s/taler/
General help using GNU software: http://www.gnu.org/gethelp/
EOF
}


function optcheck {

TEMP=`getopt -o c:hiIL:l:m:T:v --long config:,help,internal,ignore-not-found,log:,logfile:exchange-key:,timetravel:,version -n 'taler-auditor' -- "$@"`

if [ $? != 0 ] ;
then
  exit 1 ;
fi

# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

VERBOSE=false
DEBUG=false
MEMORY=
DEBUGFILE=
JAVA_MISC_OPT=
INF=
while true; do
  case "$1" in
    -c | --config ) shift 2 ;;
    -h | --help )
        usage
        exit 0
        ;;
    -i | --internal ) shift ;;
    -I | --ignore-not-found ) INF="-I"; shift ;;
    -L | --log ) shift 2;;
    -l | --logfile ) shift ;;
    -m | --exchange-key ) shift 2 ;;
    -t | --timetravel ) shift 2 ;;
    -m | --memory ) MEMORY="$2"; shift 2 ;;
    -v | --version )
        taler-helper-auditor-deposits -v | sed -e 's/taler-helper-auditor-deposits/taler-auditor/'
        exit 0
        ;;
    -- )
        shift;
        break
        ;;
    * )
        usage
        exit 1
        ;;
  esac
done

}
# End of function 'optcheck'

optcheck "$@"

# Remove "-I" from $@ if present, store result in $ARGS.
ARGS=("$@")
ARGS=(${ARGS[@]/$INF})

DIR=`mktemp -d reportXXXXXX`
for n in aggregation coins deposits reserves
do
  taler-helper-auditor-$n ${ARGS[*]} > ${DIR}/$n.json
done

taler-helper-auditor-wire $INF ${ARGS[*]} > ${DIR}/wire.json

taler-helper-auditor-render.py \
    ${DIR}/aggregation.json \
    ${DIR}/coins.json \
    ${DIR}/deposits.json \
    ${DIR}/reserves.json \
    ${DIR}/wire.json < %datadir%/taler/exchange/auditor-report.tex.j2 > ${DIR}/auditor-report.tex
cd ${DIR}
pdflatex auditor-report.tex < /dev/null &> /dev/null || true
pdflatex auditor-report.tex < /dev/null &> /dev/null || true
pdflatex auditor-report.tex < /dev/null || echo "pdflatex failed"
cd ..

echo "Result is in ${DIR}/auditor-report.pdf"