summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mail-filter/opendmarc/files/opendmarc.initd')
-rw-r--r--mail-filter/opendmarc/files/opendmarc.initd51
1 files changed, 51 insertions, 0 deletions
diff --git a/mail-filter/opendmarc/files/opendmarc.initd b/mail-filter/opendmarc/files/opendmarc.initd
new file mode 100644
index 00000000000..d70afd75e72
--- /dev/null
+++ b/mail-filter/opendmarc/files/opendmarc.initd
@@ -0,0 +1,51 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+CONFFILE="/etc/opendmarc/${SVCNAME}.conf"
+
+depend() {
+ use dns logger net
+ before mta
+}
+
+check_cfg() {
+ if [ ! -f "${CONFFILE}" ] ; then
+ eerror "Configuration file ${CONFFILE} is missing"
+ return 1
+ fi
+ PIDFILE=$(sed -ne 's/^[[:space:]]*PidFile[[:space:]]\+//p' "${CONFFILE}")
+ local PIDDIR="${PIDFILE%/*}"
+ if [ ! -d "${PIDDIR}" ] ; then
+ checkpath -q -d -o ${OPENDMARC_USER}:${OPENDMARC_GROUP} -m 0755 "${PIDDIR}" || return 1
+ fi
+ if [ -z "${PIDFILE}" ] ; then
+ eerror "Configuration file needs PidFile setting - recommend adding 'PidFile /var/run/opendmarc/${SVCNAME}.pid' to ${CONFFILE}"
+ return 1
+ fi
+ if egrep -q '^[[:space:]]*Background[[:space:]]+false' "${CONFFILE}" ; then
+ eerror "${SVCNAME} service cannot run with Background key set to false!"
+ return 1
+ fi
+
+ ebegin "Checking your configfile (${CONFFILE})"
+ opendmarc -c "${CONFFILE}" -n
+ eend $? "Configuration error. Please fix your configfile (${CONFFILE})"
+}
+
+start() {
+ check_cfg || return 1
+
+ ebegin "Starting OpenDMARC"
+ start-stop-daemon --start --pidfile "${PIDFILE}" \
+ --exec /usr/sbin/opendmarc -- -c "${CONFFILE}"
+ eend $?
+}
+
+stop() {
+ check_cfg || return 1
+ ebegin "Stopping OpenDMARC"
+ start-stop-daemon --stop --pidfile "${PIDFILE}"
+ eend $?
+}