Hi, Am 24.04.2018 um 16:47 schrieb Marco d'Itri: > On Apr 24, Sven Bartscher <kritzef...@debian.org> wrote: > >> I currently see no fix for this besides shipping a systemd unit file >> with RestartSec. This would require some thinking though, because the > I want to add this anyway, but I believe that there are better solutions. > >> One easy way to solve this problem about accessing the options could be >> to tell systemd to run the init script of rbldnsd as a forking service >> and specify RestartSec and PIDFile. This would be a slight improvement >> over the current situation, but IMO quite ugly. > No: this would be seriously stupid because it would mask every kind of > errors.
The attached patch adds the systemd units rbldnsd.service and rbldnsd@.service. The latter controls one instance of rbldnsd with the command line options specified in /etc/rbldnsd/<instance>.conf, while the former controls all instances for which command line options are set. This approach works quite well for me, but also means that the place to configure rbldnsd depends on the used init system. I guess this makes it unfit for inclusion in the package as-is, but it might serve as a starting point for a proper solution. Regards Sven
From 70abede076f42f7b2e08079c02dcc10e95dd7a0e Mon Sep 17 00:00:00 2001 From: Sven Bartscher <sven.bartsc...@credativ.de> Date: Wed, 25 Apr 2018 13:30:24 +0200 Subject: [PATCH] Add systemd units The instance unit file creates an instance for each file in /etc/rbldnsd/*.conf that sets RBLDNSD_ARGS. The non-instance unit starts and stop all detected instances. --- debian/rbldnsd-generator | 27 +++++++++++++++++++++++++++ debian/rbldnsd.conf | 7 +++++++ debian/rbldnsd.service | 11 +++++++++++ debian/rbldnsd@.service | 15 +++++++++++++++ debian/rules | 5 ++++- 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 debian/rbldnsd-generator create mode 100644 debian/rbldnsd.conf create mode 100644 debian/rbldnsd.service create mode 100644 debian/rbldnsd@.service diff --git a/debian/rbldnsd-generator b/debian/rbldnsd-generator new file mode 100644 index 0000000..472cdb8 --- /dev/null +++ b/debian/rbldnsd-generator @@ -0,0 +1,27 @@ +#!/bin/sh + +# This systemd generator creates dependency symlinks that make all +# rbldnsd instances for which command line options are set be +# started/stopped/reloaded when rbldnsd.service is +# started/stopped/reloaded. + +set -eu + +gendir="$1" +wantdir="$1/rbldnsd.service.wants" +rbldnsdservice="/lib/systemd/system/rbldnsd@.service" + +mkdir -p "$wantdir" + +for conf in /etc/rbldnsd/*.conf; do + # If nothing was found the loop still loops over the unexpanded + # glob. Abort if that is the case. + if ! [ -e "$conf" ]; then continue; fi + + if ! grep -q '^\s*RBLDNSD_ARGS=' "$conf"; then continue; fi + + name=$(basename -s '.conf' $conf) + ln -s "$rbldnsdservice" "$wantdir/rbldnsd@$name.service" +done + +exit 0 diff --git a/debian/rbldnsd.conf b/debian/rbldnsd.conf new file mode 100644 index 0000000..0b15a19 --- /dev/null +++ b/debian/rbldnsd.conf @@ -0,0 +1,7 @@ +# The variable below specifies command line options that should be +# passed to rbldnsd. To start multiple instances of rbldnsd you can +# create additional files in the form /etc/rbldnsd/<name>.conf. For +# each of these files systemd will generate one rbldnsd@<name>.service +# unit. + +# RBLDNSD_ARGS="-r/var/lib/rbldns/dsbl -b127.2 list.dsbl.org:ip4set:list" diff --git a/debian/rbldnsd.service b/debian/rbldnsd.service new file mode 100644 index 0000000..590324d --- /dev/null +++ b/debian/rbldnsd.service @@ -0,0 +1,11 @@ +[Unit] +Description=rbldnsd blacklist dns server + +[Service] +Type=oneshot +ExecStart=/bin/true +ExecReload=/bin/true +RemainAfterExit=on + +[Install] +WantedBy=multi-user.target diff --git a/debian/rbldnsd@.service b/debian/rbldnsd@.service new file mode 100644 index 0000000..f3d3f50 --- /dev/null +++ b/debian/rbldnsd@.service @@ -0,0 +1,15 @@ +[Unit] +Description=rbldnsd blacklist dns server instance %i +ConditionPathExists=/etc/rbldnsd/%i.conf +PartOf=rbldnsd.service +ReloadPropagatedFrom=rbldnsd.service +Before=rbldnsd.service + +[Service] +ExecStart=/usr/sbin/rbldnsd -n $RBLDNSD_ARGS +ExecReload=/bin/kill -HUP $MAINPID +RestartSec=1 +EnvironmentFile=/etc/rbldnsd/%i.conf + +[Install] +WantedBy=multi-user.target diff --git a/debian/rules b/debian/rules index 0c7a724..dc15a90 100755 --- a/debian/rules +++ b/debian/rules @@ -32,9 +32,12 @@ binary-arch: build dh_testroot dh_prep - dh_installdirs /usr/sbin/ + dh_installdirs /usr/sbin/ /etc/rbldnsd/ /lib/systemd/system-generators/ install --mode=755 rbldnsd debian/rbldnsd/usr/sbin/ + install --mode=644 debian/rbldnsd.conf debian/rbldnsd/etc/rbldnsd/ + install --mode=755 debian/rbldnsd-generator debian/rbldnsd/lib/systemd/system-generators/ dh_installinit --restart-after-upgrade + dh_installsystemd --restart-after-upgrade dh_installman rbldnsd.8 dh_installdocs README.user TODO CHANGES-0.81 dh_installchangelogs NEWS -- 2.17.0
signature.asc
Description: OpenPGP digital signature