File nrpe.spec of Package nrpe

%define name nrpe
%define version 2.12
%define release 1
%define nsusr nagios
%define nsgrp nagios
%define nsport 5666

# Reserve option to override port setting with:
# rpm -ba|--rebuild --define 'nsport 5666'
%{?port:%define nsport %{port}}

# Macro that print mesages to syslog at package (un)install time
%define nnmmsg logger -t %{name}/rpm

Summary: Host/service/network monitoring agent for Nagios
URL: http://www.nagios.org
Name: %{name}
Version: %{version}
Release: %{release}
License: GPL
Group: Application/System
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
Requires: bash, grep, nagios-plugins, openssl, xinetd
BuildRequires: openssl-devel, xinetd
PreReq: /usr/bin/logger, sh-utils, shadow-utils, sed, fileutils, mktemp

%description
Nrpe is a system daemon that will execute various Nagios plugins
locally on behalf of a remote (monitoring) host that uses the
check_nrpe plugin.  Various plugins that can be executed by the 
daemon are available at:
http://sourceforge.net/projects/nagiosplug

This package provides the core agent.

%prep
%setup -q

%pre
# Create `nagios' group on the system if necessary
if grep ^nagios: /etc/group; then
	: # group already exists
else
	/usr/sbin/groupadd %{nsgrp} || %nnmmsg Unexpected error adding group "%{nsgrp}". Aborting install process.
fi

# Create `nagios' user on the system if necessary
if id %{nsusr} ; then
	: # user already exists
else
	/usr/sbin/useradd -r -s /bin/sh -c "%{nsusr}" -g %{nsgrp} %{nsusr} || \
		%nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
fi

# Add services entry if there in none yet.
if grep -E "^nrpe[[:blank:]]+%{nsport}/tcp.*$" /etc/services; then
	: # service entry already exists
else
	echo -e "\nnrpe\t\t%{nsport}/tcp # NRPE daemon" >> /etc/services
fi

%build
export PATH=$PATH:/usr/sbin
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
./configure --prefix=%{_prefix} \
  --libexecdir=%{_prefix}/nagios/libexec
make nrpe

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
/usr/bin/install -c -m 775 -d ${RPM_BUILD_ROOT}/usr/nagios/bin
/usr/bin/install -c -m 775 src/nrpe ${RPM_BUILD_ROOT}/usr/nagios/bin
/usr/bin/install -c -m 775 -d ${RPM_BUILD_ROOT}/usr/nagios/etc
/usr/bin/install -c -m 644 sample-config/nrpe.cfg ${RPM_BUILD_ROOT}/usr/nagios/etc
/usr/bin/install -c -m 775 -d ${RPM_BUILD_ROOT}/etc/xinetd.d
/usr/bin/install -c -m 644 sample-config/nrpe.xinetd ${RPM_BUILD_ROOT}/etc/xinetd.d/nrpe 

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(755,root,root)
/etc/xinetd.d/nrpe
%{_prefix}/nagios/etc/nrpe.cfg
%defattr(755,%{nsusr},%{nsgrp})
%{_prefix}/nagios/bin/nrpe
%doc Changelog LEGAL README 

%changelog
* Mon Jan 23 2006 Andreas Kasenides ank<@>cs.ucy.ac.cy
- fixed nrpe.cfg relocation to sample-config
- replaced Copyright label with License
- added --enable-command-args to enable remote arg passing (if desired can be disabled by commenting out)

* Wed Nov 12 2003 Ingimar Robertsson <iar@skyrr.is>
- Added adding of nagios group if it does not exist.

* Tue Jan 07 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
- Removed the lines which removed the nagios user and group from the system
- changed the patch release version from 3 to 1

* Mon Jan 06 2003 James 'Showkilr' Peterson <showkilr@showkilr.com>
- Removed patch files required for nrpe 1.5
- Update spec file for version 1.6 (1.6-1)

* Sat Dec 28 2002 James 'Showkilr' Peterson <showkilr@showkilr.com>
- First RPM build (1.5-1)
openSUSE Build Service is sponsored by