File mod_gearman.spec of Package mod_gearman

#
# spec file for package mod_gearman
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2014-2016 SUSE LINUX 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:           mod_gearman
Version:        1.5.5
Release:        1
License:        GPL-3.0+
Summary:        Gearman module for Icinga/Nagios
Url:            http://mod-gearman.org/
Group:          System/Monitoring
Source0:        mod_gearman-%{version}.tar.bz2
Source1:        rcmod_gearman_worker
Source2:        etc_sysconfig_mod_gearman_worker
Source4:        mod_gearman-README.SUSE
Source5:        gearman_proxy.init
Source6:        mod_gearman_proxy.logrotate
Patch0:         mod_gearman_localstatedir.patch
BuildRequires:  autoconf,
BuildRequires:  automake,
BuildRequires:  gcc-c++
BuildRequires:  gearmand-devel
BuildRequires:  libevent-devel
BuildRequires:  libtool,
BuildRequires:  perl(ExtUtils::Embed)
# 09-check-packaged-twice check does not allow a directory/file packaged 
# in different subpackages with different users - even if those conflict
# so we disable the check for the affected distributions 
%if 0%{suse_version} == 01230 || 0%{suse_version} == 01310 
BuildRequires:  -post-build-checks
%endif
%if 0%{?suse_version} > 01140
BuildRequires:  libtool-ltdl-devel,
%endif
BuildRequires:  nagios-rpm-macros
BuildRequires:  ncurses-devel
Requires(pre):  /sbin/ldconfig
Requires(post): /sbin/ldconfig
%if 0%{?suse_version}
Requires(pre):  pwdutils
Requires(pre):  %insserv_prereq
Requires(pre):  %fillup_prereq
%define         _initrddir %{_sysconfdir}/init.d
%else
Requires(pre):  shadow-utils
%endif
Recommends:     gearmand-server
Requires:       perl >= 5.10.0
Requires:       %{name}-files = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Mod Gearman is a new way of distributing active Nagios/Icinga
checks across your network. It consists of two parts: There is
a NEB module which resides in the Nagios/Icinga core and adds
servicechecks, hostchecks and eventhandler to a Gearman queue.
There can be multiple equal gearman servers. The counterpart
is one or more worker clients for the checks itself. They can
be bound to host and servicegroups.

%package nagios
Summary:        Gearman module files for Nagios
Group:          System/Monitoring
Requires:       logrotate
Requires(pre):  %{name} = %{version}
Provides:       %{name}-files = %{version}-%{release}
Conflicts:      %{name}-icinga
Supplements:    nagios

%description nagios
Mod Gearman is a new way of distributing active Nagios/Icinga
checks across your network.

This package contains files and directories with the right 
permissions for Nagios.


%package icinga
Summary:        Gearman module files for Icinga
Group:          System/Monitoring
Requires:       logrotate
Requires(pre):  %{name} = %{version}
Provides:       %{name}-files = %{version}-%{release}
Conflicts:      %{name}-nagios
Supplements:    icinga

%description icinga
Mod Gearman is a new way of distributing active Nagios/Icinga
checks across your network.

This package contains files and directories with the right
permissions for Icinga.

%package proxy
Summary:        Proxy Gearman Jobs from one jobserver to another jobserver
Group:          System/Monitoring
Requires:       gearmand-server
Requires:       logrotate

%description proxy
Proxy Gearman Jobs from one jobserver to another jobserver. This could
be handy, when you have a worker in a remote net and only push is
allowed. 

Mod-Gearman <-> Gearmand <-> Gearman-Proxy <--|--> Gearmand <-> Worker

Instead of the Worker polling from the master gearmand, it can now
poll the jobs from a local jobserver which gets fed by the
Gearman-Proxy.


%prep
%setup -q
#%patch0 -p1
sed -i "s|--export-dynamic||g" Makefile.*
# install documentation
install -m644 %{SOURCE4} README.SUSE

%build
./autogen.sh
export CPPFLAGS="%{optflags}" \
export CFLAGS="%{optflags}" \
%configure \
     --with-init-dir="%{_initddir}" \
     --with-user="%{nagios_user}" \
     --enable-embedded-perl

make %{?_smp_mflags}

%install
make install \
     install-config \
     DESTDIR=%{buildroot} \
     AM_INSTALL_PROGRAM_FLAGS=""

