aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2024-10-16 14:13:55 +0200
committerGitHub <noreply@github.com>2024-10-16 14:13:55 +0200
commitefed6f196ecab333b76b83a5d256c9e4e6b75867 (patch)
treed8e5963a07a1ea87f3547a0e9ae8d370e6cb06f5 /packages
parent3e2ce661f01545daeb311d671bf222d378729bca (diff)
Read and parse configuration files. Fixes #41. (#42)1.7rc1
Read and parse configuration files. Fixes #41. * supports nDPId / nDPIsrvd via command line parameter `-f` * nDPId: read general/tuning and libnDPI settings * support for settings risk domains libnDPI option via config file or via `-R` (Fixes #45, thanks to @UnveilTech) * added some documentation in the config file * adjusted Systemd and Debian packaging to make use of config files Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'packages')
-rwxr-xr-xpackages/debian/postrm6
-rwxr-xr-xpackages/debian/preinst16
-rwxr-xr-xpackages/debian/prerm3
-rw-r--r--packages/systemd/default.cfg2
-rw-r--r--packages/systemd/ndpid@.service.in5
-rw-r--r--packages/systemd/ndpisrvd.service.in7
6 files changed, 30 insertions, 9 deletions
diff --git a/packages/debian/postrm b/packages/debian/postrm
new file mode 100755
index 000000000..0699f2a47
--- /dev/null
+++ b/packages/debian/postrm
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+rm -rf /run/nDPId /run/nDPIsrvd
+deluser ndpid || true
+deluser ndpisrvd || true
+delgroup ndpisrvd-distributor || true
diff --git a/packages/debian/preinst b/packages/debian/preinst
new file mode 100755
index 000000000..e60ef3af3
--- /dev/null
+++ b/packages/debian/preinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+addgroup --system ndpisrvd-distributor
+adduser --system --no-create-home --shell=/bin/false --group ndpisrvd
+adduser --system --no-create-home --shell=/bin/false --group ndpid
+
+cat <<EOF
+**********************************************************************************
+* The that may want to access DPI data needs access to /run/nDPIsrvd/distributor *
+* *
+* To make it accessible to a user, type: *
+* sudo usermod --append --groups ndpisrvd-distributor [USER] *
+* *
+* Please not that you might need to re-login to make changes take effect. *
+**********************************************************************************
+EOF
diff --git a/packages/debian/prerm b/packages/debian/prerm
new file mode 100755
index 000000000..6942225bd
--- /dev/null
+++ b/packages/debian/prerm
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+systemctl stop ndpisrvd.service
diff --git a/packages/systemd/default.cfg b/packages/systemd/default.cfg
deleted file mode 100644
index 8598da168..000000000
--- a/packages/systemd/default.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-COLLECTOR_PATH=/var/run/ndpisrvd-collector
-NDPID_ARGS="-A -z"
diff --git a/packages/systemd/ndpid@.service.in b/packages/systemd/ndpid@.service.in
index cfbb4110f..b59a6612c 100644
--- a/packages/systemd/ndpid@.service.in
+++ b/packages/systemd/ndpid@.service.in
@@ -5,10 +5,9 @@ Requires=ndpisrvd.service
[Service]
Type=simple
-ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/nDPId $NDPID_ARGS -i %i -c ${COLLECTOR_PATH}
+ExecStartPre=/bin/sh -c 'test -r "@CMAKE_INSTALL_PREFIX@/etc/nDPId/%i.conf" || cp -v "@CMAKE_INSTALL_PREFIX@/share/nDPId/ndpid.conf.example" "@CMAKE_INSTALL_PREFIX@/etc/nDPId/%i.conf"'
+ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/nDPId -f @CMAKE_INSTALL_PREFIX@/etc/nDPId/%i.conf -i %i -u ndpid -c /run/nDPIsrvd/collector
Restart=on-failure
-Environment=COLLECTOR_PATH=/var/run/ndpisrvd-collector NDPID_ARGS="-A -z"
-EnvironmentFile=@CMAKE_INSTALL_PREFIX@/etc/default/ndpid
[Install]
WantedBy=multi-user.target
diff --git a/packages/systemd/ndpisrvd.service.in b/packages/systemd/ndpisrvd.service.in
index 0fd3ba8e7..89f87a682 100644
--- a/packages/systemd/ndpisrvd.service.in
+++ b/packages/systemd/ndpisrvd.service.in
@@ -4,11 +4,10 @@ After=network.target
[Service]
Type=simple
-ExecStart=@CMAKE_INSTALL_PREFIX@/bin/nDPIsrvd -c ${COLLECTOR_PATH}
-ExecStopPost=/bin/rm -f /var/run/ndpisrvd-collector
+ExecStartPre=/bin/sh -c 'test -r "@CMAKE_INSTALL_PREFIX@/etc/nDPId/nDPIsrvd.conf" || cp -v "@CMAKE_INSTALL_PREFIX@/share/nDPId/ndpisrvd.conf.example" "@CMAKE_INSTALL_PREFIX@/etc/nDPId/nDPIsrvd.conf"'
+ExecStartPre=/bin/sh -c 'mkdir -p /run/nDPIsrvd && chown root:root /run/nDPIsrvd && chmod 0775 /run/nDPIsrvd'
+ExecStart=@CMAKE_INSTALL_PREFIX@/bin/nDPIsrvd -f @CMAKE_INSTALL_PREFIX@/etc/nDPId/nDPIsrvd.conf -u ndpisrvd -c /run/nDPIsrvd/collector -s /run/nDPIsrvd/distributor -G ndpid:ndpisrvd-distributor
Restart=on-failure
-Environment=COLLECTOR_PATH=/var/run/ndpisrvd-collector
-EnvironmentFile=@CMAKE_INSTALL_PREFIX@/etc/default/ndpid
[Install]
WantedBy=multi-user.target