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 %if "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
97 BuildRequires: gcc47-c++
98 BuildRequires: libstdc++47-devel
100 BuildRequires: gcc-c++
101 BuildRequires: libstdc++-devel
104 BuildRequires: flex >= 2.5.35
108 %if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
109 # el5 and el6 require packages.icinga.org
110 BuildRequires: boost153-devel
112 %if 0%{?build_icinga_org} && "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
113 # sles 11 sp3 requires packages.icinga.org
114 BuildRequires: boost153-devel
116 BuildRequires: boost-devel >= 1.41
121 BuildRequires: systemd
125 Requires: %{name}-common = %{version}-%{release}
128 Icinga 2 is a general-purpose network monitoring application.
129 Provides binaries and libraries for Icinga 2 Core.
132 Summary: Common Icinga 2 configuration
133 Group: Applications/System
134 %if "%{_vendor}" == "redhat"
135 Requires(pre): shadow-utils
136 Requires(post): shadow-utils
138 %if "%{_vendor}" == "suse"
139 Recommends: logrotate
143 Provides common directories, uid and gid among Icinga 2 related
148 Summary: Documentation for Icinga 2
149 Group: Applications/System
150 Requires: %{name} = %{version}-%{release}
153 Provides documentation for Icinga 2.
157 Summary: IDO MySQL database backend for Icinga 2
158 Group: Applications/System
159 %if "%{_vendor}" == "suse"
160 BuildRequires: libmysqlclient-devel
161 %if 0%{?suse_version} >= 1310
162 BuildRequires: mysql-devel
166 BuildRequires: mysql-devel
169 Requires: %{name} = %{version}-%{release}
171 %description ido-mysql
172 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
173 IDOUtils schema >= 1.12
177 Summary: IDO PostgreSQL database backend for Icinga 2
178 Group: Applications/System
179 BuildRequires: postgresql-devel
180 Requires: %{name} = %{version}-%{release}
182 %description ido-pgsql
183 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
184 IDOUtils schema >= 1.12
187 %package classicui-config
188 Summary: Icinga 2 Classic UI Standalone configuration
189 Group: Applications/System
190 BuildRequires: %{apachename}
191 Requires: %{apachename}
192 Requires: %{name} = %{version}-%{release}
193 %if "%{_vendor}" == "suse"
194 Recommends: icinga-www
196 Provides: icinga-classicui-config
197 Conflicts: icinga-gui-config
199 %description classicui-config
200 Icinga 1.x Classic UI Standalone configuration with locations
203 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
204 %global selinux_variants mls targeted
205 %{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null)}
206 %global modulename %{name}
209 Summary: SELinux policy module supporting icinga2
210 Group: System Environment/Base
211 BuildRequires: checkpolicy, selinux-policy-devel, /usr/share/selinux/devel/policyhelp, hardlink
212 %if "%{_selinux_policy_version}" != ""
213 Requires: selinux-policy >= %{_selinux_policy_version}
215 Requires: %{name} = %{version}-%{release}
216 Requires(post): /usr/sbin/semodule, /sbin/restorecon
217 Requires(postun): /usr/sbin/semodule, /sbin/restorecon
220 SELinux policy module supporting icinga2
225 %setup -q -n %{name}-%{version}
228 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
229 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
230 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
231 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
232 -DCMAKE_VERBOSE_MAKEFILE=ON \
233 -DBoost_NO_BOOST_CMAKE=ON \
234 -DICINGA2_RUNDIR=%{_rundir} \
235 -DICINGA2_USER=%{icinga_user} \
236 -DICINGA2_GROUP=%{icinga_group} \
237 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
238 %if "%{_vendor}" == "redhat"
239 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
240 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
241 # details in https://dev.icinga.org/issues/5033
242 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
243 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
244 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
245 -DBoost_NO_SYSTEM_PATHS=TRUE \
246 -DBUILD_TESTING=FALSE \
247 -DBoost_NO_BOOST_CMAKE=TRUE"
249 %if 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
250 CMAKE_OPTS="$CMAKE_OPTS -DBUILD_TESTING=FALSE"
254 %if "%{_vendor}" != "suse"
255 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
257 %if 0%{?suse_version} < 1310
258 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
259 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
260 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
261 -DBoost_NO_SYSTEM_PATHS=TRUE \
262 -DBUILD_TESTING=FALSE \
263 -DBoost_NO_BOOST_CMAKE=TRUE"
265 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
269 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
272 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
276 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
278 for selinuxvariant in %{selinux_variants}
280 make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
281 mv %{modulename}.pp %{modulename}.pp.${selinuxvariant}
282 make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
289 DESTDIR="%{buildroot}"
291 # install classicui config
292 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
293 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
294 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
296 # remove features-enabled symlinks
297 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
299 # enable suse rc links
300 %if "%{_vendor}" == "suse"
302 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
304 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
306 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
307 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
310 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
312 for selinuxvariant in %{selinux_variants}
314 install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
315 install -p -m 644 %{modulename}.pp.${selinuxvariant} \
316 %{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp
320 /usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
324 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
327 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
328 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
329 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}
331 %if "%{_vendor}" == "suse"
333 %service_add_pre %{name}.service
337 %if "%{_vendor}" == "suse"
339 %verify_permissions -e %{_rundir}/%{name}/cmd
344 # install the api setup
345 %{_sbindir}/%{name} api setup
348 %if "%{_vendor}" == "suse"
350 %if 0%{?suse_version} >= 1310
351 %set_permissions %{_rundir}/%{name}/cmd
358 %if "%{_vendor}" == "suse"
361 %service_add_post %{name}.service
363 %fillup_and_insserv %{name}
366 # initial installation, enable default features
367 for feature in checker notification mainlog; do
368 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
377 %systemd_post %{name}.service
379 /sbin/chkconfig --add %{name}
384 # initial installation, enable default features
385 for feature in checker notification mainlog; do
386 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
397 %if "%{_vendor}" == "suse"
398 %if 0%{?using_systemd}
399 %service_del_postun %{name}.service
401 %restart_on_update %{name}
409 %systemd_postun_with_restart %{name}.service
411 if [ "$1" -ge "1" ]; then
412 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
419 if [ "$1" = "0" ]; then
420 # deinstallation of the package - remove enabled features
421 rm -rf %{_sysconfdir}/%{name}/features-enabled
428 %if "%{_vendor}" == "suse"
431 %service_del_preun %{name}.service
433 %stop_on_removal %{name}
442 %systemd_preun %{name}.service
444 if [ "$1" = "0" ]; then
445 /sbin/service %{name} stop > /dev/null 2>&1 || :
446 /sbin/chkconfig --del %{name} || :
458 # initial installation, enable ido-mysql feature
459 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
465 if [ "$1" = "0" ]; then
466 # deinstallation of the package - remove feature
467 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
475 # initial installation, enable ido-pgsql feature
476 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
482 if [ "$1" = "0" ]; then
483 # deinstallation of the package - remove feature
484 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
489 %post classicui-config
492 # initial installation, enable features
493 for feature in statusdata compatlog command; do
494 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
500 %postun classicui-config
501 if [ "$1" = "0" ]; then
502 # deinstallation of the package - remove feature
503 for feature in statusdata compatlog command; do
504 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
510 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
512 for selinuxvariant in %{selinux_variants}
514 /usr/sbin/semodule -s ${selinuxvariant} -i \
515 %{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp &> /dev/null || :
517 /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
518 /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
519 /sbin/semanage port -a -t icinga2_port_t -p tcp 5665 &> /dev/null || :
522 if [ $1 -eq 0 ] ; then
523 /sbin/semanage port -d -t icinga2_port_t -p tcp 5665 &> /dev/null || :
524 for selinuxvariant in %{selinux_variants}
526 /usr/sbin/semodule -s ${selinuxvariant} -r %{modulename} &> /dev/null || :
528 /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
529 /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
535 %defattr(-,root,root,-)
539 %defattr(-,root,root,-)
540 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
542 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
543 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
544 %dir %{_libdir}/%{name}
545 %{_libdir}/%{name}/*.so*
546 %dir %{_libdir}/%{name}/sbin
547 %{_libdir}/%{name}/sbin/%{name}
549 %exclude %{_datadir}/%{name}/include
550 %{_mandir}/man8/%{name}.8.gz
552 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
553 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
554 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
555 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
556 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
557 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
559 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
560 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
563 %defattr(-,root,root,-)
564 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
565 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
566 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
567 %{_sysconfdir}/bash_completion.d/%{name}
569 %attr(644,root,root) %{_unitdir}/%{name}.service
571 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
573 %if "%{_vendor}" == "suse"
574 %{_sbindir}/rc%{name}
575 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
577 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
579 %attr(0750,root,%{icinga_group}) %dir %{_sysconfdir}/%{name}
580 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
581 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
582 %exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
583 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
584 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
585 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
586 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
587 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
588 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
589 %config(noreplace) %attr(0640,root,%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
590 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
591 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
592 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
593 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
594 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
595 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
596 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
597 %dir %{_libexecdir}/%{name}
598 %{_libexecdir}/%{name}/prepare-dirs
599 %{_libexecdir}/%{name}/safe-reload
600 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
601 %attr(0770,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
602 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
603 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
604 %{_datadir}/%{name}/include
607 %defattr(-,root,root,-)
608 %{_datadir}/doc/%{name}
609 %docdir %{_datadir}/doc/%{name}
612 %defattr(-,root,root,-)
613 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
614 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-mysql.conf
615 %{_libdir}/%{name}/libdb_ido_mysql*
616 %{_datadir}/icinga2-ido-mysql
619 %defattr(-,root,root,-)
620 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
621 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-pgsql.conf
622 %{_libdir}/%{name}/libdb_ido_pgsql*
623 %{_datadir}/icinga2-ido-pgsql
625 %files classicui-config
626 %defattr(-,root,root,-)
627 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
628 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
629 %config(noreplace) %{apacheconfdir}/icinga.conf
630 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
632 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
634 %defattr(-,root,root,0755)
636 %{_datadir}/selinux/*/%{modulename}.pp