# remove custom gearmand initscript
rm -f %{buildroot}%{_initddir}/gearmand
%if 0%{?suse_version}
rm  %{buildroot}%{_initddir}/mod_gearman_worker
install -m755 %{SOURCE1}  %{buildroot}%{_initddir}/mod_gearman_worker
# install symlink in sbindir
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_initddir}/mod_gearman_worker %{buildroot}%{_sbindir}/rcmod_gearman_worker
# install sysconfig script
install -D -m644 %{SOURCE2} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.mod_gearman_worker
%endif
mkdir -p %{buildroot}%{_localstatedir}/log/mod_gearman
# patch logrotate file
sed -i "s|}|    su %{nagios_user} %{nagios_group}\n}|g" %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
mv %{buildroot}%{_sysconfdir}/logrotate.d/mod_gearman %{buildroot}%{_sysconfdir}/%{name}/logrotate-%{name}-nagios
# patch logrotate file for icinga subpackage
sed -e "s|    su %{nagios_user} %{nagios_group}|    su %{icinga_user} %{icinga_group}|g;" \
		%{buildroot}%{_sysconfdir}/%{name}/logrotate-%{name}-nagios \
		> %{buildroot}%{_sysconfdir}/%{name}/logrotate-%{name}-icinga
# install files for gearman_proxy 
cd contrib
install -m0644 gearman_proxy.cfg %{buildroot}%{_sysconfdir}/mod_gearman/gearman_proxy.cfg
install -m0755 gearman_proxy.pl %{buildroot}/%{_datadir}/mod_gearman/gearman_proxy.pl
install -m0755 %{SOURCE5} %{buildroot}/%{_sysconfdir}/init.d/mod_gearman-proxy
install -m0644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/logrotate.d/mod_gearman-proxy
%if 0%{?suse_version}
ln -sf %{_sysconfdir}/init.d/mod_gearman-proxy %{buildroot}/%{_sbindir}/rcmod_gearman-proxy
%endif

%pre nagios
%{nagios_user_group_add}

%pre icinga
%{icinga_user_group_add}
if [ ${1:-0} -eq 1 ]; then
	if [ -w %{_sysconfdir}/sysconfig/mod_gearman_worker ]; then
		sed -i "s|USER=\"nagios\"|USER=\"icinga\"|g" %{_sysconfdir}/sysconfig/mod_gearman_worker 
	fi
fi

%if 0%{?suse_version}
%preun
%stop_on_removal mod_gearman_worker

%post
%{fillup_and_insserv -n mod_gearman_worker mod_gearman_worker}
/sbin/ldconfig

%postun
%restart_on_update mod_gearman_worker
%insserv_cleanup
/sbin/ldconfig
%else
%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig
%endif

%post proxy
%{fillup_and_insserv -y mod_gearman-proxy}

%preun proxy
%stop_on_removal mod_gearman-proxy

%postun proxy
%restart_on_update mod_gearman-proxy
%insserv_cleanup

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc Changes COPYING README README.SUSE THANKS TODO docs/*
%dir %{_sysconfdir}/mod_gearman
%dir %{_datadir}/mod_gearman
%dir %{_libdir}/mod_gearman
%{_localstatedir}/adm/fillup-templates/sysconfig.mod_gearman_worker

%attr(755,root,root) %{_initddir}/mod_gearman_worker

%{_datadir}/mod_gearman/standalone_worker.conf
%{_datadir}/mod_gearman/shared.conf
%attr(644,root,root) %{_datadir}/mod_gearman/mod_gearman_p1.pl

%{_bindir}/check_gearman
%{_bindir}/gearman_top
%{_bindir}/mod_gearman_mini_epn
%{_bindir}/mod_gearman_worker
%{_bindir}/send_gearman
%{_bindir}/send_multi

%{_libdir}/mod_gearman/mod_gearman.o
%if 0%{?suse_version}
%{_sbindir}/rcmod_gearman_worker
%endif

%files proxy
%defattr(-,root,root)
%doc contrib/README
%config(noreplace) %{_sysconfdir}/mod_gearman/gearman_proxy.cfg
%config(noreplace) %{_sysconfdir}/logrotate.d/mod_gearman-proxy
%attr(755,root,root) %{_datadir}/mod_gearman/gearman_proxy.pl
%dir %{_var}/log/mod_gearman
%{_sysconfdir}/init.d/mod_gearman-proxy
%if 0%{?suse_version} 
%{_sbindir}/rcmod_gearman-proxy
%endif

%files icinga
%defattr(-,%{icinga_user},root)
%{_localstatedir}/log/mod_gearman
%defattr(644,root,%{icinga_command_group})
%config(noreplace) %{_sysconfdir}/mod_gearman/mod_gearman_neb.conf
%config(noreplace) %{_sysconfdir}/mod_gearman/mod_gearman_worker.conf
%attr(640,root,root) %config(noreplace) %{_sysconfdir}/%{name}/logrotate-%{name}-icinga

%files nagios
%defattr(-,%{nagios_user},root)
%{_localstatedir}/log/mod_gearman
%defattr(644,root,%{nagios_command_group})
%config(noreplace) %{_sysconfdir}/mod_gearman/mod_gearman_neb.conf
%config(noreplace) %{_sysconfdir}/mod_gearman/mod_gearman_worker.conf
%attr(640,root,root) %config(noreplace) %{_sysconfdir}/%{name}/logrotate-%{name}-nagios

%changelog
openSUSE Build Service is sponsored by