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" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
104 # el5 and el6 require 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
156 %if 0%{?suse_version} >= 1310
157 BuildRequires: mysql-devel
161 BuildRequires: mysql-devel
164 Requires: %{name} = %{version}-%{release}
166 %description ido-mysql
167 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
168 IDOUtils schema >= 1.12
172 Summary: IDO PostgreSQL database backend for Icinga 2
173 Group: Applications/System
174 BuildRequires: postgresql-devel
175 Requires: %{name} = %{version}-%{release}
177 %description ido-pgsql
178 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
179 IDOUtils schema >= 1.12
182 %package classicui-config
183 Summary: Icinga 2 Classic UI Standalone configuration
184 Group: Applications/System
185 BuildRequires: %{apachename}
186 Requires: %{apachename}
187 Requires: %{name} = %{version}-%{release}
188 %if "%{_vendor}" == "suse"
189 Recommends: icinga-www
191 Provides: icinga-classicui-config
192 Conflicts: icinga-gui-config
194 %description classicui-config
195 Icinga 1.x Classic UI Standalone configuration with locations
198 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
199 %global selinux_variants mls targeted
200 %{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null)}
201 %global modulename %{name}
204 Summary: SELinux policy module supporting icinga2
205 Group: System Environment/Base
206 BuildRequires: checkpolicy, selinux-policy-devel, /usr/share/selinux/devel/policyhelp, hardlink
207 %if "%{_selinux_policy_version}" != ""
208 Requires: selinux-policy >= %{_selinux_policy_version}
210 Requires: %{name} = %{version}-%{release}
211 Requires(post): /usr/sbin/semodule, /sbin/restorecon
212 Requires(postun): /usr/sbin/semodule, /sbin/restorecon
215 SELinux policy module supporting icinga2
220 %setup -q -n %{name}-%{version}
223 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
224 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
225 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
226 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
227 -DCMAKE_VERBOSE_MAKEFILE=ON \
228 -DBoost_NO_BOOST_CMAKE=ON \
229 -DICINGA2_RUNDIR=%{_rundir} \
230 -DICINGA2_USER=%{icinga_user} \
231 -DICINGA2_GROUP=%{icinga_group} \
232 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
233 %if "%{_vendor}" == "redhat"
234 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
235 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
236 # details in https://dev.icinga.org/issues/5033
237 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
238 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
239 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
240 -DBoost_NO_SYSTEM_PATHS=TRUE \
241 -DBUILD_TESTING=FALSE \
242 -DBoost_NO_BOOST_CMAKE=TRUE"
244 %if 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
245 CMAKE_OPTS="$CMAKE_OPTS -DBUILD_TESTING=FALSE"
249 %if "%{_vendor}" != "suse"
250 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
252 %if 0%{?suse_version} < 1310
253 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
254 -DBOOST_INCLUDEDIR=/usr/include/boost153 \
255 -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
256 -DBoost_NO_SYSTEM_PATHS=TRUE \
257 -DBUILD_TESTING=FALSE \
258 -DBoost_NO_BOOST_CMAKE=TRUE"
260 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
264 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
267 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
271 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
273 for selinuxvariant in %{selinux_variants}
275 make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
276 mv %{modulename}.pp %{modulename}.pp.${selinuxvariant}
277 make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
284 DESTDIR="%{buildroot}"
286 # install classicui config
287 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
288 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
289 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
291 # remove features-enabled symlinks
292 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
294 # enable suse rc links
295 %if "%{_vendor}" == "suse"
297 ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
299 ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
301 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
302 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
305 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
307 for selinuxvariant in %{selinux_variants}
309 install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
310 install -p -m 644 %{modulename}.pp.${selinuxvariant} \
311 %{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp
315 /usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
319 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
322 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
323 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
324 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}
326 %if "%{_vendor}" == "suse"
328 %service_add_pre %{name}.service
332 %if "%{_vendor}" == "suse"
334 %verify_permissions -e %{_rundir}/%{name}/cmd
339 # install the api setup
340 %{_sbindir}/%{name} api setup
343 %if "%{_vendor}" == "suse"
345 %if 0%{?suse_version} >= 1310
346 %set_permissions %{_rundir}/%{name}/cmd
353 %if "%{_vendor}" == "suse"
356 %service_add_post %{name}.service
358 %fillup_and_insserv %{name}
361 # initial installation, enable default features
362 for feature in checker notification mainlog; do
363 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
372 %systemd_post %{name}.service
374 /sbin/chkconfig --add %{name}
379 # initial installation, enable default features
380 for feature in checker notification mainlog; do
381 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
392 %if "%{_vendor}" == "suse"
393 %if 0%{?using_systemd}
394 %service_del_postun %{name}.service
396 %restart_on_update %{name}
404 %systemd_postun_with_restart %{name}.service
406 if [ "$1" -ge "1" ]; then
407 /sbin/service %{name} condrestart >/dev/null 2>&1 || :
414 if [ "$1" = "0" ]; then
415 # deinstallation of the package - remove enabled features
416 rm -rf %{_sysconfdir}/%{name}/features-enabled
423 %if "%{_vendor}" == "suse"
426 %service_del_preun %{name}.service
428 %stop_on_removal %{name}
437 %systemd_preun %{name}.service
439 if [ "$1" = "0" ]; then
440 /sbin/service %{name} stop > /dev/null 2>&1 || :
441 /sbin/chkconfig --del %{name} || :
453 # initial installation, enable ido-mysql feature
454 ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
460 if [ "$1" = "0" ]; then
461 # deinstallation of the package - remove feature
462 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
470 # initial installation, enable ido-pgsql feature
471 ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
477 if [ "$1" = "0" ]; then
478 # deinstallation of the package - remove feature
479 rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
484 %post classicui-config
487 # initial installation, enable features
488 for feature in statusdata compatlog command; do
489 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
495 %postun classicui-config
496 if [ "$1" = "0" ]; then
497 # deinstallation of the package - remove feature
498 for feature in statusdata compatlog command; do
499 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
505 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
507 for selinuxvariant in %{selinux_variants}
509 /usr/sbin/semodule -s ${selinuxvariant} -i \
510 %{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp &> /dev/null || :
512 /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
513 /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
514 /sbin/semanage port -a -t icinga2_port_t -p tcp 5665 &> /dev/null || :
517 if [ $1 -eq 0 ] ; then
518 /sbin/semanage port -d -t icinga2_port_t -p tcp 5665 &> /dev/null || :
519 for selinuxvariant in %{selinux_variants}
521 /usr/sbin/semodule -s ${selinuxvariant} -r %{modulename} &> /dev/null || :
523 /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
524 /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
530 %defattr(-,root,root,-)
534 %defattr(-,root,root,-)
535 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
537 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
538 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
539 %dir %{_libdir}/%{name}
540 %{_libdir}/%{name}/*.so*
541 %dir %{_libdir}/%{name}/sbin
542 %{_libdir}/%{name}/sbin/%{name}
544 %exclude %{_datadir}/%{name}/include
545 %{_mandir}/man8/%{name}.8.gz
547 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
548 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
549 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
550 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
551 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
552 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
554 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
555 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
558 %defattr(-,root,root,-)
559 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
560 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
561 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
562 %{_sysconfdir}/bash_completion.d/%{name}
564 %attr(644,root,root) %{_unitdir}/%{name}.service
566 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
568 %if "%{_vendor}" == "suse"
569 %{_sbindir}/rc%{name}
570 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
572 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
574 %attr(0750,root,%{icinga_group}) %dir %{_sysconfdir}/%{name}
575 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
576 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
577 %exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
578 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
579 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
580 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
581 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
582 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
583 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
584 %config(noreplace) %attr(0640,root,%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
585 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
586 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
587 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
588 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
589 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
590 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
591 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
592 %dir %{_libexecdir}/%{name}
593 %{_libexecdir}/%{name}/prepare-dirs
594 %{_libexecdir}/%{name}/safe-reload
595 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
596 %attr(0770,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
597 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
598 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
599 %{_datadir}/%{name}/include
602 %defattr(-,root,root,-)
603 %{_datadir}/doc/%{name}
604 %docdir %{_datadir}/doc/%{name}
607 %defattr(-,root,root,-)
608 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
609 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-mysql.conf
610 %{_libdir}/%{name}/libdb_ido_mysql*
611 %{_datadir}/icinga2-ido-mysql
614 %defattr(-,root,root,-)
615 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
616 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-pgsql.conf
617 %{_libdir}/%{name}/libdb_ido_pgsql*
618 %{_datadir}/icinga2-ido-pgsql
620 %files classicui-config
621 %defattr(-,root,root,-)
622 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
623 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
624 %config(noreplace) %{apacheconfdir}/icinga.conf
625 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
627 %if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
629 %defattr(-,root,root,0755)
631 %{_datadir}/selinux/*/%{modulename}.pp