File nsca.spec of Package nsca
#
# spec file for package nsca
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: nsca
Version: 2.9.1
Release: 0
Summary: The Nagios Service Check Acceptor
License: GPL-2.0+
Group: System/Monitoring
Url: http://www.nagios.org/
Source0: %{name}-%{version}.tar.bz2
Source1: rcnsca
Source2: nsca-rpmlintrc
Source3: nsca-SuSEfirewall2
Source4: send_nsca.1
Source5: nsca.1
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch1: nsca.abuild.patch
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch2: nsca.xinetd.patch
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch3: nsca.spooldir.patch
BuildRequires: libmcrypt-devel
BuildRequires: nagios-rpm-macros
BuildRequires: tcpd-devel
Recommends: monitoring_daemon
Provides: nagios-nsca = %{version}
Obsoletes: nagios-nsca < 2.9.2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
The purpose of this add-on is to allow the execution of NetSaint and
Nagios plug-ins on a remote host in a manner that is as transparent as
possible. This is the server part including the daemon without the
client program.
%package client
Summary: The Nagios Service Check Acceptor Client
Group: System/Monitoring
Provides: nagios-nsca-client = %{version}
Obsoletes: nagios-nsca-client < 2.9.2
%description client
The purpose of this add-on is to allow the execution of NetSaint and
Nagios plug-ins on a remote host in a manner that is as transparent as
possible. This package includes only the client program.
%prep
%setup -q
%patch1
%patch2
%patch3
%build
export CFLAGS="%{optflags}"
%if %suse_version > 1000
export CFLAGS="$CFLAGS -fstack-protector"
%endif
%configure \
--sysconfdir=%{_sysconfdir} \
--localstatedir=%{nagios_spooldir} \
--with-nsca-user=%{nagios_user} \
--with-nsca-grp=%{nagios_group} \
--with-nsca-port=5667
make all
%install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_sysconfdir}
mkdir -p %{buildroot}%{_initddir}/
mkdir -p %{buildroot}%{_sysconfdir}/xinetd.d/
install -m 755 src/nsca %{buildroot}%{_bindir}/
install -m 755 src/send_nsca %{buildroot}%{_bindir}/
install -m 644 sample-config/nsca.cfg %{buildroot}%{_sysconfdir}/
install -m 644 sample-config/send_nsca.cfg %{buildroot}%{_sysconfdir}/
install -m 644 sample-config/nsca.xinetd %{buildroot}%{_sysconfdir}/xinetd.d/nsca
install -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/nsca
ln -sf ../../%{_sysconfdir}/init.d/nsca %{buildroot}%{_sbindir}/rcnsca
chmod 644 README
# install SuSEfirewall2 script
%if 0%{?suse_version} > 1020
install -Dm644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%endif
# install man pages
install -Dm644 %{SOURCE4} %{buildroot}%{_mandir}/man1/send_nsca.1
install -m644 %{SOURCE5} %{buildroot}%{_mandir}/man1/nsca.1
%preun
%stop_on_removal nsca
%postun
%restart_on_update nsca
%insserv_cleanup
%triggerpostun -- nagios-nrpe < 2.9.2
STATUS='/var/adm/update-scripts/%{name}'
if [ -x %{_sysconfdir}/init.d/nsca ]; then
%{_sysconfdir}/init.d/nsca status >/dev/null
if test $? = 0; then
echo "%{_sysconfdir}/init.d/nsca restart" >> "$STATUS"
else
touch "$STATUS"
fi
chmod +x "$STATUS"
fi
if [ -x %{_sysconfdir}/init.d/xinetd ]; then
%{_sysconfdir}/init.d/xinetd status >/dev/null
if test $? = 0; then
echo "%{_sysconfdir}/init.d/xinetd try-restart" >> "$STATUS"
else
touch "$STATUS"
fi
chmod +x "$STATUS"
fi
%triggerpostun -- nagios-nsca < 2.9.2
# Move /etc/nagios/nsca.conf to /etc/nsca.conf when updating from an old version
# and inform the admin about the move.
pushd %{_sysconfdir}
if test -e nagios/nsca.conf.rpmsave -a ! -e nsca.conf.rpmnew; then
mv nsca/nsca.conf nsca.conf.rpmnew
mv nagios/nsca.conf.rpmsave nsca.conf
test -L %{nagios_sysconfdir}/nsca.conf || ln -s %{_sysconfdir}/nsca.conf %{nagios_sysconfdir}/nsca.conf
%restart_on_update nsca
fi
sed -i "s|%{nagios_sysconfdir}/nsca.cfg|%{_sysconfdir}/nsca.cfg|g" %{_sysconfdir}/xinetd.d/nsca || :
if [ -e /var/adm/update-scripts/%{name} ]; then
/bin/sh /var/adm/update-scripts/%{name}
rm /var/adm/update-scripts/%{name}
fi
%triggerpostun -- nagios-nsca-client < 2.9.2
# Move /etc/nagios/send_nsca.cfg to /etc/send_nsca.cfg when updating from an old version
# and inform the admin about the move.
pushd %{_sysconfdir}
if test -e nagios/send_nsca.cfg.rpmsave -a ! -e send_nsca.cfg.rpmnew; then
mv nsca/send_nsca.cfg send_nsca.cfg.rpmnew
mv nagios/send_nsca.cfg send_nsca.cfg
test -L %{nagios_sysconfdir}/send_nsca.cfg || ln -s %{_sysconfdir}/send_nsca.cfg %{nagios_sysconfdir}/send_nsca.cfg
fi
%clean
rm -rf %{buildroot};
%files
%defattr(-,root,root)
%{_bindir}/nsca
%{_sysconfdir}/init.d/nsca
%{_sbindir}/rcnsca
%config(noreplace) %{_sysconfdir}/nsca.cfg
%config(noreplace) %{_sysconfdir}/xinetd.d/nsca
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%{_mandir}/man1/nsca.1*
%doc Changelog README SECURITY LEGAL
%files client
%defattr(-,root,root)
%{_bindir}/send_nsca
%{_mandir}/man1/send_nsca.1*
%config(noreplace) %{_sysconfdir}/send_nsca.cfg
%changelog