[netflow-tools] Building a softflowd RPM

Steve Snodgrass ssnodgra at pheran.com
Sat Mar 4 09:55:58 EST 2006


I've included several files that enable one to build an RPM package of
softflowd.  This is intended for Red Hat (i.e. Fedora Core and RHEL) systems
but could be ported to any RPM-based system without too much trouble.

The attached files are:

softflowd.spec - the RPM spec file
softflowd.init - an init script for starting/stopping softflowd
softflowd.sysconfig - a config file that sets options for softflowd

This RPM also makes use of the DESTDIR and ICMP patches I submitted in my
previous email.  The ICMP patch is optional and could be removed, but the
DESTDIR patch is needed to successfully build the RPM.

I could make a full source RPM available if there's demand for it.

-- 
Steve Snodgrass * ssnodgra at pheran.com * Network and Unix Guru(?) at Large
Geek Code: GCS d? s: a C++ U++++$ P+++ L++ w PS+ 5++ b++ DI+ D++ e++ r+++ y+*
"If you want to be somebody else, change your mind."  -Sister Hazel
-------------- next part --------------
# $Id: softflowd.spec,v 1.4 2006/03/03 21:39:09 ssnodgra_dev Exp $

# Figure out release tag (e.g. rhel3, fc1) based on redhat-release file
%global _RHTAG %(sed 's/(.*)//;s/ [A-Z]* //;s/[a-z ]*//g' /etc/redhat-release | tr '[:upper:]' '[:lower:]')

Name: softflowd
Summary: Network traffic analyser capable of Cisco NetFlow data export
Version: 0.9.7
Release: 4.%{_RHTAG}
Source: softflowd-%{version}.tar.gz
Group: System/Utilities
License: BSD
BuildRoot: %{_tmppath}/%{name}-root
URL: http://www.mindrot.org/softflowd.html
Vendor: mindrot.org
Patch0: destdir.patch
Patch1: icmp.patch

%description
softflowd is a software implementation of a flow-based network traffic
monitor.  softflowd reads network traffic and gathers information about
active traffic flows.  A "traffic flow" is communication between two IP
addresses or (if the overlying protocol is TCP or UDP) address/port tuples.
The intended use of softflowd is as a software implementation of Cisco?s
NetFlow traffic account system.  softflowd supports data export using
versions 1, 5 or 9 of the NetFlow protocol.

%prep
%setup
%patch0 -p1
%patch1 -p1

%build
%configure
make

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
cp %_sourcedir/softflowd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/softflowd
cp %_sourcedir/softflowd.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/softflowd

%files
%defattr(-,root,root)
/usr/sbin/*
/usr/share/man/*
%attr(0755,root,root) /etc/rc.d/init.d/softflowd
%config(noreplace) %attr(0644,root,root) /etc/sysconfig/softflowd
%doc ChangeLog README TODO

%clean
rm -rf $RPM_BUILD_ROOT
-------------- next part --------------
#!/bin/bash
#
# softflowd	Starts softflowd NetFlow probe
# $Id: softflowd.init,v 1.2 2006/02/15 21:42:04 ssnodgra_dev Exp $
#
# chkconfig: 2345 95 02
# description: Starts and stops the softflowd Netflow probe

# Source function library.
. /etc/init.d/functions

SOFTFLOW_CONF=/etc/sysconfig/softflowd
SOFTFLOW_LOCK=/var/lock/subsys/softflowd
SOFTFLOW_PROG=/usr/sbin/softflowd
SOFTFLOW_OPTS="-i eth0"

# Source config
if [ -f $SOFTFLOW_CONF ]; then
    . $SOFTFLOW_CONF
fi

[ -x $SOFTFLOW_PROG ] || exit 0

RETVAL=0

start() {
    echo -n $"Starting softflowd: "
    daemon $SOFTFLOW_PROG $SOFTFLOW_OPTS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $SOFTFLOW_LOCK
    return $RETVAL
}
stop() {
    echo -n $"Shutting down softflowd: "
    killproc $SOFTFLOW_PROG
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $SOFTFLOW_LOCK
    return $RETVAL
}
restart() {
    stop
    start
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status $SOFTFLOW_PROG
	;;
    restart|reload)
	restart
	;;
    condrestart)
	[ -f $SOFTFLOW_LOCK ] && restart || :
	;;
    *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
	exit 1
esac

exit $?
-------------- next part --------------
# Config file for softflowd startup

# Location of softflowd binary
#SOFTFLOW_PROG=/usr/sbin/softflowd

# Options passed to the softflowd program
# Default - not very useful
#SOFTFLOW_OPTS="-i eth0"
# Example NetFlow v5 export from traffic on eth1
#SOFTFLOW_OPTS="-v 5 -i eth1 -n hostname:2055"


More information about the netflow-tools mailing list