summaryrefslogtreecommitdiff
path: root/pcr/openrc-net/opendkim.initd
diff options
context:
space:
mode:
authorDavid P <megver83@parabola.nu>2018-04-23 22:31:18 -0300
committerDavid P <megver83@parabola.nu>2018-04-23 22:31:18 -0300
commit58a4cab6e3c6bc0f641c987d02633411dbbb013a (patch)
treeaf594f644ebe91bc6ef064b5b1020d0cee5046b6 /pcr/openrc-net/opendkim.initd
parent31773ac407fd74dccf5b56f00b7707cb6369039c (diff)
upgpkg: pcr/openrc-net 20180424-1
Added opendkim-openrc Signed-off-by: David P <megver83@parabola.nu>
Diffstat (limited to 'pcr/openrc-net/opendkim.initd')
-rw-r--r--pcr/openrc-net/opendkim.initd55
1 files changed, 55 insertions, 0 deletions
diff --git a/pcr/openrc-net/opendkim.initd b/pcr/openrc-net/opendkim.initd
new file mode 100644
index 000000000..0d075d166
--- /dev/null
+++ b/pcr/openrc-net/opendkim.initd
@@ -0,0 +1,55 @@
+#!/usr/bin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+CONFFILE=/etc/opendkim/${SVCNAME}.conf
+
+depend() {
+ use dns logger net
+ before mta
+}
+
+check_cfg() {
+
+ PIDFILE=$(sed -ne 's/^[[:space:]]*PidFile[[:space:]]\+//p' "${CONFFILE}")
+ local PIDDIR="${PIDFILE%/*}"
+ if [ ! -d "${PIDDIR}" ] ; then
+ checkpath -q -d -o opendkim:mail -m 0755 "${PIDDIR}" || return 1
+ fi
+ if [ ! -f "${CONFFILE}" ] ; then
+ eerror "Configuration file ${CONFFILE} is missing"
+ return 1
+ fi
+ if [ -z "${PIDFILE}" ] ; then
+ eerror "Configuration file needs PidFile setting - recommend adding 'PidFile /run/opendkim/${SVCNAME}.pid' to ${CONFFILE}"
+ return 1
+ fi
+
+ if egrep -q '^[[:space:]]*Background[[:space:]]+no' "${CONFFILE}" ; then
+ eerror "${SVCNAME} service cannot run with Background key set to yes!"
+ return 1
+ fi
+}
+
+start() {
+ check_cfg || return 1
+
+ # Remove stalled Unix socket if no other process is using it
+ local UNIX_SOCKET=$(sed -ne 's/^[[:space:]]*Socket[[:space:]]\+\(unix\|local\)://p' "${CONFFILE}")
+
+ if [ -S "${UNIX_SOCKET}" ] && ! fuser -s "${UNIX_SOCKET}"; then
+ rm "${UNIX_SOCKET}"
+ fi
+
+ ebegin "Starting OpenDKIM"
+ start-stop-daemon --start --pidfile "${PIDFILE}" \
+ --exec /usr/bin/opendkim -- -x "${CONFFILE}"
+ eend $?
+}
+
+stop() {
+ check_cfg || return 1
+ ebegin "Stopping OpenDKIM"
+ start-stop-daemon --stop --pidfile "${PIDFILE}"
+ eend $?
+}