diff options
author | Stanislav Sedov <stas@FreeBSD.org> | 2006-11-08 01:06:16 +0000 |
---|---|---|
committer | Stanislav Sedov <stas@FreeBSD.org> | 2006-11-08 01:06:16 +0000 |
commit | a75b9780d304ef57517110e0a4f0d6ccbbebe8f0 (patch) | |
tree | 0038b8d45c1e87da38254388e6e509c3f089adc5 /net-mgmt/flow-tools | |
parent | c2fd546aa9ac21f8e8a073aec314f6b4052b3d71 (diff) | |
download | ports-a75b9780d304ef57517110e0a4f0d6ccbbebe8f0.tar.gz ports-a75b9780d304ef57517110e0a4f0d6ccbbebe8f0.zip |
Notes
Diffstat (limited to 'net-mgmt/flow-tools')
-rw-r--r-- | net-mgmt/flow-tools/Makefile | 21 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/flow_capture.in | 51 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/patch-lib_ftsym.c | 10 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/patch-lib_support.c | 10 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/pkg-deinstall.in | 37 | ||||
-rw-r--r-- | net-mgmt/flow-tools/files/pkg-install.in | 78 |
6 files changed, 206 insertions, 1 deletions
diff --git a/net-mgmt/flow-tools/Makefile b/net-mgmt/flow-tools/Makefile index 323da43942a7..d12a74f95505 100644 --- a/net-mgmt/flow-tools/Makefile +++ b/net-mgmt/flow-tools/Makefile @@ -7,7 +7,7 @@ PORTNAME= flow-tools PORTVERSION= 0.68 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net-mgmt MASTER_SITES= ftp://ftp.eng.oar.net/pub/flow-tools/ @@ -26,6 +26,19 @@ MAN1= flow-capture.1 flow-cat.1 flow-dscan.1 flow-expire.1 \ flow-tag.1 flow-tools.1 flow-tools-examples.1 \ flow-xlate.1 flow-rptfmt.1 flow-log2rrd.1 flow-rpt2rrd.1 +SUB_FILES= pkg-install pkg-deinstall +SUB_LIST= FLOW_CAPTURE_SPOOL="${FLOW_CAPTURE_SPOOL}" \ + FLOW_CAPTURE_USER="${FLOW_CAPTURE_USER}" \ + FLOW_CAPTURE_GROUP="${FLOW_CAPTURE_GROUP}" \ + FLOW_CAPTURE_PIDDIR="${FLOW_CAPTURE_PIDDIR}" +USE_RC_SUBR= flow_capture + +VARDIR?= ${DESTDIR}/var +FLOW_CAPTURE_SPOOL= ${VARDIR}/db/flows +FLOW_CAPTURE_USER= flowtools +FLOW_CAPTURE_GROUP= flowtools +FLOW_CAPTURE_PIDDIR= ${VARDIR}/run/flow-capture + .if defined(WITH_PGSQL) CONFIGURE_ARGS+=--with-pgsql=${PREFIX} USE_PGSQL= yes @@ -42,9 +55,15 @@ post-patch: -e 's|@localstatedir@/cfg/|${PREFIX}/etc/flow-tools/|' \ ${WRKSRC}/docs/flow-*.1.in ${WRKSRC}/docs/flow-*.html.in +pre-su-install: + @${SETENV} ${SCRIPTS_ENV} \ + ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL + post-install: .for I in ${MAN1} ${INSTALL_MAN} ${WRKSRC}/docs/${I} ${PREFIX}/man/man1/ .endfor + @${SETENV} ${SCRIPTS_ENV} \ + ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .include <bsd.port.mk> diff --git a/net-mgmt/flow-tools/files/flow_capture.in b/net-mgmt/flow-tools/files/flow_capture.in new file mode 100644 index 000000000000..f19ebfd05f12 --- /dev/null +++ b/net-mgmt/flow-tools/files/flow_capture.in @@ -0,0 +1,51 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: flow_capture +# REQUIRE: LOGIN +# KEYWORD: shutdown + +# +# Add the following line to /etc/rc.conf to enable flow-capture: +# flow_capture_enable (bool): Set it to "YES" to enable flow-capture daemon. +# Set to "NO" by default. +# flow_tools_datadir (str): Base flow data directory. +# Default is "/var/db/flows" +# flow_tools_datasize (str): Maximum allowed size of the flow data on disk +# Default is "128M" +# flow_capture_localip (str): IP address to bind to +# Default to "0.0.0.0" +# flow_capture_remoteip (str): IP address to accept flows from +# Default to "0.0.0.0" or all IPs +# flow_capture_port (int): Port to accept flow data on +# Default is "8787" +# flow_capture_args (str): Custom additional arguments to be passed +# to flow-collector (default empty). +# + +. /etc/rc.subr + +name="flow_capture" +rcvar=`set_rcvar` + +load_rc_config $name + +: ${flow_capture_enable="NO"} +: ${flow_tools_datadir="%%FLOW_CAPTURE_SPOOL%%"} +: ${flow_tools_datasize="128M"} +: ${flow_capture_localip="0.0.0.0"} +: ${flow_capture_remoteip="0.0.0.0"} +: ${flow_capture_port="8787"} +: ${flow_capture_pid="%%FLOW_CAPTURE_PIDDIR%%/flow-capture.pid"} +: ${flow_capture_user="flowtools"} +: ${flow_capture_group="flowtools"} +: ${flow_capture_args=""} + +pidfile="${flow_capture_pid}.${flow_capture_port}" + +command="%%PREFIX%%/bin/flow-capture" +command_args="${flow_capture_args} -E ${flow_tools_datasize} -w ${flow_tools_datadir} -p ${flow_capture_pid} ${flow_capture_localip}/${flow_capture_remoteip}/${flow_capture_port}" + +run_rc_command "$1" diff --git a/net-mgmt/flow-tools/files/patch-lib_ftsym.c b/net-mgmt/flow-tools/files/patch-lib_ftsym.c new file mode 100644 index 000000000000..dc9d4442cebf --- /dev/null +++ b/net-mgmt/flow-tools/files/patch-lib_ftsym.c @@ -0,0 +1,10 @@ +--- lib/ftsym.c.orig Wed Nov 8 03:51:51 2006 ++++ lib/ftsym.c Wed Nov 8 03:51:56 2006 +@@ -35,6 +35,7 @@ + #include <ctype.h> + #include <stddef.h> + #include <stdlib.h> ++#include <unistd.h> + + #if HAVE_STRINGS_H + #include <strings.h> diff --git a/net-mgmt/flow-tools/files/patch-lib_support.c b/net-mgmt/flow-tools/files/patch-lib_support.c new file mode 100644 index 000000000000..efbe83fd0d43 --- /dev/null +++ b/net-mgmt/flow-tools/files/patch-lib_support.c @@ -0,0 +1,10 @@ +--- lib/support.c.orig Wed Nov 8 03:50:31 2006 ++++ lib/support.c Wed Nov 8 03:51:27 2006 +@@ -40,6 +40,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <syslog.h> ++#include <unistd.h> + #include <time.h> + #include <fcntl.h> + diff --git a/net-mgmt/flow-tools/files/pkg-deinstall.in b/net-mgmt/flow-tools/files/pkg-deinstall.in new file mode 100644 index 000000000000..cbc04bea3005 --- /dev/null +++ b/net-mgmt/flow-tools/files/pkg-deinstall.in @@ -0,0 +1,37 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin + +FLOW_CAPTURE_SPOOL="%%FLOW_CAPTURE_SPOOL%%" +FLOW_CAPTURE_USER="%%FLOW_CAPTURE_USER%%" +FLOW_CAPTURE_GROUP="%%FLOW_CAPTURE_GROUP%%" +FLOW_CAPTURE_PIDDIR="%%FLOW_CAPTURE_PIDDIR%%" + +post-deinstall() { + rmdir ${FLOW_CAPTURE_SPOOL} > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "WARNING: If you will NOT use this package anymore, please" + echo " remove the following directory manually:" + echo " ${FLOW_CAPTURE_SPOOL}" + echo + echo "Also flow-tools related user accounts and groups were not" + echo "removed (${FLOW_CAPTURE_USER}:${FLOW_CAPTURE_GROUP})." + echo "Do it manually, if needed." + echo + fi + +# +# Remove pid directory +# + rm -rf ${FLOW_CAPTURE_PIDDIR} > /dev/null 2>&1 +} + + +case $2 in + POST-DEINSTALL) + post-deinstall + ;; +esac diff --git a/net-mgmt/flow-tools/files/pkg-install.in b/net-mgmt/flow-tools/files/pkg-install.in new file mode 100644 index 000000000000..dc913ca32fd8 --- /dev/null +++ b/net-mgmt/flow-tools/files/pkg-install.in @@ -0,0 +1,78 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin + +FLOW_CAPTURE_SPOOL="%%FLOW_CAPTURE_SPOOL%%" +FLOW_CAPTURE_USER="%%FLOW_CAPTURE_USER%%" +FLOW_CAPTURE_GROUP="%%FLOW_CAPTURE_GROUP%%" +FLOW_CAPTURE_PIDDIR="%%FLOW_CAPTURE_PIDDIR%%" + +if [ -x /usr/sbin/nologin ]; then + NOLOGIN=/usr/sbin/nologin +else + NOLOGIN=/sbin/nologin +fi + +pre-install() { +# +# Create group +# + pw groupshow ${FLOW_CAPTURE_GROUP} > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -n "Creating '${FLOW_CAPTURE_GROUP}' group... " + pw groupadd ${FLOW_CAPTURE_GROUP} -q + + if [ $? -eq 0 ]; then + echo "ok" + else + echo "failed" + echo "Cannot create group '${FLOW_CAPTURE_GROUP}'" >&2 + echo "Please, create it manually." >&2 + exit 1 + fi + else + echo "Using existing group '${FLOW_CAPTURE_GROUP}'" + fi + +# +# Create user +# + pw usershow ${FLOW_CAPTURE_USER} > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -n "Creating '${FLOW_CAPTURE_USER}' user... " + pw useradd -n ${FLOW_CAPTURE_USER} -g ${FLOW_CAPTURE_GROUP} \ + -c "Flow-tools collector pseudo-user" \ + -d "/var/empty" -s "${NOLOGIN}" -h - -q + + if [ $? -eq 0 ]; then + echo "ok" + else + echo "failed" + echo "Cannot create user '${FLOW_CAPTURE_USER}'" >&2 + echo "Please, create it manually." >&2 + exit 1 + fi + else + echo "Using existing group '${FLOW_CAPTURE_USER}'" + fi +} + +post-install() { + /usr/bin/install -d -m 700 -o ${FLOW_CAPTURE_USER} \ + -g ${FLOW_CAPTURE_GROUP} ${FLOW_CAPTURE_PIDDIR} + /usr/bin/install -d -m 1700 -o ${FLOW_CAPTURE_USER} \ + -g ${FLOW_CAPTURE_GROUP} ${FLOW_CAPTURE_SPOOL} +} + + +case $2 in + PRE-INSTALL) + pre-install + ;; + POST-INSTALL) + post-install + ;; +esac |