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
|
From: Scott Kitterman <scott@kitterman.com>
Date: Mon, 23 Dec 2019 11:12:36 -0500
Subject: ticket159
Bug: https://sourceforge.net/p/opendmarc/tickets/159/
---
configure.ac | 1 +
reports/opendmarc-importstats | 26 --------------------------
reports/opendmarc-importstats.in | 27 +++++++++++++++++++++++++++
3 files changed, 28 insertions(+), 26 deletions(-)
delete mode 100755 reports/opendmarc-importstats
create mode 100644 reports/opendmarc-importstats.in
diff --git a/configure.ac b/configure.ac
index 692dbe4..cf4ff90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -538,6 +538,7 @@ AC_CONFIG_FILES([ 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 100644
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
|