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}
259 %if "%{_vendor}" == "suse"
261 %service_add_pre %{name}.service
266 %if "%{_vendor}" == "suse"
268 %verify_permissions -e %{_rundir}/%{name}/cmd
273 %if "%{_vendor}" == "suse"
274 %if 0%{?suse_version} >= 1310
275 %set_permissions %{_rundir}/%{name}/cmd
279 %service_add_post %{name}.service
281 %fillup_and_insserv %{name}
284 # initial installation, enable default features
285 for feature in checker notification mainlog; do
286 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
295 %systemd_post %{name}.service
297 /sbin/chkconfig --add %{name}
302 # initial installation, enable default features
303 for feature in checker notification mainlog; do
304 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
315 %if "%{_vendor}" == "suse"
316 %if 0%{?using_systemd}
317 %service_del_postun %{name}.service
319 %restart_on_update %{name}
327 %systemd_postun_with_restart %{name}.service
329 if [ "$1" -ge "1" ]; then
330 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
337 if [ "$1" = "0" ]; then
338 # deinstallation of the package - remove enabled features
339 rm -rf %{_sysconfdir}/%{name}/features-enabled
346 %if "%{_vendor}" == "suse"
349 %service_del_preun %{name}.service
351 %stop_on_removal %{name}
360 %systemd_preun %{name}.service
362 if [ "$1" = "0" ]; then
363 /sbin/service %{name} stop > /dev/null 2>&1 || :
364 /sbin/chkconfig --del %{name} || :
376 # initial installation, enable ido-mysql feature
377 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
383 if [ "$1" = "0" ]; then
384 # deinstallation of the package - remove feature
385 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
393 # initial installation, enable ido-pgsql feature
394 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
400 if [ "$1" = "0" ]; then
401 # deinstallation of the package - remove feature
402 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
407 %post classicui-config
410 # initial installation, enable features
411 for feature in statusdata compatlog command; do
412 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
418 %postun classicui-config
419 if [ "$1" = "0" ]; then
420 # deinstallation of the package - remove feature
421 for feature in statusdata compatlog command; do
422 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
429 %defattr(-,root,root,-)
433 %defattr(-,root,root,-)
434 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
436 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
437 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
440 %exclude %{_datadir}/%{name}/include
441 %{_mandir}/man8/%{name}.8.gz
443 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
444 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
445 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
446 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
447 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
449 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
450 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
453 %defattr(-,root,root,-)
454 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
455 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
456 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
457 %{_sysconfdir}/bash_completion.d/%{name}
459 %attr(644,root,root) %{_unitdir}/%{name}.service
461 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
463 %if "%{_vendor}" == "suse"
464 %{_sbindir}/rc%{name}
465 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
467 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
469 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
470 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
471 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
472 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
473 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
474 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
475 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
476 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
477 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
478 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
479 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
480 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
481 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
482 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
483 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
484 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
485 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
486 /usr/lib/icinga2/prepare-dirs
487 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
488 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
489 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
490 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
491 %{_datadir}/%{name}/include
494 %defattr(-,root,root,-)
495 %{_datadir}/doc/%{name}
496 %docdir %{_datadir}/doc/%{name}
499 %defattr(-,root,root,-)
500 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
501 %{_libdir}/%{name}/libdb_ido_mysql*
502 %{_datadir}/icinga2-ido-mysql
505 %defattr(-,root,root,-)
506 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
507 %{_libdir}/%{name}/libdb_ido_pgsql*
508 %{_datadir}/icinga2-ido-pgsql
510 %files classicui-config
511 %defattr(-,root,root,-)
512 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
513 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
514 %config(noreplace) %{apacheconfdir}/icinga.conf
515 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd