Subject: [alpine-aports] [PATCH] testing/flow-tools: new aport

From: Valery Kartel <[email-masked]>
Date: Tue, 25 Apr 2017 17:01:24 +0300

Tool set for working with NetFlow data
https://code.google.com/p/flow-tools
---
 testing/flow-tools/APKBUILD               | 71 +++++++++++++++++++++++++++++++
 testing/flow-tools/flow-tools.confd       | 25 +++++++++++
 testing/flow-tools/flow-tools.initd       | 17 ++++++++
 testing/flow-tools/flow-tools.pre-install |  6 +++
 4 files changed, 119 insertions(+)
 create mode 100644 testing/flow-tools/APKBUILD
 create mode 100644 testing/flow-tools/flow-tools.confd
 create mode 100644 testing/flow-tools/flow-tools.initd
 create mode 100644 testing/flow-tools/flow-tools.pre-install

diff --git a/testing/flow-tools/APKBUILD b/testing/flow-tools/APKBUILD
new file mode 100644
index 0000000000..694214af83
--- /dev/null
+++ b/testing/flow-tools/APKBUILD
@@ -0,0 +1,71 @@
+# Contributor: Valery Kartel <[email-masked]>
+# Maintainer: Valery Kartel <[email-masked]>
+pkgname=flow-tools
+pkgver=0.68.5.1
+pkgrel=0
+_flow=flow
+pkgdesc="Tool set for working with NetFlow data"
+url="https://code.google.com/p/flow-tools"
+arch="all"
+license="BSD"
+options="!check"
+install="$pkgname.pre-install"
+pkgusers=$_flow
+pkggroups=$_flow
+makedepends="zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-rpt::noarch"
+source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname-$pkgver.tar.bz2
+	$pkgname.initd
+	$pkgname.confd"
+builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+	default_prepare || return 1
+
+	cd "$builddir"
+	local file
+	for file in bin/flow-rpt*; do
+		sed -i -e "s:/usr/local/netflow/var:/etc/$_flow:" $file || return 1
+	done
+	update_config_sub
+}
+
+build() {
+	cd "$builddir"
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--target=$CTARGET \
+		--prefix=/usr \
+		--sysconfdir=/etc/$_flow \
+		--localstatedir=/var/lib/$_flow \
+		|| return 1
+	make
+}
+
+package() {
+	make -C "$builddir" DESTDIR="$pkgdir" install || return 1
+	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/flow-capture || return 1
+	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/flow-capture || return 1
+	install -Dm750 -o flow -g flow -d "$pkgdir"/var/lib/$_flow
+}
+
+dev() {
+	default_dev || return 1
+
+	mkdir -p "$subpkgdir"/usr/share || return 1
+	mv "$pkgdir"/usr/share/$pkgname "$subpkgdir"/usr/share
+}
+
+rpt() {
+	depends="python2 py-rrd"
+	pkgdesc="$pkgdesc (flow-report and log converters)"
+	mkdir -p "$subpkgdir"/usr/bin || return 1
+	mv "$pkgdir"/usr/bin/flow-rpt* \
+		"$pkgdir"/usr/bin/flow-log2rrd \
+		"$subpkgdir"/usr/bin
+}
+
+sha512sums="ae17ba39854daa8ef3deecd3a554bb6d1fa47648cb791d8225a40bec13f65bf0692871660b2c3490d133b1251875c323d066bb0c0483eceb0707cec9b7714c57  flow-tools-0.68.5.1.tar.bz2
+ad915948b17cbf5c175b618840ce57b8885b687bf742a90fa2e879f0828c32b689fff54f04bb3d792e2733a6b8d90ffda17a9b1249dbabad03b8a973d0558f93  flow-tools.initd
+0e7e754bd450b9a8cb4e167cd7192e7240058a3d70fed465e2db14477989f1e5776b3420ac577172ff08e052935a6f58c3984c51770cf898f0c8ece5119f61dc  flow-tools.confd"
diff --git a/testing/flow-tools/flow-tools.confd b/testing/flow-tools/flow-tools.confd
new file mode 100644
index 0000000000..fd0c13c0be
--- /dev/null
+++ b/testing/flow-tools/flow-tools.confd
@@ -0,0 +1,25 @@
+# This is the default and should be left unless you know what you are doing
+#FLOW_VER=5
+
+# local ip. if configured flow-capture will only ps flows sent to this ip.
+#FLOW_LOCAL_IP=0
+
+# remote ip. If this is configured only flows from this exporter will be accepted
+# by default we will accept any flows sent to us
+#FLOW_REMOTE_IP=0
+
+# port to listen on
+#FLOW_PORT=2055
+
+# You probably don't want to change this, but in case you do - nest level
+#FLOW_NEST=0
+
+# Retain the maximum number of files so that the total storage is less than SIZE
+# The letters b,K,M,G can be used as multipliers, ie 16 Megabytes is 16M.
+#FLOW_SIZE=1G
+
+# number of rotations per day
+#FLOW_ROTATIONS=287
+
+# program used to rotate 
+#FLOW_ROTATE_PROG="/var/lib/flow/rotate.sh"
diff --git a/testing/flow-tools/flow-tools.initd b/testing/flow-tools/flow-tools.initd
new file mode 100644
index 0000000000..7abb2c34d4
--- /dev/null
+++ b/testing/flow-tools/flow-tools.initd
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+
+name="NetFlow capture"
+command=/usr/bin/flow-capture
+command_args="-D -w ${FLOW_WORKDIR:-/var/lib/flow} ${FLOW_LOCAL_IP:-0}/${FLOW_REMOTE_IP:-0}/${FLOW_PORT:-2055} $FLOW_ARGS"
+command_args="$command_args${FLOW_VER:+ -V $FLOW_VER}"
+command_args="$command_args${FLOW_NEST:+ -N $FLOW_NEST}"
+command_args="$command_args${FLOW_SIZE:+ -E $FLOW_SIZE}"
+command_args="$command_args${FLOW_ROTATIONS:+ -n $FLOW_ROTATIONS}"
+command_args="$command_args${FLOW_ROTATE_PROG:+ -R $FLOW_ROTATE_PROG}"
+command_background=yes
+pidfile=/run/$RC_SVCNAME.pid
+start_stop_daemon_args="-u ${FLOW_USER:-flow}"
+
+depend() {
+	need net localmount
+}
diff --git a/testing/flow-tools/flow-tools.pre-install b/testing/flow-tools/flow-tools.pre-install
new file mode 100644
index 0000000000..316e61ba4f
--- /dev/null
+++ b/testing/flow-tools/flow-tools.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S flow 2>/dev/null
+adduser -S -D -H -h /var/lib/flow -s /sbin/nologin -G flow -g flow flow 2>/dev/null
+
+exit 0
-- 
2.12.2

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---