summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVjaceslavs Klimovs <vklimovs@gmail.com>2020-08-13 21:32:18 -0700
committerSam James <sam@gentoo.org>2021-03-15 21:03:37 +0000
commit6dace4048ed813d3811cdb8d325fd4519c117753 (patch)
treec38615ea3f0c05d9a25c189684a1bfa572f47544 /net-analyzer/nfdump/files
parentnet-analyzer/hydra: drop obsolete USE=ncp (diff)
downloadgentoo-6dace4048ed813d3811cdb8d325fd4519c117753.tar.gz
gentoo-6dace4048ed813d3811cdb8d325fd4519c117753.tar.bz2
gentoo-6dace4048ed813d3811cdb8d325fd4519c117753.zip
net-analyzer/nfdump: add use flags and init scripts for nfcapd
Closes: https://bugs.gentoo.org/712590 Signed-off-by: Vjaceslavs Klimovs <vklimovs@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'net-analyzer/nfdump/files')
-rw-r--r--net-analyzer/nfdump/files/nfcapd.confd11
-rw-r--r--net-analyzer/nfdump/files/nfcapd.initd60
2 files changed, 71 insertions, 0 deletions
diff --git a/net-analyzer/nfdump/files/nfcapd.confd b/net-analyzer/nfdump/files/nfcapd.confd
new file mode 100644
index 000000000000..28ea35fd0741
--- /dev/null
+++ b/net-analyzer/nfdump/files/nfcapd.confd
@@ -0,0 +1,11 @@
+#shellcheck shell=sh
+#shellcheck disable=SC2034
+
+#port number to listen on
+#PORT="2055"
+
+#maximum size of collected files
+#MAX_SIZE="1G"
+
+#enable sending of all received packets to specified address
+#REPEAT_TO="192.168.1.1/60062"
diff --git a/net-analyzer/nfdump/files/nfcapd.initd b/net-analyzer/nfdump/files/nfcapd.initd
new file mode 100644
index 000000000000..98d388cb710f
--- /dev/null
+++ b/net-analyzer/nfdump/files/nfcapd.initd
@@ -0,0 +1,60 @@
+#!/sbin/openrc-run
+#shellcheck shell=sh
+
+IDENT="${RC_SVCNAME#*.}"
+PIDFILE="/run/nfcapd/${IDENT}.pid"
+USER="nfcapd"
+GROUP="nfcapd"
+
+ssd_start(){
+ if [ -n "${MAX_SIZE}" ]; then
+ set -- "$@" -e
+ fi
+ if [ -n "${PORT}" ]; then
+ set -- "$@" -p "${PORT}"
+ fi
+ if [ -n "${REPEAT_TO}" ]; then
+ set -- "$@" -R "${REPEAT_TO}"
+ fi
+ start-stop-daemon "$@"
+}
+
+checkconfig() {
+ if [ "${IDENT}" = "${RC_SVCNAME}" ]; then
+ eerror "You have to create an init script for each ident:"
+ eerror " cd /etc/init.d/; ln -s nfcapd nfcapd.ident"
+ return 1
+ fi
+}
+
+depend() {
+ need net
+}
+
+start() {
+ checkconfig || return 1
+
+ checkpath -d -m 0750 -o nfcapd:nfcapd /run/nfcapd
+ checkpath -d -m 0750 -o nfcapd:nfcapd /var/tmp/nfcapd/"${IDENT}"
+
+ if [ -n "${MAX_SIZE}" ]; then
+ nfexpire -u /var/tmp/nfcapd/"${IDENT}" -s "${MAX_SIZE}" \
+ > /dev/null 2>&1
+ chown -R ${USER}:${GROUP} /var/tmp/nfcapd/"${IDENT}"
+ fi
+
+ ebegin "Starting ${RC_SVCNAME}"
+ ssd_start --start --quiet --exec /usr/bin/nfcapd \
+ --pidfile "${PIDFILE}" -- -D -P "${PIDFILE}" -u ${USER} \
+ -g ${GROUP} -I "${IDENT}" -l /var/tmp/nfcapd/"${IDENT}"
+ eend $?
+}
+
+stop() {
+ checkconfig || return 1
+
+ ebegin "Stopping ${RC_SVCNAME}"
+ start-stop-daemon --stop --exec /usr/bin/nfcapd \
+ --pidfile "${PIDFILE}"
+ eend $?
+}