X-Original-To: alpine-aports@lists.alpinelinux.org Received: from mail.infogroup.kiev.ua (tera.infogroup.kiev.ua [195.144.25.26]) by lists.alpinelinux.org (Postfix) with ESMTP id 77EA45C4900 for ; Wed, 26 Apr 2017 13:04:20 +0000 (GMT) Received: from ost.org.ua ([195.144.25.230] helo=alpine.ost.org.ua) by mail.infogroup.kiev.ua with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80.1) (envelope-from ) id 1d3McG-0004At-AU for alpine-aports@lists.alpinelinux.org; Wed, 26 Apr 2017 16:04:20 +0300 From: Valery Kartel To: alpine-aports@lists.alpinelinux.org Subject: [alpine-aports] [PATCH v3] testing/flow-tools: new aport Date: Wed, 26 Apr 2017 16:04:20 +0300 Message-Id: <20170426130420.20396-1-valery.kartel@gmail.com> X-Mailer: git-send-email 2.12.2 Sender: droid@infogroup.kiev.ua X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: Tool set for working with NetFlow data https://code.google.com/p/flow-tools --- v1 -> v2: split to subpackages v2 -> v3: fix and improve $command_args in init-script --- testing/flow-tools/APKBUILD | 106 ++++++++++++++++++++++++++++ testing/flow-tools/flow-capture.confd | 33 +++++++++ testing/flow-tools/flow-capture.initd | 18 +++++ testing/flow-tools/flow-capture.pre-install | 6 ++ 4 files changed, 163 insertions(+) create mode 100644 testing/flow-tools/APKBUILD create mode 100644 testing/flow-tools/flow-capture.confd create mode 100644 testing/flow-tools/flow-capture.initd create mode 100644 testing/flow-tools/flow-capture.pre-install diff --git a/testing/flow-tools/APKBUILD b/testing/flow-tools/APKBUILD new file mode 100644 index 0000000000..4d6c222889 --- /dev/null +++ b/testing/flow-tools/APKBUILD @@ -0,0 +1,106 @@ +# Contributor: Valery Kartel +# Maintainer: Valery Kartel +pkgname=flow-tools +pkgver=0.68.5.1 +pkgrel=0 +_pkgreal=flow +pkgdesc="Tool set for working with NetFlow data" +url="https://code.google.com/p/flow-tools" +arch="all" +license="BSD" +options="!check" +install="$_pkgreal-capture.pre-install" +pkgusers=$_pkgreal +pkggroups=$_pkgreal +depends_dev="perl" +makedepends="zlib-dev" +subpackages="$pkgname-doc libft-dev libft:libs + $_pkgreal-capture $_pkgreal-log2rrd::noarch + $_pkgreal-rptfmt::noarch $_pkgreal-rpt2rrd::noarch + " +_tools="cat dscan expire export fanout filter gen header import + mask merge nfilter print receive report send split stat tag xlate" +_tools_list="$_pkgreal-capture" +for _tool in $_tools; do + subpackages="$subpackages $_pkgreal-$_tool:_tool" + _tools_list="$_tools_list $_pkgreal-$_tool" +done +source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname-$pkgver.tar.bz2 + $_pkgreal-capture.initd + $_pkgreal-capture.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/$_pkgreal:" $file || return 1 + done + update_config_sub +} + +build() { + cd "$builddir" + ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --target=$CTARGET \ + --prefix=/usr \ + --sysconfdir=/etc/$_pkgreal \ + --localstatedir=/var/lib/$_pkgreal \ + || return 1 + make +} + +package() { + depends=$_tools_list + make -C "$builddir" DESTDIR="$pkgdir" install +} + +dev() { + default_dev || return 1 + + mkdir -p "$subpkgdir"/usr || return 1 + mv "$pkgdir"/usr/share "$subpkgdir"/usr || return 1 +} + +libs() { + default_libs || return 1 + mv "$pkgdir"/etc "$subpkgdir" || return 1 +} + +_tool() { + pkgdesc="$pkgdesc (${subpkgname#$_pkgreal-} tool)" + mkdir -p "$subpkgdir"/usr/bin || return 1 + mv "$pkgdir"/usr/bin/$subpkgname "$subpkgdir"/usr/bin || return 1 +} + +capture() { + _tool || return 1 + install -Dm644 "$srcdir"/$subpkgname.confd \ + "$subpkgdir"/etc/conf.d/$subpkgname || return 1 + install -Dm755 "$srcdir"/$subpkgname.initd \ + "$subpkgdir"/etc/init.d/$subpkgname || return 1 + install -Dm750 -o $_pkgreal -g $_pkgreal -d "$subpkgdir"/var/lib/$_pkgreal +} + +rptfmt() { + _tool || return 1 + depends="python2" +} + +rpt2rrd() { + _tool || return 1 + depends="python2 py-rrd" +} + +log2rrd() { + _tool || return 1 + depends="python2 py-rrd" +} + +sha512sums="ae17ba39854daa8ef3deecd3a554bb6d1fa47648cb791d8225a40bec13f65bf0692871660b2c3490d133b1251875c323d066bb0c0483eceb0707cec9b7714c57 flow-tools-0.68.5.1.tar.bz2 +3692d8ae28de6b7aea65714ba66f7f561a0f40500dc79804f02d631c1eb2ba72caf97018a08b3e1ee89c1df1f1e50c845646911224299871d208af9254db4200 flow-capture.initd +1716f9dfc8ac23aedce95cc692f18f4b17865748aa63780347b94eb8fbc78f6509a66438bd07fa9e0871bba05f03a129ef084615533d513b625320f3eb3bb373 flow-capture.confd" diff --git a/testing/flow-tools/flow-capture.confd b/testing/flow-tools/flow-capture.confd new file mode 100644 index 0000000000..8b40f7bcae --- /dev/null +++ b/testing/flow-tools/flow-capture.confd @@ -0,0 +1,33 @@ +# port to listen on +#FLOW_PORT=2055 + +# 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 + +# dir we will be saving flows and working in +#FLOW_WORKDIR=/var/lib/flow + +# user to run as +#FLOW_USER=flow + +# This is the default and should be left unless you know what you are doing +#FLOW_VER=5 + +# 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" + +#FLOW_ARGS= diff --git a/testing/flow-tools/flow-capture.initd b/testing/flow-tools/flow-capture.initd new file mode 100644 index 0000000000..5dfdddff7c --- /dev/null +++ b/testing/flow-tools/flow-capture.initd @@ -0,0 +1,18 @@ +#!/sbin/openrc-run + +name="NetFlow capture" +command=/usr/bin/flow-capture +command_args="$FLOW_ARGS \ + ${FLOW_VER:+-V $FLOW_VER} \ + ${FLOW_NEST:+-N $FLOW_NEST} \ + ${FLOW_SIZE:+-E $FLOW_SIZE} \ + ${FLOW_ROTATIONS:+-n $FLOW_ROTATIONS} \ + ${FLOW_ROTATE_PROG:+-R $FLOW_ROTATE_PROG} \ + -D -w ${FLOW_WORKDIR:-/var/lib/flow} ${FLOW_LOCAL_IP:-0}/${FLOW_REMOTE_IP:-0}/${FLOW_PORT:-2055}" +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-capture.pre-install b/testing/flow-tools/flow-capture.pre-install new file mode 100644 index 0000000000..316e61ba4f --- /dev/null +++ b/testing/flow-tools/flow-capture.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: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---