#
# $Id$
#
# $Id: configure.in,v 1.33 2008/02/08 15:10:17 adeniz Exp $
#
# autoconf input for the MicroNeil @PACKAGE_NAME@ distribution.
#
# Author: Alban Deniz
#
# Copyright (C) 2012 ARM Research Labs, LLC.
# See www.armresearch.com for the copyright terms.
#
#############################################################################

# Look for sources in this directory.
%define _sourcedir @abs_srcdir@/

# Build in this directory 
%define _builddir @abs_srcdir@/

# Create the source RPM in this directory.
%define _srcrpmdir @abs_srcdir@/

# Create the binary RPM in this directory.
%define _rpmdir @abs_srcdir@/

# Test install in this directory.
BuildRoot: @abs_srcdir@/scratch/

# Required items.
Name: @PACKAGE_NAME@
Version: @VERSION@
Release: 1
License: Artistic
Group: System Environment/Daemons
Summary: ARM Research Labs Sniffer.

%define manifest %{_builddir}/%{name}-%{version}-%{release}.manifest

# Optional items.
Vendor: ARM Research Labs, Inc.
URL: http://www.armresearch.com/

# Source.
Source: @PACKAGE_NAME@-@VERSION@.tar.gz

# Dependencies.
Requires(pre): shadow-utils

Requires: curl

BuildRequires: curl

Provides: snf-engine

%description
@PACKAGE_NAME@ is a plug-in for an MTA (Mail Transport Agent, such as
sendmail or postfix) that does spam detection and IP address scanning.
@PACKAGE_NAME@ must be configured after installation to work with an
MTA.

%group Applications/Communications

%prep
%setup -q -n @PACKAGE_NAME@-@VERSION@

%build
%configure                              \
	--enable-os-type=@SNF_OSTYPE@   \
	--sysconfdir=/etc               \
	--prefix=/usr

make

%pre

# Create the snfuser user and group.
getent group snfuser > /dev/null || /usr/sbin/groupadd -r snfuser
getent passwd snfuser > /dev/null || \
       /usr/sbin/useradd -r -g snfuser -s /sbin/nologin \
       			 -c "Sniffer Account" snfuser
exit 0

%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install

%post
# Configure with testmode rulebase, no integration.
/usr/sbin/SNFServerConfig -setup

# Add the SFServer service.
/sbin/chkconfig --add snf-server
/sbin/chkconfig snf-server on

# Start the service.
/sbin/service snf-server start

%preun
# Stop the service if it is running.
/sbin/service snf-server status | grep running > /dev/null 2>&1
if [ $? == 0 ]; then
   /sbin/service snf-server stop
fi

# Remove the service.
/sbin/chkconfig --del snf-server

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)

%{_sbindir}/SNF2Check
%{_sbindir}/SNFClient
%{_sbindir}/getRulebase.sample
%{_sbindir}/SNFServer
%{_sbindir}/SNFDebugServer
%{_sbindir}/SNFServerConfig
%{_sbindir}/SNFDebugServerConfig
%{_sbindir}/snfSniffer.sample
%{_sbindir}/snfSnifferFilter.sample
%{_sbindir}/snfscan-standalone.sample

%doc %{_datadir}/doc/snf-server/COPYING
%doc %{_datadir}/doc/snf-server/INSTALL
%doc %{_datadir}/doc/snf-server/BUGS
%doc %{_datadir}/doc/snf-server/TODO
%doc %{_datadir}/doc/snf-server/ChangeLog
%doc %{_datadir}/doc/snf-server/README
%doc %{_datadir}/doc/snf-server/DebugMode_readme.txt
%doc %{_datadir}/doc/snf-server/SNFClient_readme.txt
%doc %{_datadir}/doc/snf-server/SNFServer_readme.txt
%doc %{_datadir}/doc/snf-server/snf_xci.xml

%{_sysconfdir}/init.d/snf-server

%defattr(-,snfuser,snfuser)
%dir %{_datadir}/@PACKAGE_NAME@
%attr(777,snfuser,snfuser) %{_datadir}/@PACKAGE_NAME@
%{_datadir}/@PACKAGE_NAME@/junkmsg.txt
%{_datadir}/@PACKAGE_NAME@/cleanmsg.txt
%{_datadir}/@PACKAGE_NAME@/testmode.snf
%{_datadir}/@PACKAGE_NAME@/GBUdbIgnoreList.txt.sample

%dir %{_sysconfdir}/@PACKAGE_NAME@
%config %{_sysconfdir}/@PACKAGE_NAME@/SNFServer.xml.sample
%config %{_sysconfdir}/@PACKAGE_NAME@/identity.xml.sample

%changelog
* Sat Jan 05 2013 Alban Deniz - 3.0.14-1
- Initial version, copied from snf-milter.spec.
