Bernhard Schmidt wrote...
> Sure, feel free to push directly into the salsa repository and upload.
Well, although I probably could (salsa and I aren't friends yet), I'd
prefer some review and tests first.
So, patch attached.
Christoph, old-school
diff --git a/debian/changelog b/debian/changelog
index 9a049a5..0c09722 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+nfdump (1.6.17-1.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Add support for multiple instance, also eases support for
+differing configuration. Closes: #644632, #843602
+
+ -- Christoph Biedl Sat, 22 Sep 2018 21:21:43 +0200
+
nfdump (1.6.17-1) unstable; urgency=medium
* [2216e879] New upstream version 1.6.17
diff --git a/debian/default.conf b/debian/default.conf
new file mode 100644
index 000..c7c81e5
--- /dev/null
+++ b/debian/default.conf
@@ -0,0 +1,28 @@
+
+# default configuration for nfcapd
+
+# The cache directory
+#
+# In a single-instance setup, there's nothing to configure here.
+# In a multi-instance setup, you must either make sure the cache
+# directory used is created by other means - or configure it here,
+# it will be created upon start then, optionally ownership changed to
+# the given user and group (default: root:root).
+#
+#cache_directory=/var/cache/nfdump
+#user=root
+#group=root
+
+# Options for this nfcapd instance, see nfcapd(1)
+#
+# Caveats:
+# - You must define a base directory (-l or -M), this is *not* checked.
+# - When using -l for the cache directory, you must give each instance
+# a separate directory, else all but the first instance will not
+# start.
+# - Any cache_dir, user and group values defined above needs to be
+# repeated here in an according option (-l/-M, -u, -g).
+# Remember, shell expandsion will not work when using systemd.
+# - Do not use the -D and -P options, they are already set internally.
+#
+options='-l /var/cache/nfdump -p 2055'
diff --git a/debian/nfdump-generator b/debian/nfdump-generator
new file mode 100755
index 000..88841a3
--- /dev/null
+++ b/debian/nfdump-generator
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+set -eu
+
+SERVICEFILE="/lib/systemd/system/nfdump@.service"
+WANTDIR="$1/nfdump.service.wants"
+
+CONFIG_DIR=/etc/nfdump/
+
+if [ -d "$CONFIG_DIR" ] ; then
+mkdir -p "$WANTDIR"
+cd "$CONFIG_DIR"
+for CONFIG in *.conf ; do
+[ -f "$CONFIG" ] || continue
+INSTANCE="$(systemd-escape "${CONFIG%%.conf}")"
+LINK="$WANTDIR/nfdump@$INSTANCE.service"
+
+sh -n "$CONFIG_DIR$CONFIG" 2>/dev/null || continue
+
+cache_dir=
+user=
+group=
+options=
+
+. "$CONFIG_DIR$CONFIG"
+
+[ "$options" ] || continue
+if [ "$cache_dir" ] ; then
+mkdir -p "$cache_dir"
+if [ "$user" ] && [ "$group" ] ; then
+chown "$user:$group" "$cache_dir"
+elif [ "$user" ] ; then
+chown "$user" "$cache_dir"
+fi
+fi
+
+ln -s "$SERVICEFILE" "$LINK"
+done
+fi
+
+exit 0
diff --git a/debian/nfdump.init b/debian/nfdump.init
index fb64ad5..82e6006 100644
--- a/debian/nfdump.init
+++ b/debian/nfdump.init
@@ -1,158 +1,176 @@
-#! /bin/sh
+#!/bin/sh
+
### BEGIN INIT INFO
-# Provides: nfcapd
-# Required-Start:$remote_fs $network
-# Required-Stop: $remote_fs
+# Provides: netflow capture daemon
+# Required-Start:$network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
-# Short-Description: netflow capture daemon
-# Description: nfcapd is the netflow capture daemon of the nfdump tools.
+# Short-Description: Flow-based network traffic analyser
+# Description: Manage all nfcapd instanaces defined in
+#/etc/nfdump/*.conf
### END INIT INFO
-# Author: Erik Wenzel
-
-# Do NOT "set -e"
-
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="netflow capture daemon"
NAME=nfcapd
-DAEMON=/usr/bin/$NAME
-DATA_BASE_DIR="/var/cache/nfdump"
-PIDFILE=/var/run/$NAME.pid
-DAEMON_ARGS="-D -l $DATA_BASE_DIR -P $PIDFILE"
-SCRIPTNAME=/etc/init.d/nfdump
+DESC='Netflow capture daemon'
+NFCAPD='/usr/bin/nfcapd'
+PIDDIR="/var/run/$NAME/"
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
+[ -x "$NFCAPD" ] || exit 0
-# Read configuration variable file if it is present
-[ -r /etc/default/nfdump ] && . /etc/default/nfdump
+mkdir -p "$PIDDIR"
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
-# Define LSB log_* functions.
-# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+# Define LSB functions
. /lib/lsb/init-functions
+# Start a nfcapd instance
#
-# Function that starts the daemon/service
-#
-do_start()
-{
- # Don't start daemon in this mode. Defined in /etc/default/nfdump
- if [ x"$nfcapd_start" = xno ]
- then
- [ "$VERBOSE"