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 %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
38 %if "%{_vendor}" == "suse"
39 %if 0%{?suse_version} >= 1310
41 %define opensuse_boost_version 1_53_0
44 %define opensuse_boost_version 1_49_0
46 %define sles_boost_version 1_54_0
47 %define apachename apache2
48 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
49 %define apacheuser wwwrun
50 %define apachegroup www
53 %define icinga_user icinga
54 %define icinga_group icinga
55 %define icingacmd_group icingacmd
56 %define icingaweb2name icingaweb2
57 %define icingaweb2version 2.0.0
59 %define icingaclassicconfdir %{_sysconfdir}/icinga
61 %define logmsg logger -t %{name}/rpm
63 Summary: Network monitoring application
66 Release: %{revision}%{?dist}
68 Group: Applications/System
69 Source: %{name}-%{version}.tar.gz
70 URL: http://www.icinga.org/
71 BuildRoot: %{_tmppath}/%{name}-%{version}-build
73 Requires: %{name}-bin = %{version}
74 #Requires: %{name}-ido-mysql = %{version}
75 #Requires: %{icingaweb2name} >= %{icingaweb2version}
78 Meta package for Icinga 2 Core, DB IDO and Web.
81 Summary: Icinga 2 binaries and libraries
82 Group: Applications/System
84 BuildRequires: openssl-devel
85 BuildRequires: gcc-c++
86 BuildRequires: libstdc++-devel
88 BuildRequires: flex >= 2.5.35
93 %if "%{_vendor}" == "redhat"
94 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
96 BuildRequires: boost%{el5_boost_version}-devel
97 BuildRequires: boost%{el5_boost_version}
98 Requires: boost%{el5_boost_version}-program-options
99 Requires: boost%{el5_boost_version}-system
100 Requires: boost%{el5_boost_version}-test
101 Requires: boost%{el5_boost_version}-thread
102 Requires: boost%{el5_boost_version}-regex
104 BuildRequires: boost-devel >= 1.41
105 Requires: boost-program-options >= 1.41
106 Requires: boost-system >= 1.41
107 Requires: boost-test >= 1.41
108 Requires: boost-thread >= 1.41
109 Requires: boost-regex >= 1.41
115 %if "%{_vendor}" == "suse"
117 # note: sles_version macro is not set in SLES11 anymore
118 # note: sles service packs are not under version control
119 %if 0%{?suse_version} == 1110
120 BuildRequires: gcc-fortran
121 BuildRequires: libgfortran43
122 BuildRequires: boost-license%{sles_boost_version}
123 BuildRequires: boost-devel >= 1.41
124 Requires: boost-license%{sles_boost_version}
125 Requires: libboost_program_options%{sles_boost_version}
126 Requires: libboost_system%{sles_boost_version}
127 Requires: libboost_test%{sles_boost_version}
128 Requires: libboost_thread%{sles_boost_version}
129 Requires: libboost_regex%{sles_boost_version}
132 %if 0%{?suse_version} >= 1210
133 BuildRequires: boost-devel >= 1.41
134 Requires: libboost_program_options%{opensuse_boost_version}
135 Requires: libboost_system%{opensuse_boost_version}
136 Requires: libboost_test%{opensuse_boost_version}
137 Requires: libboost_thread%{opensuse_boost_version}
138 Requires: libboost_regex%{opensuse_boost_version}
144 BuildRequires: systemd
148 Requires: %{name}-common = %{version}
151 Icinga 2 is a general-purpose network monitoring application.
152 Provides binaries and libraries for Icinga 2 Core.
155 Summary: Common Icinga 2 configuration
156 Group: Applications/System
157 %if "%{_vendor}" == "redhat"
158 Requires(pre): shadow-utils
159 Requires(post): shadow-utils
161 %if "%{_vendor}" == "suse"
162 Recommends: logrotate
166 Provides common directories, uid and gid among Icinga 2 related
171 Summary: Documentation for Icinga 2
172 Group: Applications/System
173 Requires: %{name} = %{version}-%{release}
176 Provides documentation for Icinga 2.
180 Summary: IDO MySQL database backend for Icinga 2
181 Group: Applications/System
182 %if "%{_vendor}" == "suse"
183 BuildRequires: libmysqlclient-devel
185 %if "%{_vendor}" == "redhat"
186 # el5 only provides mysql package
187 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
190 BuildRequires: mysql-libs
193 BuildRequires: mysql-devel
196 Requires: %{name} = %{version}-%{release}
198 %description ido-mysql
199 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
200 IDOUtils schema >= 1.10
204 Summary: IDO PostgreSQL database backend for Icinga 2
205 Group: Applications/System
206 %if "%{_vendor}" == "suse"
207 BuildRequires: postgresql-libs
209 BuildRequires: postgresql-devel
210 Requires: postgresql-libs
211 Requires: %{name} = %{version}-%{release}
213 %description ido-pgsql
214 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
215 IDOUtils schema >= 1.10
218 %package classicui-config
219 Summary: Icinga 2 Classic UI Standalone configuration
220 Group: Applications/System
221 BuildRequires: %{apachename}
222 Requires: %{apachename}
223 Requires: %{name} = %{version}-%{release}
224 Provides: icinga-classicui-config
225 Conflicts: icinga-gui-config
227 %description classicui-config
228 Icinga 1.x Classic UI Standalone configuration with locations
233 %setup -q -n %{name}-%{version}
236 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
237 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
238 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
239 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
240 -DICINGA2_USER=%{icinga_user} \
241 -DICINGA2_GROUP=%{icinga_group} \
242 -DICINGA2_COMMAND_USER=%{icinga_user} \
243 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
244 %if "%{_vendor}" == "redhat"
245 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
246 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
247 # details in https://dev.icinga.org/issues/5033
248 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
249 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
250 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
251 -DBoost_NO_SYSTEM_PATHS=TRUE \
252 -DBUILD_TESTING=FALSE \
253 -DBoost_NO_BOOST_CMAKE=TRUE"
257 %if "%{_vendor}" != "suse"
258 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
260 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
264 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
271 rm -f components/db_ido_*sql/schema/upgrade/.gitignore
274 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
276 DESTDIR="%{buildroot}"
278 # install classicui config
279 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
280 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
281 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
283 # remove features-enabled symlinks
284 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
286 # enable suse rc links
287 %if "%{_vendor}" == "suse"
289 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
291 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
293 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
294 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
299 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
302 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
303 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
304 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}
308 %if "%{_vendor}" == "suse"
311 %service_add_pre %{name}.service
316 # all restart/feature actions belong to icinga2-bin
319 %if 0%{?suse_version}
323 %service_add_post %{name}.service
325 %fillup_and_insserv %{name}
328 # initial installation, enable default features
329 %{_sbindir}/icinga2-enable-feature checker notification mainlog
337 %systemd_post %{name}.service
339 /sbin/chkconfig --add %{name}
344 # initial installation, enable default features
345 %{_sbindir}/icinga2-enable-feature checker notification mainlog
355 %if 0%{?suse_version}
356 %if 0%{?using_systemd}
357 %service_del_postun %{name}.service
359 %restart_on_update %{name}
367 %systemd_postun_with_restart %{name}.service
369 if [ "$1" -ge "1" ]; then
370 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
377 if [ "$1" = "0" ]; then
378 # deinstallation of the package - remove enabled features
379 rm -rf %{_sysconfdir}/%{name}/features-enabled
386 %if 0%{?suse_version}
389 %service_del_preun %{name}.service
391 %stop_on_removal %{name}
400 %systemd_preun %{name}.service
402 if [ "$1" = "0" ]; then
403 /sbin/service %{name} stop > /dev/null 2>&1 || :
404 /sbin/chkconfig --del %{name} || :
416 # initial installation, enable ido-mysql feature
417 %{_sbindir}/icinga2-enable-feature ido-mysql
423 if [ "$1" = "0" ]; then
424 # deinstallation of the package - remove feature
425 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-mysql
433 # initial installation, enable ido-pgsql feature
434 %{_sbindir}/icinga2-enable-feature ido-pgsql
440 if [ "$1" = "0" ]; then
441 # deinstallation of the package - remove feature
442 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-pgsql
447 %post classicui-config
450 # initial installation, enable features
451 %{_sbindir}/icinga2-enable-feature statusdata compatlog command
456 %postun classicui-config
457 if [ "$1" = "0" ]; then
458 # deinstallation of the package - remove feature
459 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature statusdata
460 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature compatlog
461 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature command
469 %defattr(-,root,root,-)
470 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
472 %attr(644,-,0) %{_unitdir}/%{name}.service
474 %attr(755,-,-) %{_sysconfdir}/init.d/%{name}
476 %if "%{_vendor}" == "suse"
477 %{_sbindir}/rc%{name}
478 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
480 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
482 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
483 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
484 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts
485 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts/localhost
486 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
487 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
488 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
489 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
490 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
491 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
492 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
493 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
494 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf
495 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf
496 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
497 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
498 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
500 %{_bindir}/%{name}-build-ca
501 %{_bindir}/%{name}-build-key
502 %{_bindir}/%{name}-sign-key
503 %{_sbindir}/%{name}-enable-feature
504 %{_sbindir}/%{name}-disable-feature
505 %{_sbindir}/%{name}-prepare-dirs
506 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
507 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
510 %exclude %{_datadir}/%{name}/include
511 %{_mandir}/man8/%{name}.8.gz
512 %{_mandir}/man8/%{name}-enable-feature.8.gz
513 %{_mandir}/man8/%{name}-disable-feature.8.gz
514 %{_mandir}/man8/%{name}-build-ca.8.gz
515 %{_mandir}/man8/%{name}-build-key.8.gz
516 %{_mandir}/man8/%{name}-sign-key.8.gz
517 %{_mandir}/man8/%{name}-prepare-dirs.8.gz
519 %attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/cache/%{name}
520 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
521 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
522 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
523 %attr(0755,%{icinga_user},%{icinga_group}) %ghost %{_localstatedir}/run/%{name}
524 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
526 %attr(2755,%{icinga_user},%{icingacmd_group}) %ghost %{_localstatedir}/run/icinga2/cmd
529 %defattr(-,root,root,-)
530 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog tools/syntax
531 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
532 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
533 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
534 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
535 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
536 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
537 %{_datadir}/%{name}/include
540 %defattr(-,root,root,-)
541 %{_datadir}/doc/%{name}
542 %docdir %{_datadir}/doc/%{name}
545 %defattr(-,root,root,-)
546 %doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
547 %{_libdir}/%{name}/libdb_ido_mysql*
550 %defattr(-,root,root,-)
551 %doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
552 %{_libdir}/%{name}/libdb_ido_pgsql*
554 %files classicui-config
555 %defattr(-,root,root,-)
556 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
557 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
558 %config(noreplace) %{apacheconfdir}/icinga.conf
559 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd