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"
33 %if 0%{?suse_version} >= 1310
34 %define opensuse_boost_version 1_53_0
36 %define opensuse_boost_version 1_49_0
38 %define sles_boost_version 1_54_0
39 %define apachename apache2
40 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
41 %define apacheuser wwwrun
42 %define apachegroup www
45 %define icinga_user icinga
46 %define icinga_group icinga
47 %define icingacmd_group icingacmd
49 %define icingaclassicconfdir %{_sysconfdir}/icinga
51 %define logmsg logger -t %{name}/rpm
53 Summary: Network monitoring application
56 Release: %{revision}%{?dist}
58 Group: Applications/System
59 Source: %{name}-%{version}.tar.gz
60 URL: http://www.icinga.org/
61 BuildRoot: %{_tmppath}/%{name}-%{version}-build
63 BuildRequires: doxygen
64 BuildRequires: openssl-devel
65 BuildRequires: gcc-c++
66 BuildRequires: libstdc++-devel
68 BuildRequires: flex >= 2.5.35
70 BuildRequires: %{apachename}
73 %if "%{_vendor}" == "redhat"
74 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
76 BuildRequires: boost%{el5_boost_version}-devel
77 BuildRequires: boost%{el5_boost_version}
78 Requires: boost%{el5_boost_version}-program-options
79 Requires: boost%{el5_boost_version}-system
80 Requires: boost%{el5_boost_version}-test
81 Requires: boost%{el5_boost_version}-thread
82 Requires: boost%{el5_boost_version}-regex
84 BuildRequires: boost-devel >= 1.41
85 Requires: boost-program-options >= 1.41
86 Requires: boost-system >= 1.41
87 Requires: boost-test >= 1.41
88 Requires: boost-thread >= 1.41
89 Requires: boost-regex >= 1.41
95 %if "%{_vendor}" == "suse"
97 # note: sles_version macro is not set in SLES11 anymore
98 # note: sles service packs are not under version control
99 %if 0%{?suse_version} == 1110
100 BuildRequires: gcc-fortran
101 BuildRequires: libgfortran43
102 BuildRequires: boost-license%{sles_boost_version}
103 BuildRequires: boost-devel >= 1.41
104 Requires: boost-license%{sles_boost_version}
105 Requires: libboost_program_options%{sles_boost_version}
106 Requires: libboost_system%{sles_boost_version}
107 Requires: libboost_test%{sles_boost_version}
108 Requires: libboost_thread%{sles_boost_version}
109 Requires: libboost_regex%{sles_boost_version}
112 %if 0%{?suse_version} >= 1210
113 BuildRequires: boost-devel >= 1.41
114 Requires: libboost_program_options%{opensuse_boost_version}
115 Requires: libboost_system%{opensuse_boost_version}
116 Requires: libboost_test%{opensuse_boost_version}
117 Requires: libboost_thread%{opensuse_boost_version}
118 Requires: libboost_regex%{opensuse_boost_version}
123 Requires: %{name}-common = %{version}
126 Icinga is a general-purpose network monitoring application.
129 Summary: Common Icinga 2 configuration
130 Group: Applications/System
131 %if "%{_vendor}" == "redhat"
132 Requires(pre): shadow-utils
133 Requires(post): shadow-utils
137 Provides common directories, uid and gid among Icinga 2 related
142 Summary: Documentation for Icinga 2
143 Group: Applications/System
144 Requires: %{name} = %{version}-%{release}
147 Documentation for Icinga 2
151 Summary: IDO MySQL database backend for Icinga 2
152 Group: Applications/System
153 %if "%{_vendor}" == "suse"
154 BuildRequires: libmysqlclient-devel
155 %if 0%{?suse_version} >= 1210
156 Requires: libmysqlclient18
158 Requires: libmysqlclient15
161 %if "%{_vendor}" == "redhat"
162 # el5 only provides mysql package
163 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
166 BuildRequires: mysql-libs
169 BuildRequires: mysql-devel
172 Requires: %{name} = %{version}-%{release}
174 %description ido-mysql
175 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
176 IDOUtils schema >= 1.10
180 Summary: IDO PostgreSQL database backend for Icinga 2
181 Group: Applications/System
182 %if "%{_vendor}" == "suse"
183 BuildRequires: postgresql-libs
185 %if "%{_vendor}" == "redhat"
186 # el5 only provides mysql package
187 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
188 BuildRequires: postgresql84
191 BuildRequires: postgresql-devel
192 Requires: postgresql-libs
193 Requires: %{name} = %{version}-%{release}
195 %description ido-pgsql
196 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
197 IDOUtils schema >= 1.10
200 %package classicui-config
201 Summary: Icinga 2 Classic UI Standalone configuration
202 Group: Applications/System
203 Requires: %{apachename}
204 Requires: %{name} = %{version}-%{release}
205 Provides: icinga-classicui-config
206 Conflicts: icinga-gui-config
208 %description classicui-config
209 Icinga 1.x Classic UI Standalone configuration with locations
214 %setup -q -n %{name}-%{version}
217 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
218 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
219 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
220 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
221 -DICINGA2_USER=%{icinga_user} \
222 -DICINGA2_GROUP=%{icinga_group} \
223 -DICINGA2_COMMAND_USER=%{icinga_user} \
224 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
225 %if "%{_vendor}" == "redhat"
226 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
227 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
228 # details in https://dev.icinga.org/issues/5033
229 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
230 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
231 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
232 -DBoost_NO_SYSTEM_PATHS=TRUE \
233 -DBUILD_TESTING=FALSE \
234 -DBoost_NO_BOOST_CMAKE=TRUE"
243 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
245 DESTDIR="%{buildroot}"
247 # install classicui config
248 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
249 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
250 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
252 # fix plugin path on x64
253 %if "%{_vendor}" != "suse"
254 sed -i 's@plugindir = .*@plugindir = "%{_libdir}/nagios/plugins"@' %{buildroot}/%{_sysconfdir}/%{name}/conf.d/macros.conf
257 # remove features-enabled symlinks
258 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
261 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
264 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
265 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
266 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}
270 %if 0%{?suse_version}
272 %{fillup_and_insserv icinga2}
276 # initial installation, enable default features
277 %{_sbindir}/icinga2-enable-feature checker
278 %{_sbindir}/icinga2-enable-feature notification
279 %{_sbindir}/icinga2-enable-feature mainlog
284 %restart_on_update icinga2
287 if [ "$1" = "0" ]; then
288 # deinstallation of the package - remove enabled features
289 rm -rf %{_sysconfdir}/%{name}/features-enabled
295 %stop_on_removal icinga2
301 /sbin/chkconfig --add icinga2
305 # initial installation, enable default features
306 %{_sbindir}/icinga2-enable-feature checker
307 %{_sbindir}/icinga2-enable-feature notification
308 %{_sbindir}/icinga2-enable-feature mainlog
314 if [ "$1" -ge "1" ]; then
315 /sbin/service icinga2 condrestart >/dev/null 2>&1 || :
318 if [ "$1" = "0" ]; then
319 # deinstallation of the package - remove enabled features
320 rm -rf %{_sysconfdir}/%{name}/features-enabled
325 if [ "$1" = "0" ]; then
326 /sbin/service icinga2 stop > /dev/null 2>&1
327 /sbin/chkconfig --del icinga2
336 # initial installation, enable ido-mysql feature
337 %{_sbindir}/icinga2-enable-feature ido-mysql
343 if [ "$1" = "0" ]; then
344 # deinstallation of the package - remove feature
345 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-mysql
353 # initial installation, enable ido-pgsql feature
354 %{_sbindir}/icinga2-enable-feature ido-pgsql
360 if [ "$1" = "0" ]; then
361 # deinstallation of the package - remove feature
362 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-pgsql
367 %post classicui-config
370 # initial installation, enable features
371 %{_sbindir}/icinga2-enable-feature statusdata
372 %{_sbindir}/icinga2-enable-feature compatlog
373 %{_sbindir}/icinga2-enable-feature command
378 %postun classicui-config
379 if [ "$1" = "0" ]; then
380 # deinstallation of the package - remove feature
381 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature statusdata
382 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature compatlog
383 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature command
389 %defattr(-,root,root,-)
390 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
391 %attr(755,-,-) %{_sysconfdir}/init.d/%{name}
392 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
393 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
394 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
395 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
396 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
397 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
398 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
399 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
400 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
402 %{_bindir}/%{name}-migrate-config
403 %{_bindir}/%{name}-build-ca
404 %{_bindir}/%{name}-build-key
405 %{_sbindir}/%{name}-enable-feature
406 %{_sbindir}/%{name}-disable-feature
407 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
408 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
411 %exclude %{_datadir}/%{name}/itl
412 %{_mandir}/man8/%{name}.8.gz
414 %attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/cache/%{name}
415 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
416 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
417 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
418 %attr(0755,%{icinga_user},%{icinga_group}) %ghost %{_localstatedir}/run/%{name}
419 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
421 %attr(2755,%{icinga_user},%{icingacmd_group}) %ghost %{_localstatedir}/run/icinga2/cmd
424 %defattr(-,root,root,-)
425 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
426 %attr(755,-,-) %{_sysconfdir}/logrotate.d/%{name}
427 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
428 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
429 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
430 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/itl
431 %{_datadir}/%{name}/itl
434 %defattr(-,root,root,-)
435 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
436 %{_datadir}/doc/%{name}
437 %docdir %{_datadir}/doc/%{name}
440 %defattr(-,root,root,-)
441 %doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
442 %{_libdir}/%{name}/libdb_ido_mysql*
445 %defattr(-,root,root,-)
446 %doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
447 %{_libdir}/%{name}/libdb_ido_pgsql*
449 %files classicui-config
450 %defattr(-,root,root,-)
451 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
452 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
453 %config(noreplace) %{apacheconfdir}/icinga.conf
454 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd