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
88 BuildRequires: openssl-devel
89 BuildRequires: gcc-c++
90 BuildRequires: libstdc++-devel
92 BuildRequires: flex >= 2.5.35
96 %if "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
98 BuildRequires: boost141-devel
100 BuildRequires: boost-devel >= 1.41
104 BuildRequires: systemd
108 Requires: %{name}-common = %{version}-%{release}
111 Icinga 2 is a general-purpose network monitoring application.
112 Provides binaries and libraries for Icinga 2 Core.
115 Summary: Common Icinga 2 configuration
116 Group: Applications/System
117 %if "%{_vendor}" == "redhat"
118 Requires(pre): shadow-utils
119 Requires(post): shadow-utils
121 %if "%{_vendor}" == "suse"
122 Recommends: logrotate
126 Provides common directories, uid and gid among Icinga 2 related
131 Summary: Documentation for Icinga 2
132 Group: Applications/System
133 Requires: %{name} = %{version}-%{release}
136 Provides documentation for Icinga 2.
140 Summary: IDO MySQL database backend for Icinga 2
141 Group: Applications/System
142 %if "%{_vendor}" == "suse"
143 BuildRequires: libmysqlclient-devel
145 BuildRequires: mysql-devel
146 Requires: %{name} = %{version}-%{release}
148 %description ido-mysql
149 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
150 IDOUtils schema >= 1.10
154 Summary: IDO PostgreSQL database backend for Icinga 2
155 Group: Applications/System
156 BuildRequires: postgresql-devel
157 Requires: %{name} = %{version}-%{release}
159 %description ido-pgsql
160 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
161 IDOUtils schema >= 1.10
164 %package classicui-config
165 Summary: Icinga 2 Classic UI Standalone configuration
166 Group: Applications/System
167 BuildRequires: %{apachename}
168 Requires: %{apachename}
169 Requires: %{name} = %{version}-%{release}
170 %if "%{_vendor}" == "suse"
171 Recommends: icinga-www
173 Provides: icinga-classicui-config
174 Conflicts: icinga-gui-config
176 %description classicui-config
177 Icinga 1.x Classic UI Standalone configuration with locations
182 %setup -q -n %{name}-%{version}
185 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
186 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
187 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
188 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
189 -DCMAKE_VERBOSE_MAKEFILE=ON \
190 -DBoost_NO_BOOST_CMAKE=ON \
191 -DICINGA2_RUNDIR=%{_rundir} \
192 -DICINGA2_USER=%{icinga_user} \
193 -DICINGA2_GROUP=%{icinga_group} \
194 -DICINGA2_COMMAND_GROUP=%{icingacmd_group} \
195 -DICINGA2_UNITY_BUILD=TRUE"
196 %if "%{_vendor}" == "redhat"
197 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
198 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
199 # details in https://dev.icinga.org/issues/5033
200 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
201 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
202 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
203 -DBoost_NO_SYSTEM_PATHS=TRUE \
204 -DBUILD_TESTING=FALSE \
205 -DBoost_NO_BOOST_CMAKE=TRUE"
209 %if "%{_vendor}" != "suse"
210 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
212 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
216 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
219 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
226 DESTDIR="%{buildroot}"
228 # install classicui config
229 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
230 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
231 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
233 # remove features-enabled symlinks
234 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
236 # enable suse rc links
237 %if "%{_vendor}" == "suse"
239 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
241 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
243 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
244 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
249 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
252 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
253 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
254 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}
257 %if "%{_vendor}" == "suse"
259 %verify_permissions -e %{_rundir}/%{name}/cmd
263 %if "%{_vendor}" == "suse"
266 %service_add_pre %{name}.service
272 %if "%{_vendor}" == "suse"
273 %if 0%{?suse_version} >= 1310
274 %set_permissions %{_rundir}/%{name}/cmd
278 %service_add_post %{name}.service
280 %fillup_and_insserv %{name}
283 # initial installation, enable default features
284 for feature in checker notification mainlog; do
285 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
294 %systemd_post %{name}.service
296 /sbin/chkconfig --add %{name}
301 # initial installation, enable default features
302 for feature in checker notification mainlog; do
303 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
314 %if "%{_vendor}" == "suse"
315 %if 0%{?using_systemd}
316 %service_del_postun %{name}.service
318 %restart_on_update %{name}
326 %systemd_postun_with_restart %{name}.service
328 if [ "$1" -ge "1" ]; then
329 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
336 if [ "$1" = "0" ]; then
337 # deinstallation of the package - remove enabled features
338 rm -rf %{_sysconfdir}/%{name}/features-enabled
345 %if "%{_vendor}" == "suse"
348 %service_del_preun %{name}.service
350 %stop_on_removal %{name}
359 %systemd_preun %{name}.service
361 if [ "$1" = "0" ]; then
362 /sbin/service %{name} stop > /dev/null 2>&1 || :
363 /sbin/chkconfig --del %{name} || :
375 # initial installation, enable ido-mysql feature
376 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
382 if [ "$1" = "0" ]; then
383 # deinstallation of the package - remove feature
384 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
392 # initial installation, enable ido-pgsql feature
393 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
399 if [ "$1" = "0" ]; then
400 # deinstallation of the package - remove feature
401 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
406 %post classicui-config
409 # initial installation, enable features
410 for feature in statusdata compatlog command; do
411 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
417 %postun classicui-config
418 if [ "$1" = "0" ]; then
419 # deinstallation of the package - remove feature
420 for feature in statusdata compatlog command; do
421 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
428 %defattr(-,root,root,-)
432 %defattr(-,root,root,-)
433 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
435 %{_sbindir}/%{name}-prepare-dirs
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 %{_sbindir}/%{name}-prepare-dirs
487 %{_mandir}/man8/%{name}-prepare-dirs.8.gz
488 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
489 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
490 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
491 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
492 %{_datadir}/%{name}/include
495 %defattr(-,root,root,-)
496 %{_datadir}/doc/%{name}
497 %docdir %{_datadir}/doc/%{name}
500 %defattr(-,root,root,-)
501 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
502 %{_libdir}/%{name}/libdb_ido_mysql*
503 %{_datadir}/icinga2-ido-mysql
506 %defattr(-,root,root,-)
507 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
508 %{_libdir}/%{name}/libdb_ido_pgsql*
509 %{_datadir}/icinga2-ido-pgsql
511 %files classicui-config
512 %defattr(-,root,root,-)
513 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
514 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
515 %config(noreplace) %{apacheconfdir}/icinga.conf
516 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd