1 #/******************************************************************************
3 # * Copyright (C) 2012-present 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 %if "%{_vendor}" == "redhat"
23 %define el5_boost_version 141
24 %define el5_boost_libs %{_libdir}/boost%{el5_boost_version}
25 %define el5_boost_includes /usr/include/boost%{el5_boost_version}
26 %define apachename httpd
27 %define apacheconfdir %{_sysconfdir}/httpd/conf.d
28 %define apacheuser apache
29 %define apachegroup apache
31 %if "%{_vendor}" == "suse"
32 %define opensuse_boost_version 1_49_0
33 %define sles_boost_version 1_54_0
34 %define apachename apache2
35 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
36 %define apacheuser wwwrun
37 %define apachegroup www
40 %define icinga_user icinga
41 %define icinga_group icinga
42 %define icingacmd_group icingacmd
44 %define icingaclassicconfdir %{_sysconfdir}/icinga
46 %define logmsg logger -t %{name}/rpm
48 Summary: Network monitoring application
51 Release: %{revision}%{?dist}
53 Group: Applications/System
54 Source: %{name}-%{version}.tar.gz
55 URL: http://www.icinga.org/
56 BuildRoot: %{_tmppath}/%{name}-%{version}-build
58 BuildRequires: doxygen
59 BuildRequires: openssl-devel
60 BuildRequires: gcc-c++
61 BuildRequires: libstdc++-devel
63 BuildRequires: flex >= 2.5.35
65 BuildRequires: %{apachename}
68 %if "%{_vendor}" == "redhat"
69 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
71 BuildRequires: boost%{el5_boost_version}-devel
72 BuildRequires: boost%{el5_boost_version}
73 Requires: boost%{el5_boost_version}-program-options
74 Requires: boost%{el5_boost_version}-system
75 Requires: boost%{el5_boost_version}-test
76 Requires: boost%{el5_boost_version}-thread
77 Requires: boost%{el5_boost_version}-regex
79 BuildRequires: boost-devel >= 1.41
80 Requires: boost-program-options >= 1.41
81 Requires: boost-system >= 1.41
82 Requires: boost-test >= 1.41
83 Requires: boost-thread >= 1.41
84 Requires: boost-regex >= 1.41
90 %if "%{_vendor}" == "suse"
92 # note: sles_version macro is not set in SLES11 anymore
93 # note: sles service packs are not under version control
94 %if 0%{?suse_version} == 1110
95 BuildRequires: gcc-fortran
96 BuildRequires: libgfortran43
97 BuildRequires: boost-license%{sles_boost_version}
98 BuildRequires: boost-devel >= 1.41
99 Requires: boost-license%{sles_boost_version}
100 Requires: libboost_program_options%{sles_boost_version}
101 Requires: libboost_system%{sles_boost_version}
102 Requires: libboost_test%{sles_boost_version}
103 Requires: libboost_thread%{sles_boost_version}
104 Requires: libboost_regex%{sles_boost_version}
107 %if 0%{?suse_version} >= 1210
108 BuildRequires: boost-devel >= 1.41
109 Requires: libboost_program_options%{opensuse_boost_version}
110 Requires: libboost_system%{opensuse_boost_version}
111 Requires: libboost_test%{opensuse_boost_version}
112 Requires: libboost_thread%{opensuse_boost_version}
113 Requires: libboost_regex%{opensuse_boost_version}
118 Requires: %{name}-common = %{version}
121 Icinga is a general-purpose network monitoring application.
124 Summary: Common Icinga 2 configuration
125 Group: Applications/System
126 %if "%{_vendor}" == "redhat"
127 Requires(pre): shadow-utils
128 Requires(post): shadow-utils
132 Provides common directories, uid and gid among Icinga 2 related
137 Summary: Documentation for Icinga 2
138 Group: Applications/System
139 Requires: %{name} = %{version}-%{release}
142 Documentation for Icinga 2
146 Summary: IDO MySQL database backend for Icinga 2
147 Group: Applications/System
148 %if "%{_vendor}" == "suse"
149 BuildRequires: libmysqlclient-devel
150 %if 0%{?suse_version} >= 1210
151 Requires: libmysqlclient18
153 Requires: libmysqlclient15
156 %if "%{_vendor}" == "redhat"
157 # el5 only provides mysql package
158 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
161 BuildRequires: mysql-libs
164 BuildRequires: mysql-devel
167 Requires: %{name} = %{version}-%{release}
169 %description ido-mysql
170 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
171 IDOUtils schema >= 1.10
175 Summary: IDO PostgreSQL database backend for Icinga 2
176 Group: Applications/System
177 %if "%{_vendor}" == "suse"
178 BuildRequires: postgresql-libs
180 %if "%{_vendor}" == "redhat"
181 # el5 only provides mysql package
182 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
183 BuildRequires: postgresql84
186 BuildRequires: postgresql-devel
187 Requires: postgresql-libs
188 Requires: %{name} = %{version}-%{release}
190 %description ido-pgsql
191 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
192 IDOUtils schema >= 1.10
195 %package classicui-config
196 Summary: Icinga 2 Classic UI Standalone configuration
197 Group: Applications/System
198 Requires: %{apachename}
199 Requires: %{name} = %{version}-%{release}
200 Provides: icinga-classicui-config
201 Conflicts: icinga-gui-config
203 %description classicui-config
204 Icinga 1.x Classic UI Standalone configuration with locations
209 %setup -q -n %{name}-%{version}
212 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
213 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
214 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
215 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
216 -DICINGA2_USER=%{icinga_user} \
217 -DICINGA2_GROUP=%{icinga_group} \
218 -DICINGA2_COMMAND_USER=%{icinga_user} \
219 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
220 %if "%{_vendor}" == "redhat"
221 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
222 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
223 # details in https://dev.icinga.org/issues/5033
224 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
225 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
226 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
227 -DBoost_NO_SYSTEM_PATHS=TRUE \
228 -DBUILD_TESTING=FALSE \
229 -DBoost_NO_BOOST_CMAKE=TRUE"
238 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
240 DESTDIR="%{buildroot}"
242 # install classicui config
243 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
244 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
245 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
247 # fix plugin path on x64
248 %if "%{_vendor}" != "suse"
249 sed -i 's@plugindir = .*@plugindir = "%{_libdir}/nagios/plugins"@' %{buildroot}/%{_sysconfdir}/%{name}/conf.d/macros.conf
252 # remove features-enabled symlinks
253 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
256 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
259 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
260 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
261 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}
265 %if 0%{?suse_version}
267 %{fillup_and_insserv icinga2}
271 # initial installation, enable default features
272 %{_sbindir}/icinga2-enable-feature checker
273 %{_sbindir}/icinga2-enable-feature notification
274 %{_sbindir}/icinga2-enable-feature mainlog
279 %restart_on_update icinga2
282 if [ "$1" = "0" ]; then
283 # deinstallation of the package - remove enabled features
284 rm -rf %{_sysconfdir}/%{name}/features-enabled
290 %stop_on_removal icinga2
296 /sbin/chkconfig --add icinga2
300 # initial installation, enable default features
301 %{_sbindir}/icinga2-enable-feature checker
302 %{_sbindir}/icinga2-enable-feature notification
303 %{_sbindir}/icinga2-enable-feature mainlog
309 if [ "$1" -ge "1" ]; then
310 /sbin/service icinga2 condrestart >/dev/null 2>&1 || :
313 if [ "$1" = "0" ]; then
314 # deinstallation of the package - remove enabled features
315 rm -rf %{_sysconfdir}/%{name}/features-enabled
320 if [ "$1" = "0" ]; then
321 /sbin/service icinga2 stop > /dev/null 2>&1
322 /sbin/chkconfig --del icinga2
331 # initial installation, enable ido-mysql feature
332 %{_sbindir}/icinga2-enable-feature ido-mysql
338 if [ "$1" = "0" ]; then
339 # deinstallation of the package - remove feature
340 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-mysql
348 # initial installation, enable ido-pgsql feature
349 %{_sbindir}/icinga2-enable-feature ido-pgsql
355 if [ "$1" = "0" ]; then
356 # deinstallation of the package - remove feature
357 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-pgsql
362 %post classicui-config
365 # initial installation, enable features
366 %{_sbindir}/icinga2-enable-feature statusdata
367 %{_sbindir}/icinga2-enable-feature compatlog
368 %{_sbindir}/icinga2-enable-feature command
373 %postun classicui-config
374 if [ "$1" = "0" ]; then
375 # deinstallation of the package - remove feature
376 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature statusdata
377 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature compatlog
378 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature command
384 %defattr(-,root,root,-)
385 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
386 %attr(755,-,-) %{_sysconfdir}/init.d/%{name}
387 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
388 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
389 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
390 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
391 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
392 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
393 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
394 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
395 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
397 %{_bindir}/%{name}-migrate-config
398 %{_bindir}/%{name}-build-ca
399 %{_bindir}/%{name}-build-key
400 %{_sbindir}/%{name}-enable-feature
401 %{_sbindir}/%{name}-disable-feature
402 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
403 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
406 %exclude %{_datadir}/%{name}/itl
407 %{_mandir}/man8/%{name}.8.gz
409 %attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/cache/%{name}
410 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
411 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
412 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
413 %attr(0755,%{icinga_user},%{icinga_group}) %ghost %{_localstatedir}/run/%{name}
414 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
416 %attr(2755,%{icinga_user},%{icingacmd_group}) %ghost %{_localstatedir}/run/icinga2/cmd
419 %defattr(-,root,root,-)
420 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
421 %attr(755,-,-) %{_sysconfdir}/logrotate.d/%{name}
422 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
423 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
424 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
425 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/itl
426 %{_datadir}/%{name}/itl
429 %defattr(-,root,root,-)
430 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
431 %{_datadir}/doc/%{name}
432 %docdir %{_datadir}/doc/%{name}
435 %defattr(-,root,root,-)
436 %doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
437 %{_libdir}/%{name}/libdb_ido_mysql*
440 %defattr(-,root,root,-)
441 %doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
442 %{_libdir}/%{name}/libdb_ido_pgsql*
444 %files classicui-config
445 %defattr(-,root,root,-)
446 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
447 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
448 %config(noreplace) %{apacheconfdir}/icinga.conf
449 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd