diff --git a/Makefile.am b/Makefile.am index 2187b2df..32838ab6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,11 +47,15 @@ DISTCHECK_CONFIGURE_FLAGS=--enable-vbr --with-lua --enable-stats --with-odbx --w # # We want to *build and install* these on the target machine. -nodist_doc_DATA = opendkim/opendkim.conf.simple \ +nodist_doc_DATA = contrib/openrc/opendkim.openrc \ + contrib/systemd/opendkim.tmpfiles \ + opendkim/opendkim.conf.simple \ opendkim/opendkim.conf.simple-verify # We want to *ship* these. -EXTRA_DIST = opendkim/opendkim.conf.simple.in \ +EXTRA_DIST = contrib/openrc/opendkim.openrc.in \ + contrib/systemd/opendkim.tmpfiles.in \ + opendkim/opendkim.conf.simple.in \ opendkim/opendkim.conf.simple-verify.in # The next rule allow us to replace bindir, libdir, etc. within @@ -59,7 +63,9 @@ EXTRA_DIST = opendkim/opendkim.conf.simple.in \ # be found in the "Installation Directory Variables" section. edit = sed -e 's|@DOMAIN[@]|$(DOMAIN)|g' \ -e 's|@LOCALSTATEDIR[@]|$(localstatedir)|g' \ - -e 's|@RUNSTATEDIR[@]|$(runstatedir)|g' + -e 's|@RUNSTATEDIR[@]|$(runstatedir)|g' \ + -e 's|@SBINDIR[@]|$(sbindir)|g' \ + -e 's|@SYSCONFDIR[@]|$(sysconfdir)|g' # This rule includes EVERY source/intermediate file as a dependency of # EVERY output file, which is clearly wrong, but it may be the best we diff --git a/configure.ac b/configure.ac index bf1a7fe1..46b7d8a0 100644 --- a/configure.ac +++ b/configure.ac @@ -2733,6 +2733,7 @@ AC_CONFIG_FILES([ Makefile contrib/init/solaris/Makefile contrib/ldap/Makefile contrib/lua/Makefile + contrib/openrc/Makefile contrib/patches/Makefile contrib/repute/Makefile contrib/spec/Makefile diff --git a/contrib/.gitignore b/contrib/.gitignore index 88b99afa..78a72c55 100644 --- a/contrib/.gitignore +++ b/contrib/.gitignore @@ -1,3 +1,5 @@ Makefile Makefile.in opendkim.spec +openrc/opendkim.openrc +systemd/opendkim.tmpfiles diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 76df01cd..174074e6 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -3,6 +3,6 @@ #AUTOMAKE_OPTIONS = foreign -SUBDIRS = convert docs init ldap lua patches repute spec stats systemd +SUBDIRS = convert docs init ldap lua openrc patches repute spec stats systemd dist_doc_DATA = README diff --git a/contrib/openrc/Makefile.am b/contrib/openrc/Makefile.am new file mode 100644 index 00000000..63b12a1e --- /dev/null +++ b/contrib/openrc/Makefile.am @@ -0,0 +1 @@ +dist_doc_DATA = README diff --git a/contrib/openrc/README b/contrib/openrc/README new file mode 100644 index 00000000..5b9f99e4 --- /dev/null +++ b/contrib/openrc/README @@ -0,0 +1,11 @@ +Service scripts and configuration for the OpenRC[0] init system. They +are supported by their authors and/or the maintainers of the OpenDKIM +package[1] in Gentoo linux (presently, one and the same). + +OpenRC uses the tmpfiles.d mechanism[2], so the tmpfiles entry in the +"systemd" subdirectory is relevant here as well. + + +[0] https://github.com/OpenRC/openrc +[1] https://packages.gentoo.org/packages/mail-filter/opendkim +[2] https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html diff --git a/contrib/openrc/opendkim.openrc.in b/contrib/openrc/opendkim.openrc.in new file mode 100644 index 00000000..83f2f28b --- /dev/null +++ b/contrib/openrc/opendkim.openrc.in @@ -0,0 +1,52 @@ +#!/sbin/openrc-run + +CONFFILE="@SYSCONFDIR@/${RC_SVCNAME}.conf" +required_files="${CONFFILE}" + +command="@SBINDIR@/opendkim" +pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid" +command_args="-P ${pidfile} -x ${CONFFILE}" +extra_commands="checkconfig" + +depend() { + use dns logger net + before mta +} + +checkconfig() { + # + # The opendkim.conf man page says, + # + # For parameters that are Boolean in nature, only the first byte + # of the value is processed... For negative values, the following + # are accepted: "F", "f", "N", "n", "0".' + # + if grep '^[[:space:]]*Background[[:space:]][[:space:]]*[FfNn0]' "${CONFFILE}" \ + >/dev/null 2>&1; then + eend 1 "${RC_SVCNAME} cannot run in the foreground!" + fi + if ! "${command}" -n "${command_args}"; then + eend 1 "${RC_SVCNAME} configuration check failed" + fi +} + +start_pre() { + # If this isn't a restart, make sure that the user's config isn't + # busted before we try to start the daemon (this will produce + # better error messages than if we just try to start it blindly). + # + # If, on the other hand, this *is* a restart, then the stop_pre + # action will have ensured that the config is usable and we don't + # need to do that again. + if [ "${RC_CMD}" != "restart" ]; then + checkconfig || return $? + fi +} + +stop_pre() { + # If this is a restart, check to make sure the user's config + # isn't busted before we stop the running daemon. + if [ "${RC_CMD}" = "restart" ]; then + checkconfig || return $? + fi +} diff --git a/contrib/systemd/opendkim.tmpfiles.in b/contrib/systemd/opendkim.tmpfiles.in new file mode 100644 index 00000000..a9118974 --- /dev/null +++ b/contrib/systemd/opendkim.tmpfiles.in @@ -0,0 +1,5 @@ +# We allow everyone to read/traverse this directory because if it +# contains a local socket, then (for example) your MTA will want to +# look in there. Permissions on the socket itself are controlled +# by the "UserID" and "UMask" directives in the daemon's configuration. +d @RUNSTATEDIR@/opendkim 0755 opendkim opendkim