1 #/******************************************************************************
3 # * Copyright (C) 2012-2015 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 %define _libexecdir %{_prefix}/lib/
29 %if "%{_vendor}" == "redhat"
30 %define apachename httpd
31 %define apacheconfdir %{_sysconfdir}/httpd/conf.d
32 %define apacheuser apache
33 %define apachegroup apache
36 %if %(uname -m) != "x86_64"
37 %define march_flag -march=i686
45 %if "%{_vendor}" == "suse"
46 %define apachename apache2
47 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
48 %define apacheuser wwwrun
49 %define apachegroup www
50 %if 0%{?suse_version} >= 1310
57 %define icinga_user icinga
58 %define icinga_group icinga
59 %define icingacmd_group icingacmd
60 %define icingaweb2name icingaweb2
61 %define icingaweb2version 2.0.0
63 %define icingaclassicconfdir %{_sysconfdir}/icinga
65 %define logmsg logger -t %{name}/rpm
67 Summary: Network monitoring application
70 Release: %{revision}%{?dist}
72 Group: Applications/System
73 Source: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz
74 URL: https://www.icinga.org/
75 BuildRoot: %{_tmppath}/%{name}-%{version}-build
76 Requires: %{name}-bin = %{version}-%{release}
79 Meta package for Icinga 2 Core, DB IDO and Web.
82 Summary: Icinga 2 binaries and libraries
83 Group: Applications/System
85 %if "%{_vendor}" == "suse"
87 Provides: monitoring_daemon
88 Recommends: monitoring-plugins
89 %if 0%{?suse_version} >= 1310
90 BuildRequires: libyajl-devel
93 BuildRequires: libedit-devel
94 BuildRequires: ncurses-devel
95 BuildRequires: openssl-devel
96 BuildRequires: gcc-c++
97 BuildRequires: libstdc++-devel
99 BuildRequires: flex >= 2.5.35
103 %if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
104 # el5 requires packages.icinga.org
105 BuildRequires: boost153-devel
107 %if 0%{?build_icinga_org} && "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
108 # sles 11 sp3 requires packages.icinga.org
109 BuildRequires: boost153-devel
111 BuildRequires: boost-devel >= 1.41
116 BuildRequires: systemd
120 Requires: %{name}-common = %{version}-%{release}
123 Icinga 2 is a general-purpose network monitoring application.
124 Provides binaries and libraries for Icinga 2 Core.
127 Summary: Common Icinga 2 configuration
128 Group: Applications/System
129 %if "%{_vendor}" == "redhat"
130 Requires(pre): shadow-utils
131 Requires(post): shadow-utils
133 %if "%{_vendor}" == "suse"
134 Recommends: logrotate
138 Provides common directories, uid and gid among Icinga 2 related
143 Summary: Documentation for Icinga 2
144 Group: Applications/System
145 Requires: %{name} = %{version}-%{release}
148 Provides documentation for Icinga 2.
152 Summary: IDO MySQL database backend for Icinga 2
153 Group: Applications/System
154 %if "%{_vendor}" == "suse"
155 BuildRequires: libmysqlclient-devel
157 BuildRequires: mysql-devel
158 Requires: %{name} = %{version}-%{release}
160 %description ido-mysql
161 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
162 IDOUtils schema >= 1.12
166 Summary: IDO PostgreSQL database backend for Icinga 2
167 Group: Applications/System
168 BuildRequires: postgresql-devel
169 Requires: %{name} = %{version}-%{release}
171 %description ido-pgsql
172 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
173 IDOUtils schema >= 1.12
176 %package classicui-config
177 Summary: Icinga 2 Classic UI Standalone configuration
178 Group: Applications/System
179 BuildRequires: %{apachename}
180 Requires: %{apachename}
181 Requires: %{name} = %{version}-%{release}
182 %if "%{_vendor}" == "suse"
183 Recommends: icinga-www
185 Provides: icinga-classicui-config
186 Conflicts: icinga-gui-config
188 %description classicui-config
189 Icinga 1.x Classic UI Standalone configuration with locations
194 %setup -q -n %{name}-%{version}
197 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
198 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
199 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
200 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
201 -DCMAKE_VERBOSE_MAKEFILE=ON \
202 -DBoost_NO_BOOST_CMAKE=ON \
203 -DICINGA2_RUNDIR=%{_rundir} \
204 -DICINGA2_USER=%{icinga_user} \
205 -DICINGA2_GROUP=%{icinga_group} \
206 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
207 %if "%{_vendor}" == "redhat"
208 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
209 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
210 # details in https://dev.icinga.org/issues/5033
211 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
212 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
213 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
214 -DBoost_NO_SYSTEM_PATHS=TRUE \
215 -DBUILD_TESTING=FALSE \
216 -DBoost_NO_BOOST_CMAKE=TRUE"
220 %if "%{_vendor}" != "suse"
221 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
223 %if 0%{?suse_version} < 1310
224 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
225 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
226 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
227 -DBoost_NO_SYSTEM_PATHS=TRUE \
228 -DBUILD_TESTING=FALSE \
229 -DBoost_NO_BOOST_CMAKE=TRUE"
231 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
235 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
238 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
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 # remove features-enabled symlinks
253 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
255 # enable suse rc links
256 %if "%{_vendor}" == "suse"
258 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
260 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
262 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
263 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
268 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
271 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
272 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
273 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}
275 %if "%{_vendor}" == "suse"
277 %service_add_pre %{name}.service
282 %if "%{_vendor}" == "suse"
284 %verify_permissions -e %{_rundir}/%{name}/cmd
286 %if 0%{?suse_version} >= 1310
288 %set_permissions %{_rundir}/%{name}/cmd
294 %if "%{_vendor}" == "suse"
297 %service_add_post %{name}.service
299 %fillup_and_insserv %{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
313 %systemd_post %{name}.service
315 /sbin/chkconfig --add %{name}
320 # initial installation, enable default features
321 for feature in checker notification mainlog; do
322 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
333 %if "%{_vendor}" == "suse"
334 %if 0%{?using_systemd}
335 %service_del_postun %{name}.service
337 %restart_on_update %{name}
345 %systemd_postun_with_restart %{name}.service
347 if [ "$1" -ge "1" ]; then
348 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
355 if [ "$1" = "0" ]; then
356 # deinstallation of the package - remove enabled features
357 rm -rf %{_sysconfdir}/%{name}/features-enabled
364 %if "%{_vendor}" == "suse"
367 %service_del_preun %{name}.service
369 %stop_on_removal %{name}
378 %systemd_preun %{name}.service
380 if [ "$1" = "0" ]; then
381 /sbin/service %{name} stop > /dev/null 2>&1 || :
382 /sbin/chkconfig --del %{name} || :
394 # initial installation, enable ido-mysql feature
395 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
401 if [ "$1" = "0" ]; then
402 # deinstallation of the package - remove feature
403 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
411 # initial installation, enable ido-pgsql feature
412 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
418 if [ "$1" = "0" ]; then
419 # deinstallation of the package - remove feature
420 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
425 %post classicui-config
428 # initial installation, enable features
429 for feature in statusdata compatlog command; do
430 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
436 %postun classicui-config
437 if [ "$1" = "0" ]; then
438 # deinstallation of the package - remove feature
439 for feature in statusdata compatlog command; do
440 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
447 %defattr(-,root,root,-)
451 %defattr(-,root,root,-)
452 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
454 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
455 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
456 %dir %{_libdir}/%{name}
457 %{_libdir}/%{name}/*.so*
458 %dir %{_libdir}/%{name}/sbin
459 %{_libdir}/%{name}/sbin/%{name}
461 %exclude %{_datadir}/%{name}/include
462 %{_mandir}/man8/%{name}.8.gz
464 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
465 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
466 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
467 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
468 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
469 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
471 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
472 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
475 %defattr(-,root,root,-)
476 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
477 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
478 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
479 %{_sysconfdir}/bash_completion.d/%{name}
481 %attr(644,root,root) %{_unitdir}/%{name}.service
483 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
485 %if "%{_vendor}" == "suse"
486 %{_sbindir}/rc%{name}
487 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
489 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
491 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
492 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
493 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
494 %exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
495 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
496 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
497 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
498 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
499 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
500 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
501 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
502 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
503 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
504 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
505 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
506 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
507 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
508 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
509 %dir %{_libexecdir}/%{name}
510 %{_libexecdir}/%{name}/prepare-dirs
511 %{_libexecdir}/%{name}/safe-reload
512 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
513 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
514 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
515 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
516 %{_datadir}/%{name}/include
519 %defattr(-,root,root,-)
520 %{_datadir}/doc/%{name}
521 %docdir %{_datadir}/doc/%{name}
524 %defattr(-,root,root,-)
525 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
526 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-mysql.conf
527 %{_libdir}/%{name}/libdb_ido_mysql*
528 %{_datadir}/icinga2-ido-mysql
531 %defattr(-,root,root,-)
532 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
533 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-pgsql.conf
534 %{_libdir}/%{name}/libdb_ido_pgsql*
535 %{_datadir}/icinga2-ido-pgsql
537 %files classicui-config
538 %defattr(-,root,root,-)
539 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
540 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
541 %config(noreplace) %{apacheconfdir}/icinga.conf
542 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd