Initial commit
[opendmarc.git] / usr / sbin / opendmarc-importstats
1 #!/bin/sh
2 ##
3 ## Copyright (c) 2012, The Trusted Domain Project. All rights reserved.
4 ##
5 ## opendmarc-importstats -- import opendmarc output to MySQL
6 ##
7 ## This is intended to be used via a crontab. If import is successful,
8 ## this code exits quietly so there's no output. If it fails, it does
9 ## "ls -l" on the temporary file, so that cron generates mail to whever
10 ## ran the job.
11
12 ## setup
13 statsdb="/var/tmp/dmarc.dat"
14 # OPENDMARC_PASSWORD="password"; export OPENDMARC_PASSWORD
15
16 if [ -s $statsdb ]
17 then
18 mv $statsdb ${statsdb}.OLD.$$
19
20 if opendmarc-import < ${statsdb}.OLD.$$
21 then
22 rm ${statsdb}.OLD.$$
23 else
24 ls -l ${statsdb}.OLD.$$
25 fi
26 fi