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 %if "%{_vendor}" == "suse" && 0%{?suse_version} < 1210
96 BuildRequires: gcc47-c++
97 BuildRequires: libstdc++47-devel
98 BuildRequires: libopenssl1-devel
100 BuildRequires: gcc-c++
101 BuildRequires: libstdc++-devel
102 BuildRequires: openssl-devel
105 BuildRequires: flex >= 2.5.35
109 %if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
110 # el5 and el6 require packages.icinga.org
111 BuildRequires: boost153-devel
113 %if 0%{?build_icinga_org} && "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
114 # sles 11 sp3 requires packages.icinga.org
115 BuildRequires: boost153-devel
117 BuildRequires: boost-devel >= 1.41
122 BuildRequires: systemd
126 Requires: %{name}-common = %{version}-%{release}
129 Icinga 2 is a general-purpose network monitoring application.
130 Provides binaries and libraries for Icinga 2 Core.
133 Summary: Common Icinga 2 configuration
134 Group: Applications/System
135 %if "%{_vendor}" == "redhat"
136 Requires(pre): shadow-utils
137 Requires(post): shadow-utils
139 %if "%{_vendor}" == "suse"
140 Recommends: logrotate
144 Provides common directories, uid and gid among Icinga 2 related
149 Summary: Documentation for Icinga 2
150 Group: Applications/System
151 Requires: %{name} = %{version}-%{release}
154 Provides documentation for Icinga 2.
158 Summary: IDO MySQL database backend for Icinga 2
159 Group: Applications/System
160 %if "%{_vendor}" == "suse"
161 BuildRequires: libmysqlclient-devel
162 %if 0%{?suse_version} >= 1310
163 BuildRequires: mysql-devel
167 BuildRequires: mysql-devel
170 Requires: %{name} = %{version}-%{release}
172 %description ido-mysql
173 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
174 IDOUtils schema >= 1.12
178 Summary: IDO PostgreSQL database backend for Icinga 2
179 Group: Applications/System
180 BuildRequires: postgresql-devel
181 Requires: %{name} = %{version}-%{release}
183 %description ido-pgsql
184 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
185 IDOUtils schema >= 1.12
188 %package classicui-config
189 Summary: Icinga 2 Classic UI Standalone configuration
190 Group: Applications/System
191 BuildRequires: %{apachename}
192 Requires: %{apachename}
193 Requires: %{name} = %{version}-%{release}
194 %if "%{_vendor}" == "suse"
195 Recommends: icinga-www
197 Provides: icinga-classicui-config
198 Conflicts: icinga-gui-config
200 %description classicui-config
201 Icinga 1.x Classic UI Standalone configuration with locations
204 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
205 %global selinux_variants mls targeted
206 %{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null)}
207 %global modulename %{name}
210 Summary: SELinux policy module supporting icinga2
211 Group: System Environment/Base
212 BuildRequires: checkpolicy, selinux-policy-devel, /usr/share/selinux/devel/policyhelp, hardlink
213 %if "%{_selinux_policy_version}" != ""
214 Requires: selinux-policy >= %{_selinux_policy_version}
216 Requires: %{name} = %{version}-%{release}
217 Requires(post): /usr/sbin/semodule, /sbin/restorecon
218 Requires(postun): /usr/sbin/semodule, /sbin/restorecon
221 SELinux policy module supporting icinga2
226 %setup -q -n %{name}-%{version}
229 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
230 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
231 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
232 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
233 -DCMAKE_VERBOSE_MAKEFILE=ON \
234 -DBoost_NO_BOOST_CMAKE=ON \
235 -DICINGA2_RUNDIR=%{_rundir} \
236 -DICINGA2_USER=%{icinga_user} \
237 -DICINGA2_GROUP=%{icinga_group} \
238 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
239 %if "%{_vendor}" == "redhat"
240 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
241 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
242 # details in https://dev.icinga.org/issues/5033
243 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
244 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
245 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
246 -DBoost_NO_SYSTEM_PATHS=TRUE \
247 -DBUILD_TESTING=FALSE \
248 -DBoost_NO_BOOST_CMAKE=TRUE"
250 %if 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
251 CMAKE_OPTS="$CMAKE_OPTS -DBUILD_TESTING=FALSE"
255 %if "%{_vendor}" != "suse"
256 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
258 %if 0%{?suse_version} < 1310
259 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
260 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
261 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
262 -DBoost_NO_SYSTEM_PATHS=TRUE \
263 -DBUILD_TESTING=FALSE \
264 -DBoost_NO_BOOST_CMAKE=TRUE"
266 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
270 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
273 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
277 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
279 for selinuxvariant in %{selinux_variants}
281 make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
282 mv %{modulename}.pp %{modulename}.pp.${selinuxvariant}
283 make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
290 DESTDIR="%{buildroot}"
292 # install classicui config
293 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
294 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
295 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
297 # remove features-enabled symlinks
298 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
300 # enable suse rc links
301 %if "%{_vendor}" == "suse"
303 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
305 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
307 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
308 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
311 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
313 for selinuxvariant in %{selinux_variants}
315 install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
316 install -p -m 644 %{modulename}.pp.${selinuxvariant} \
317 %{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp
321 /usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
325 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
328 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
329 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
330 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}
332 %if "%{_vendor}" == "suse"
334 %service_add_pre %{name}.service
338 %if "%{_vendor}" == "suse"
340 %verify_permissions -e %{_rundir}/%{name}/cmd
345 # install the api setup
346 %{_sbindir}/%{name} api setup
349 %if "%{_vendor}" == "suse"
351 %if 0%{?suse_version} >= 1310
352 %set_permissions %{_rundir}/%{name}/cmd
359 %if "%{_vendor}" == "suse"
362 %service_add_post %{name}.service
364 %fillup_and_insserv %{name}
367 # initial installation, enable default features
368 for feature in checker notification mainlog; do
369 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
378 %systemd_post %{name}.service
380 /sbin/chkconfig --add %{name}
385 # initial installation, enable default features
386 for feature in checker notification mainlog; do
387 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
398 %if "%{_vendor}" == "suse"
399 %if 0%{?using_systemd}
400 %service_del_postun %{name}.service
402 %restart_on_update %{name}
410 %systemd_postun_with_restart %{name}.service
412 if [ "$1" -ge "1" ]; then
413 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
420 if [ "$1" = "0" ]; then
421 # deinstallation of the package - remove enabled features
422 rm -rf %{_sysconfdir}/%{name}/features-enabled
429 %if "%{_vendor}" == "suse"
432 %service_del_preun %{name}.service
434 %stop_on_removal %{name}
443 %systemd_preun %{name}.service
445 if [ "$1" = "0" ]; then
446 /sbin/service %{name} stop > /dev/null 2>&1 || :
447 /sbin/chkconfig --del %{name} || :
459 # initial installation, enable ido-mysql feature
460 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
466 if [ "$1" = "0" ]; then
467 # deinstallation of the package - remove feature
468 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
476 # initial installation, enable ido-pgsql feature
477 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
483 if [ "$1" = "0" ]; then
484 # deinstallation of the package - remove feature
485 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
490 %post classicui-config
493 # initial installation, enable features
494 for feature in statusdata compatlog command; do
495 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
501 %postun classicui-config
502 if [ "$1" = "0" ]; then
503 # deinstallation of the package - remove feature
504 for feature in statusdata compatlog command; do
505 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
511 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
513 for selinuxvariant in %{selinux_variants}
515 /usr/sbin/semodule -s ${selinuxvariant} -i \
516 %{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp &> /dev/null || :
518 /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
519 /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
520 /sbin/semanage port -a -t icinga2_port_t -p tcp 5665 &> /dev/null || :
523 if [ $1 -eq 0 ] ; then
524 /sbin/semanage port -d -t icinga2_port_t -p tcp 5665 &> /dev/null || :
525 for selinuxvariant in %{selinux_variants}
527 /usr/sbin/semodule -s ${selinuxvariant} -r %{modulename} &> /dev/null || :
529 /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
530 /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
536 %defattr(-,root,root,-)
540 %defattr(-,root,root,-)
541 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
543 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
544 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
545 %dir %{_libdir}/%{name}
546 %{_libdir}/%{name}/*.so*
547 %dir %{_libdir}/%{name}/sbin
548 %{_libdir}/%{name}/sbin/%{name}
550 %exclude %{_datadir}/%{name}/include
551 %{_mandir}/man8/%{name}.8.gz
553 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
554 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
555 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
556 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
557 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
558 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
560 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
561 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
564 %defattr(-,root,root,-)
565 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
566 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
567 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
568 %{_sysconfdir}/bash_completion.d/%{name}
570 %attr(644,root,root) %{_unitdir}/%{name}.service
572 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
574 %if "%{_vendor}" == "suse"
575 %{_sbindir}/rc%{name}
576 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
578 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
580 %attr(0750,root,%{icinga_group}) %dir %{_sysconfdir}/%{name}
581 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
582 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
583 %exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
584 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
585 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
586 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
587 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
588 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
589 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
590 %config(noreplace) %attr(0640,root,%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
591 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
592 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
593 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
594 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
595 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
596 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
597 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
598 %dir %{_libexecdir}/%{name}
599 %{_libexecdir}/%{name}/prepare-dirs
600 %{_libexecdir}/%{name}/safe-reload
601 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
602 %attr(0770,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
603 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
604 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
605 %{_datadir}/%{name}/include
608 %defattr(-,root,root,-)
609 %{_datadir}/doc/%{name}
610 %docdir %{_datadir}/doc/%{name}
613 %defattr(-,root,root,-)
614 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
615 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-mysql.conf
616 %{_libdir}/%{name}/libdb_ido_mysql*
617 %{_datadir}/icinga2-ido-mysql
620 %defattr(-,root,root,-)
621 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
622 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-pgsql.conf
623 %{_libdir}/%{name}/libdb_ido_pgsql*
624 %{_datadir}/icinga2-ido-pgsql
626 %files classicui-config
627 %defattr(-,root,root,-)
628 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
629 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
630 %config(noreplace) %{apacheconfdir}/icinga.conf
631 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
633 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
635 %defattr(-,root,root,0755)
637 %{_datadir}/selinux/*/%{modulename}.pp