File ourmon.spec of Package ourmon

#
# spec file for package ourmon
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

Name:           ourmon
Summary:        Network monitoring and anomaly detection system
Version:        2.9
Release:        1
Url:            http://ourmon.sourceforge.net/
License:        BSD
Group:          System/Monitoring
Source0:        ourmon29.tar.bz2 
Source1:        ourmon-rpmlintrc
Patch1:         ourmon-libJudy.patch
Patch2:         ourmon-web.code-destdir.patch
BuildRequires:  gcc-c++
BuildRequires:  pcre-devel
BuildRequires:  libpcap-devel
BuildRequires:  Judy-devel
BuildRequires:  Judy-static
BuildRequires:  rrdtool-devel
BuildRequires:	gd-devel
BuildRequires:  libpng-devel
BuildRequires:  zlib-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         webdir %{_datadir}/%{name}

%description
Ourmon is a network monitoring and anomaly detection system and displays the
data for multiple BPF expressions via RRDTOOL-based graphs. It also helps the
user identify various kinds of network anomalies using various flow analysis
tools and logging.


%package backend
Summary:		Package sniffer and rrdtool part
Group:			System/Monitoring
Requires:		rrdtool
Requires:    	libpcap
Requires:		pcre
Requires:     	bind-utils

%description backend
This package contains the sniffer, back-end perl code and drawtopn program 
that can be run on a powerful machine.

%package frontend
Summary: 		Webfrontend for ourmon
Group:			System/Monitoring
Requires:		apache2

%description frontend
This package contains the web pages showing the results of the monitoring.


%prep
%setup -q -n mrourmon 
%patch1 -p1
%patch2 -p1

%build
export CFLAGS="%{optflags}"
export LFLAGS="%{optflags}"
pushd src/ircfr
	make -f Makefile.linux
popd
pushd src/ourmon
	make -f Makefile.linux
popd
pushd src/web.code
	make drawbar LIBS="-lgd -lpng -lz" WEBDIR="%{webdir}" BINDIR="%{_bindir}"
popd


%install
mkdir -p %{buildroot}/%{_var}/log/%{name}
mkdir -p %{buildroot}/%{_sysconfdir}/%{name}
mkdir -p %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/%{_var}/lib/%{name}/{rrddata,ircfr}
mkdir -p %{buildroot}/%{webdir}
# ircfr
install -m755 src/ircfr/ircfr %{buildroot}/%{_bindir}/
sed -e "s|/usr/dumps/ircfr|%{_var}/lib/%{name}/ircfr|g; \
		s|/home/mrourmon/bin/ircfr|%{_bindir}/ircfr|g" src/ircfr/ircfr.sh \
		> %{buildroot}/%{_bindir}/ircfr.sh
# ourmon
install -m755 src/ourmon/ourmon  %{buildroot}/%{_bindir}/
cat >> %{buildroot}/%{_bindir}/ourmon.sh << EOF
#!/bin/bash
%{_bindir}/ourmon -d -D %{_var}/lib/%{name}/foo -r ./dns.dmp  -s 256 -f %{_sysconfdir}/%{name}/ourmon.conf &
EOF
# scripts
pushd scripts
for file in $(find -type f); do
	targetfile=$(basename $file)
	case $targetfile in 
	README)
	;;
	*)
		sed -e "s|/usr/local/bin|%{_bindir}|g; \
				s|/home/mrourmon/etc|%{_sysconfdir}/%{name}|g; \
				s|/home/mrourmon/bin|%{_bindir}|g" $file > %{buildroot}/%{_bindir}/$targetfile
	;;
	esac
done
popd
# web.code
pushd src/web.code
make -f Makefile install DESTDIR="%{buildroot}" BINDIR="%{_bindir}" WEBDIR="%{webdir}"
popd
# web.html
cp -r src/web.html/* %{buildroot}/%{webdir}/
# config
cp -r etc/*.conf etc/*.txt %{buildroot}/%{_sysconfdir}/%{name}/

%clean
rm -rf %buildroot

%files 
%defattr(-,root,root)
%doc INSTALL README ACKS CHANGES VERSION
%dir %{_sysconfdir}/%{name}/
%config(noreplace) %{_sysconfdir}/%{name}/*

%files backend
%defattr(-,root,root)
%dir %{_var}/log/%{name}
%dir %{_var}/lib/%{name}
%dir %{_var}/lib/%{name}/ircfr
%dir %{_var}/lib/%{name}/rrddata
%{_bindir}/*

%files frontend
%defattr(-,root,root)
%dir %{webdir}
%{webdir}/*

%changelog