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
40 %if "%{_vendor}" == "suse"
41 %define apachename apache2
42 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
43 %define apacheuser wwwrun
44 %define apachegroup www
45 %if 0%{?suse_version} >= 1310
52 %define icinga_user icinga
53 %define icinga_group icinga
54 %define icingacmd_group icingacmd
55 %define icingaweb2name icingaweb2
56 %define icingaweb2version 2.0.0
58 %define icingaclassicconfdir %{_sysconfdir}/icinga
60 %define logmsg logger -t %{name}/rpm
62 Summary: Network monitoring application
65 Release: %{revision}%{?dist}
67 Group: Applications/System
68 Source: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz
69 URL: http://www.icinga.org/
70 BuildRoot: %{_tmppath}/%{name}-%{version}-build
71 Requires: %{name}-bin = %{version}-%{release}
74 Meta package for Icinga 2 Core, DB IDO and Web.
77 Summary: Icinga 2 binaries and libraries
78 Group: Applications/System
80 %if "%{_vendor}" == "suse"
82 Provides: monitoring_daemon
83 Recommends: monitoring-plugins
85 BuildRequires: openssl-devel
86 BuildRequires: gcc-c++
87 BuildRequires: libstdc++-devel
89 BuildRequires: flex >= 2.5.35
93 %if "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
95 BuildRequires: boost141-devel
97 BuildRequires: boost-devel >= 1.41
98 BuildRequires: boost-static >= 1.41
102 BuildRequires: systemd
106 Requires: %{name}-common = %{version}-%{release}
109 Icinga 2 is a general-purpose network monitoring application.
110 Provides binaries and libraries for Icinga 2 Core.
113 Summary: Common Icinga 2 configuration
114 Group: Applications/System
115 %if "%{_vendor}" == "redhat"
116 Requires(pre): shadow-utils
117 Requires(post): shadow-utils
119 %if "%{_vendor}" == "suse"
120 Recommends: logrotate
124 Provides common directories, uid and gid among Icinga 2 related
129 Summary: Documentation for Icinga 2
130 Group: Applications/System
131 Requires: %{name} = %{version}-%{release}
134 Provides documentation for Icinga 2.
138 Summary: IDO MySQL database backend for Icinga 2
139 Group: Applications/System
140 %if "%{_vendor}" == "suse"
141 BuildRequires: libmysqlclient-devel
143 BuildRequires: mysql-devel
144 Requires: %{name} = %{version}-%{release}
146 %description ido-mysql
147 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
148 IDOUtils schema >= 1.10
152 Summary: IDO PostgreSQL database backend for Icinga 2
153 Group: Applications/System
154 BuildRequires: postgresql-devel
155 Requires: %{name} = %{version}-%{release}
157 %description ido-pgsql
158 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
159 IDOUtils schema >= 1.10
162 %package classicui-config
163 Summary: Icinga 2 Classic UI Standalone configuration
164 Group: Applications/System
165 BuildRequires: %{apachename}
166 Requires: %{apachename}
167 Requires: %{name} = %{version}-%{release}
168 %if "%{_vendor}" == "suse"
169 Recommends: icinga-www
171 Provides: icinga-classicui-config
172 Conflicts: icinga-gui-config
174 %description classicui-config
175 Icinga 1.x Classic UI Standalone configuration with locations
180 %setup -q -n %{name}-%{version}
183 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
184 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
185 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
186 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
187 -DICINGA2_RUNDIR=%{_rundir} \
188 -DICINGA2_USER=%{icinga_user} \
189 -DICINGA2_GROUP=%{icinga_group} \
190 -DICINGA2_COMMAND_GROUP=%{icingacmd_group} \
191 -DICINGA2_UNITY_BUILD=TRUE"
192 %if "%{_vendor}" == "redhat"
193 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
194 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
195 # details in https://dev.icinga.org/issues/5033
196 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
197 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
198 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
199 -DBoost_NO_SYSTEM_PATHS=TRUE \
200 -DBUILD_TESTING=FALSE \
201 -DBoost_NO_BOOST_CMAKE=TRUE"
205 %if "%{_vendor}" != "suse"
206 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
208 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
212 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
222 DESTDIR="%{buildroot}"
224 # install classicui config
225 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
226 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
227 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
229 # remove features-enabled symlinks
230 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
232 # enable suse rc links
233 %if "%{_vendor}" == "suse"
235 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
237 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
239 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
240 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
245 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
248 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
249 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
250 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}
253 %if "%{_vendor}" == "suse"
255 %verify_permissions -e %{_rundir}/%{name}/cmd
259 %if "%{_vendor}" == "suse"
262 %service_add_pre %{name}.service
267 /usr/share/icinga2/migrate-hosts
269 # all restart/feature actions belong to icinga2-bin
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 %{_sbindir}/icinga2 feature enable checker notification mainlog
292 %systemd_post %{name}.service
294 /sbin/chkconfig --add %{name}
299 # initial installation, enable default features
300 %{_sbindir}/icinga2 feature enable checker notification mainlog
310 %if "%{_vendor}" == "suse"
311 %if 0%{?using_systemd}
312 %service_del_postun %{name}.service
314 %restart_on_update %{name}
322 %systemd_postun_with_restart %{name}.service
324 if [ "$1" -ge "1" ]; then
325 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
332 if [ "$1" = "0" ]; then
333 # deinstallation of the package - remove enabled features
334 rm -rf %{_sysconfdir}/%{name}/features-enabled
341 %if "%{_vendor}" == "suse"
344 %service_del_preun %{name}.service
346 %stop_on_removal %{name}
355 %systemd_preun %{name}.service
357 if [ "$1" = "0" ]; then
358 /sbin/service %{name} stop > /dev/null 2>&1 || :
359 /sbin/chkconfig --del %{name} || :
371 # initial installation, enable ido-mysql feature
372 %{_sbindir}/icinga2 feature enable ido-mysql
378 if [ "$1" = "0" ]; then
379 # deinstallation of the package - remove feature
380 test -x %{_sbindir}/icinga2 && %{_sbindir}/icinga2 feature disable ido-mysql
388 # initial installation, enable ido-pgsql feature
389 %{_sbindir}/icinga2 feature enable ido-pgsql
395 if [ "$1" = "0" ]; then
396 # deinstallation of the package - remove feature
397 test -x %{_sbindir}/icinga2 && %{_sbindir}/icinga2 feature disable ido-pgsql
402 %post classicui-config
405 # initial installation, enable features
406 %{_sbindir}/icinga2 feature enable statusdata compatlog command
411 %postun classicui-config
412 if [ "$1" = "0" ]; then
413 # deinstallation of the package - remove feature
414 test -x %{_sbindir}/icinga2 && %{_sbindir}/icinga2 feature disable statusdata
415 test -x %{_sbindir}/icinga2 && %{_sbindir}/icinga2 feature disable compatlog
416 test -x %{_sbindir}/icinga2 && %{_sbindir}/icinga2 feature disable command
422 %defattr(-,root,root,-)
426 %defattr(-,root,root,-)
427 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
429 %attr(644,root,root) %{_unitdir}/%{name}.service
431 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
433 %if "%{_vendor}" == "suse"
434 %{_sbindir}/rc%{name}
435 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
437 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
439 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
440 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
441 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts
442 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts/localhost
443 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
444 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
445 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
446 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
447 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
448 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
449 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
450 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
451 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
452 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
453 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
454 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf
455 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf
456 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
457 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
458 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
459 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
461 %{_sbindir}/%{name}-prepare-dirs
462 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
463 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
466 %exclude %{_datadir}/%{name}/include
467 %exclude %{_datadir}/%{name}/migrate-hosts
468 %{_mandir}/man8/%{name}.8.gz
469 %{_mandir}/man8/%{name}-prepare-dirs.8.gz
471 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
472 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
473 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
474 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
475 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
477 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
478 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
481 %defattr(-,root,root,-)
482 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
483 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
484 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
485 %{_sysconfdir}/bash_completion.d/%{name}
486 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
487 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
488 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
489 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
490 %{_datadir}/%{name}/include
491 %{_datadir}/%{name}/migrate-hosts
494 %defattr(-,root,root,-)
495 %{_datadir}/doc/%{name}
496 %docdir %{_datadir}/doc/%{name}
499 %defattr(-,root,root,-)
500 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
501 %{_libdir}/%{name}/libdb_ido_mysql*
502 %{_datadir}/icinga2-ido-mysql
505 %defattr(-,root,root,-)
506 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
507 %{_libdir}/%{name}/libdb_ido_pgsql*
508 %{_datadir}/icinga2-ido-pgsql
510 %files classicui-config
511 %defattr(-,root,root,-)
512 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
513 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
514 %config(noreplace) %{apacheconfdir}/icinga.conf
515 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd