##
## nagios.spec -- OpenPKG RPM Package Specification
## Copyright (c) 2000-2006 OpenPKG Foundation e.V.
## Copyright (c) 2000-2006 Ralf S. Engelschall
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
# package versions
%define V_nagios 1.3
%define V_nagios_plugins 1.4.2
# package information
Name: nagios
Summary: System and Network Monitoring
URL: http://www.nagios.org/
Vendor: Ethan Galstad et al.
Packager: OpenPKG
Distribution: OpenPKG
Class: EVAL
Group: Network
License: GNU
Version: %{V_nagios}
Release: 20060123
# package options
%option with_eperl yes
%option with_fsl yes
%option with_ldap yes
# list of sources
Source0: http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-%{V_nagios}.tar.gz
Source1: http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-%{V_nagios_plugins}.tar.gz
Source2: etc.tar
Source3: rc.nagios
Source4: fsl.nagios
Patch0: nagios.patch
# build information
Prefix: %{l_prefix}
BuildRoot: %{l_buildroot}
BuildPreReq: OpenPKG, openpkg >= 20040130, traceroute, gcc
PreReq: OpenPKG, openpkg >= 20040130, traceroute, apache, MTA
BuildPreReq: zlib, jpeg, png, gd
PreReq: zlib, jpeg, png, gd
BuildPreReq: openssl, openssh, coreutils, inetutils, fping
PreReq: openssl, openssh, coreutils, inetutils, fping
%if "%{with_ldap}" == "yes"
BuildPreReq: openldap
PreReq: openldap
%endif
%if "%{with_fsl}" == "yes"
BuildPreReq: fsl >= 1.3.0
PreReq: fsl >= 1.3.0
%endif
AutoReq: no
AutoReqProv: no
%description
Nagios is a system and network monitoring application. It watches
hosts and services that you specify, alerting you when things go bad
and when they get better.
%track
prog nagios = {
version = %{V_nagios}
url = http://prdownloads.sourceforge.net/nagios/
regex = nagios-(\d+(\.\d+)+)\.tar\.gz
}
prog nagios:plugins = {
version = %{V_nagios_plugins}
url = http://prdownloads.sourceforge.net/nagiosplug/
regex = nagios-plugins-(\d+(\.\d+)+)\.tar\.gz
}
%prep
%setup -q
%setup -q -T -D -a 1
%setup -q -T -D -a 2
%patch -p0
%{l_shtool} subst \
-e 's;LDAPLIBS=.*-lldap.*;LDAPLIBS="-lldap -llber -lssl -lcrypto";' \
-e 's;LDAPINCLUDE=.*-I.*;LDAPINCLUDE="-I/%{l_prefix}/include";' \
nagios-plugins-%{V_nagios_plugins}/configure
%build
CC="%{l_cc}" \
CFLAGS="%{l_cflags -O}" \
LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
LIBS="%{l_fsl_libs} -lpng -ljpeg" \
PATH_TO_TRACEROUTE="%{l_prefix}/sbin/traceroute" \
./configure \
--prefix=%{l_prefix} \
--sbindir=%{l_prefix}/cgi/nagios \
--sysconfdir=%{l_prefix}/etc/nagios \
--libexecdir=%{l_prefix}/libexec/nagios \
--localstatedir=%{l_prefix}/var/nagios \
--datadir=%{l_prefix}/web/nagios \
--with-cgiurl=/nagios/cgi \
--with-htmurl=/nagios \
--with-nagios-user=%{l_musr} \
--with-nagios-grp=%{l_mgrp} \
--with-gd-lib=%{l_prefix}/lib \
--with-gd-inc=%{l_prefix}/include \
--with-lockfile=%{l_prefix}/var/nagios/nagios.pid \
%if "%{with_eperl}" == "yes"
--enable-embedded-perl \
%endif
--without-init-dir
%{l_make} %{l_mflags} all GDLIBS="-lgd -lm -lpng -lz -ljpeg"
# configure and build plugins
( cd nagios-plugins-%{V_nagios_plugins}/
CC="%{l_cc}" \
CFLAGS="%{l_cflags -O}" \
LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
PATH_TO_PING="%{l_prefix}/bin/gping" \
PING_PACKETS_FIRST="yes" \
PATH_TO_SSH="%{l_prefix}/bin/ssh" \
LIBS="-lssl -lcrypto"
./configure \
--prefix=%{l_prefix}/libexec/nagios \
--libexecdir=%{l_prefix}/libexec/nagios \
--with-openssl=%{l_prefix} \
--with-df-command=%{l_prefix}/bin/gdf \
--with-ping-command="%{l_prefix}/bin/gping -n -c %d %s" \
--with-nagios-user=%{l_musr} \
--with-nagios-group=%{l_mgrp} \
--with-cgiurl=/nagios/cgi
%{l_make} %{l_mflags}
) || exit $?
%install
rm -rf $RPM_BUILD_ROOT
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/etc/nagios \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
$RPM_BUILD_ROOT%{l_prefix}/libexec/nagios \
$RPM_BUILD_ROOT%{l_prefix}/var/nagios/log \
$RPM_BUILD_ROOT%{l_prefix}/var/nagios/rw
%{l_make} install DESTDIR="$RPM_BUILD_ROOT" INSTALL_OPTS="" COMMAND_OPTS=""
# install plugins
( cd nagios-plugins-%{V_nagios_plugins}/
%{l_make} install DESTDIR="$RPM_BUILD_ROOT"
) || exit $?
# install default configuration
%{l_shtool} install -c -m 644 %{l_value -s -a} \
etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/nagios/
# install start script
%{l_shtool} install -c -m 755 %{l_value -s -a} \
%{SOURCE rc.nagios} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
# install OSSP fsl configuration
%{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
%{l_shtool} install -c -m 644 %{l_value -s -a} \
%{SOURCE fsl.nagios} \
$RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
# determine installation files
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
%{l_files_std} \
'%not %dir %{l_prefix}/etc/fsl' \
'%config %{l_prefix}/etc/fsl/fsl.nagios' \
'%config %{l_prefix}/etc/nagios/*'
%files -f files
%clean
rm -rf $RPM_BUILD_ROOT
%post
# after upgrade, restart service
[ $1 -eq 2 ] || exit 0
eval `%{l_rc} nagios status 2>/dev/null`
[ ".$nagios_active" = .yes ] && %{l_rc} nagios restart
exit 0
%preun
# before erase, stop service and remove log files
[ $1 -eq 0 ] || exit 0
%{l_rc} nagios stop 2>/dev/null
rm -f $RPM_INSTALL_PREFIX/var/nagios/log/*.log* >/dev/null 2>&1 || true
rm -f $RPM_INSTALL_PREFIX/var/nagios/status.sav >/dev/null 2>&1 || true
exit 0