forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opendmarc.initd
53 lines (46 loc) · 1.47 KB
/
opendmarc.initd
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
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
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
# create /var/run/opendmarc
mkdir -p /var/run/opendmarc >& /dev/null
chown ${OPENDMARC_USER}:${OPENDMARC_GROUP} /var/run/opendmarc >& /dev/null
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 $?
}