summaryrefslogtreecommitdiff
path: root/network/opendmarc/patches/ticket159.patch
blob: 13a90436144ee3c04b9d4441c873507fac205ee7 (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
diff --git a/configure.ac b/configure.ac
index 255c449..27d7cd4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -492,6 +492,7 @@ AC_OUTPUT([ Makefile
 		reports/opendmarc-expire.8
 		reports/opendmarc-import
 		reports/opendmarc-import.8
+		reports/opendmarc-importstats
 		reports/opendmarc-importstats.8
 		reports/opendmarc-params
 		reports/opendmarc-params.8
diff --git a/reports/opendmarc-importstats b/reports/opendmarc-importstats
deleted file mode 100755
index 839a871..0000000
--- a/reports/opendmarc-importstats
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-##
-## Copyright (c) 2012, The Trusted Domain Project.  All rights reserved.
-##
-## opendmarc-importstats -- import opendmarc output to MySQL
-##
-## This is intended to be used via a crontab.  If import is successful,
-## this code exits quietly so there's no output.  If it fails, it does
-## "ls -l" on the temporary file, so that cron generates mail to whever
-## ran the job.
-
-## setup
-statsdb="/var/tmp/dmarc.dat"
-# OPENDMARC_PASSWORD="password"; export OPENDMARC_PASSWORD
-
-if [ -s $statsdb ]
-then
-	mv $statsdb ${statsdb}.OLD.$$
-
-	if opendmarc-import < ${statsdb}.OLD.$$
-	then
-		rm ${statsdb}.OLD.$$
-	else
-		ls -l ${statsdb}.OLD.$$
-	fi
-fi
diff --git a/reports/opendmarc-importstats.in b/reports/opendmarc-importstats.in
new file mode 100755
index 0000000..3a28ee3
--- /dev/null
+++ b/reports/opendmarc-importstats.in
@@ -0,0 +1,27 @@
+#!/bin/sh
+##
+## Copyright (c) 2012, The Trusted Domain Project.  All rights reserved.
+##
+## opendmarc-importstats -- import opendmarc output to MySQL
+##
+## This is intended to be used via a crontab.  If import is successful,
+## this code exits quietly so there's no output.  If it fails, it does
+## "ls -l" on the temporary file, so that cron generates mail to whever
+## ran the job.
+
+## setup
+statsdb="`grep ^HistoryFile @sysconfdir@/opendmarc.conf | sed 's/^HistoryFile\s\+//'`"
+[ -z "$statsdb" ] && exit 0
+# OPENDMARC_PASSWORD="password"; export OPENDMARC_PASSWORD
+
+if [ -s "$statsdb" ]
+then
+	mv "$statsdb" "${statsdb}.OLD.$$"
+
+	if opendmarc-import < "${statsdb}.OLD.$$"
+	then
+		rm "${statsdb}.OLD.$$"
+	else
+		ls -l "${statsdb}.OLD.$$"
+	fi
+fi