1 #/******************************************************************************
3 # * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
5 # * This program is free software; you can redistribute it and/or *
6 # * modify it under the terms of the GNU General Public License *
7 # * as published by the Free Software Foundation; either version 2 *
8 # * of the License, or (at your option) any later version. *
10 # * This program is distributed in the hope that it will be useful, *
11 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 # * GNU General Public License for more details. *
15 # * You should have received a copy of the GNU General Public License *
16 # * along with this program; if not, write to the Free Software Foundation *
17 # * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 # ******************************************************************************/
22 # make sure that _rundir is working on older systems
23 %if ! %{defined _rundir}
24 %define _rundir %{_localstatedir}/run
27 %if "%{_vendor}" == "redhat"
28 %define apachename httpd
29 %define apacheconfdir %{_sysconfdir}/httpd/conf.d
30 %define apacheuser apache
31 %define apachegroup apache
34 %if %(uname -m) != "x86_64"
35 %define march_flag -march=i686
43 %if "%{_vendor}" == "suse"
44 %define apachename apache2
45 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
46 %define apacheuser wwwrun
47 %define apachegroup www
48 %if 0%{?suse_version} >= 1310
55 %define icinga_user icinga
56 %define icinga_group icinga
57 %define icingacmd_group icingacmd
58 %define icingaweb2name icingaweb2
59 %define icingaweb2version 2.0.0
61 %define icingaclassicconfdir %{_sysconfdir}/icinga
63 %define logmsg logger -t %{name}/rpm
65 Summary: Network monitoring application
68 Release: %{revision}%{?dist}
70 Group: Applications/System
71 Source: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz
72 URL: http://www.icinga.org/
73 BuildRoot: %{_tmppath}/%{name}-%{version}-build
74 Requires: %{name}-bin = %{version}-%{release}
77 Meta package for Icinga 2 Core, DB IDO and Web.
80 Summary: Icinga 2 binaries and libraries
81 Group: Applications/System
83 %if "%{_vendor}" == "suse"
85 Provides: monitoring_daemon
86 Recommends: monitoring-plugins
87 %if 0%{?suse_version} >= 1310
88 BuildRequires: libyajl-devel
91 BuildRequires: openssl-devel
92 BuildRequires: gcc-c++
93 BuildRequires: libstdc++-devel
95 BuildRequires: flex >= 2.5.35
99 %if "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
101 BuildRequires: boost141-devel
103 BuildRequires: boost-devel >= 1.41
107 BuildRequires: systemd
111 Requires: %{name}-common = %{version}-%{release}
114 Icinga 2 is a general-purpose network monitoring application.
115 Provides binaries and libraries for Icinga 2 Core.
118 Summary: Common Icinga 2 configuration
119 Group: Applications/System
120 %if "%{_vendor}" == "redhat"
121 Requires(pre): shadow-utils
122 Requires(post): shadow-utils
124 %if "%{_vendor}" == "suse"
125 Recommends: logrotate
129 Provides common directories, uid and gid among Icinga 2 related
134 Summary: Documentation for Icinga 2
135 Group: Applications/System
136 Requires: %{name} = %{version}-%{release}
139 Provides documentation for Icinga 2.
143 Summary: IDO MySQL database backend for Icinga 2
144 Group: Applications/System
145 %if "%{_vendor}" == "suse"
146 BuildRequires: libmysqlclient-devel
148 BuildRequires: mysql-devel
149 Requires: %{name} = %{version}-%{release}
151 %description ido-mysql
152 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
153 IDOUtils schema >= 1.10
157 Summary: IDO PostgreSQL database backend for Icinga 2
158 Group: Applications/System
159 BuildRequires: postgresql-devel
160 Requires: %{name} = %{version}-%{release}
162 %description ido-pgsql
163 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
164 IDOUtils schema >= 1.10
167 %package classicui-config
168 Summary: Icinga 2 Classic UI Standalone configuration
169 Group: Applications/System
170 BuildRequires: %{apachename}
171 Requires: %{apachename}
172 Requires: %{name} = %{version}-%{release}
173 %if "%{_vendor}" == "suse"
174 Recommends: icinga-www
176 Provides: icinga-classicui-config
177 Conflicts: icinga-gui-config
179 %description classicui-config
180 Icinga 1.x Classic UI Standalone configuration with locations
185 %setup -q -n %{name}-%{version}
188 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
189 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
190 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
191 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
192 -DCMAKE_VERBOSE_MAKEFILE=ON \
193 -DBoost_NO_BOOST_CMAKE=ON \
194 -DICINGA2_RUNDIR=%{_rundir} \
195 -DICINGA2_USER=%{icinga_user} \
196 -DICINGA2_GROUP=%{icinga_group} \
197 -DICINGA2_COMMAND_GROUP=%{icingacmd_group} \
198 -DICINGA2_UNITY_BUILD=TRUE"
199 %if "%{_vendor}" == "redhat"
200 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
201 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
202 # details in https://dev.icinga.org/issues/5033
203 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
204 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
205 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
206 -DBoost_NO_SYSTEM_PATHS=TRUE \
207 -DBUILD_TESTING=FALSE \
208 -DBoost_NO_BOOST_CMAKE=TRUE"
212 %if "%{_vendor}" != "suse"
213 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
215 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
219 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
222 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
229 DESTDIR="%{buildroot}"
231 # install classicui config
232 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
233 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
234 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
236 # remove features-enabled symlinks
237 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
239 # enable suse rc links
240 %if "%{_vendor}" == "suse"
242 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
244 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
246 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
247 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
252 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
255 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
256 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
257 getent passwd %{icinga_user} >/dev/null || %{_sbindir}/useradd -c "icinga" -s /sbin/nologin -r -d %{_localstatedir}/spool/%{name} -G %{icingacmd_group} -g %{icinga_group} %{icinga_user}
260 %if "%{_vendor}" == "suse"
262 %verify_permissions -e %{_rundir}/%{name}/cmd
266 %if "%{_vendor}" == "suse"
269 %service_add_pre %{name}.service
275 %if "%{_vendor}" == "suse"
276 %if 0%{?suse_version} >= 1310
277 %set_permissions %{_rundir}/%{name}/cmd
281 %service_add_post %{name}.service
283 %fillup_and_insserv %{name}
286 # initial installation, enable default features
287 for feature in checker notification mainlog; do
288 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
297 %systemd_post %{name}.service
299 /sbin/chkconfig --add %{name}
304 # initial installation, enable default features
305 for feature in checker notification mainlog; do
306 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
317 %if "%{_vendor}" == "suse"
318 %if 0%{?using_systemd}
319 %service_del_postun %{name}.service
321 %restart_on_update %{name}
329 %systemd_postun_with_restart %{name}.service
331 if [ "$1" -ge "1" ]; then
332 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
339 if [ "$1" = "0" ]; then
340 # deinstallation of the package - remove enabled features
341 rm -rf %{_sysconfdir}/%{name}/features-enabled
348 %if "%{_vendor}" == "suse"
351 %service_del_preun %{name}.service
353 %stop_on_removal %{name}
362 %systemd_preun %{name}.service
364 if [ "$1" = "0" ]; then
365 /sbin/service %{name} stop > /dev/null 2>&1 || :
366 /sbin/chkconfig --del %{name} || :
378 # initial installation, enable ido-mysql feature
379 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
385 if [ "$1" = "0" ]; then
386 # deinstallation of the package - remove feature
387 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
395 # initial installation, enable ido-pgsql feature
396 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
402 if [ "$1" = "0" ]; then
403 # deinstallation of the package - remove feature
404 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
409 %post classicui-config
412 # initial installation, enable features
413 for feature in statusdata compatlog command; do
414 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
420 %postun classicui-config
421 if [ "$1" = "0" ]; then
422 # deinstallation of the package - remove feature
423 for feature in statusdata compatlog command; do
424 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
431 %defattr(-,root,root,-)
435 %defattr(-,root,root,-)
436 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
438 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
439 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
442 %exclude %{_datadir}/%{name}/include
443 %{_mandir}/man8/%{name}.8.gz
445 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
446 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
447 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
448 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
449 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
451 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
452 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
455 %defattr(-,root,root,-)
456 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
457 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
458 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
459 %{_sysconfdir}/bash_completion.d/%{name}
461 %attr(644,root,root) %{_unitdir}/%{name}.service
463 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
465 %if "%{_vendor}" == "suse"
466 %{_sbindir}/rc%{name}
467 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
469 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
471 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
472 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
473 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
474 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
475 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
476 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
477 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
478 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
479 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
480 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
481 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
482 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
483 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
484 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
485 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
486 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
487 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
488 %{_sbindir}/%{name}-prepare-dirs
489 %{_mandir}/man8/%{name}-prepare-dirs.8.gz
490 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
491 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
492 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
493 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
494 %{_datadir}/%{name}/include
497 %defattr(-,root,root,-)
498 %{_datadir}/doc/%{name}
499 %docdir %{_datadir}/doc/%{name}
502 %defattr(-,root,root,-)
503 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
504 %{_libdir}/%{name}/libdb_ido_mysql*
505 %{_datadir}/icinga2-ido-mysql
508 %defattr(-,root,root,-)
509 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
510 %{_libdir}/%{name}/libdb_ido_pgsql*
511 %{_datadir}/icinga2-ido-pgsql
513 %files classicui-config
514 %defattr(-,root,root,-)
515 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
516 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
517 %config(noreplace) %{apacheconfdir}/icinga.conf
518 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd