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 %if "%{_vendor}" == "redhat"
23 %define el5_boost_version 141
24 %define el5_boost_libs %{_libdir}/boost%{el5_boost_version}
25 %define el5_boost_includes /usr/include/boost%{el5_boost_version}
26 %define apachename httpd
27 %define apacheconfdir %{_sysconfdir}/httpd/conf.d
28 %define apacheuser apache
29 %define apachegroup apache
31 %if "%{_vendor}" == "suse"
33 %if 0%{?suse_version} >= 1310
34 %define opensuse_boost_version 1_53_0
36 %define opensuse_boost_version 1_49_0
38 %define sles_boost_version 1_54_0
39 %define apachename apache2
40 %define apacheconfdir %{_sysconfdir}/apache2/conf.d
41 %define apacheuser wwwrun
42 %define apachegroup www
45 %define icinga_user icinga
46 %define icinga_group icinga
47 %define icingacmd_group icingacmd
48 %define icingaweb2name icingaweb2
49 %define icingaweb2version 2.0.0
51 %define icingaclassicconfdir %{_sysconfdir}/icinga
53 %define logmsg logger -t %{name}/rpm
55 Summary: Network monitoring application
58 Release: %{revision}%{?dist}
60 Group: Applications/System
61 Source: %{name}-%{version}.tar.gz
62 URL: http://www.icinga.org/
63 BuildRoot: %{_tmppath}/%{name}-%{version}-build
65 Requires: %{name}-bin = %{version}
66 #Requires: %{name}-ido-mysql = %{version}
67 #Requires: %{icingaweb2name} >= %{icingaweb2version}
70 Meta package for Icinga 2 Core, DB IDO and Web.
73 Summary: Icinga 2 binaries and libraries
74 Group: Applications/System
76 BuildRequires: doxygen
77 BuildRequires: openssl-devel
78 BuildRequires: gcc-c++
79 BuildRequires: libstdc++-devel
81 BuildRequires: flex >= 2.5.35
85 %if "%{_vendor}" == "redhat"
86 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
88 BuildRequires: boost%{el5_boost_version}-devel
89 BuildRequires: boost%{el5_boost_version}
90 Requires: boost%{el5_boost_version}-program-options
91 Requires: boost%{el5_boost_version}-system
92 Requires: boost%{el5_boost_version}-test
93 Requires: boost%{el5_boost_version}-thread
94 Requires: boost%{el5_boost_version}-regex
96 BuildRequires: boost-devel >= 1.41
97 Requires: boost-program-options >= 1.41
98 Requires: boost-system >= 1.41
99 Requires: boost-test >= 1.41
100 Requires: boost-thread >= 1.41
101 Requires: boost-regex >= 1.41
107 %if "%{_vendor}" == "suse"
109 # note: sles_version macro is not set in SLES11 anymore
110 # note: sles service packs are not under version control
111 %if 0%{?suse_version} == 1110
112 BuildRequires: gcc-fortran
113 BuildRequires: libgfortran43
114 BuildRequires: boost-license%{sles_boost_version}
115 BuildRequires: boost-devel >= 1.41
116 Requires: boost-license%{sles_boost_version}
117 Requires: libboost_program_options%{sles_boost_version}
118 Requires: libboost_system%{sles_boost_version}
119 Requires: libboost_test%{sles_boost_version}
120 Requires: libboost_thread%{sles_boost_version}
121 Requires: libboost_regex%{sles_boost_version}
124 %if 0%{?suse_version} >= 1210
125 BuildRequires: boost-devel >= 1.41
126 Requires: libboost_program_options%{opensuse_boost_version}
127 Requires: libboost_system%{opensuse_boost_version}
128 Requires: libboost_test%{opensuse_boost_version}
129 Requires: libboost_thread%{opensuse_boost_version}
130 Requires: libboost_regex%{opensuse_boost_version}
135 Requires: %{name}-common = %{version}
138 Icinga 2 is a general-purpose network monitoring application.
139 Provides binaries and libraries for Icinga 2 Core.
142 Summary: Common Icinga 2 configuration
143 Group: Applications/System
144 %if "%{_vendor}" == "redhat"
145 Requires(pre): shadow-utils
146 Requires(post): shadow-utils
150 Provides common directories, uid and gid among Icinga 2 related
155 Summary: Documentation for Icinga 2
156 Group: Applications/System
157 Requires: %{name} = %{version}-%{release}
160 Documentation for Icinga 2
164 Summary: IDO MySQL database backend for Icinga 2
165 Group: Applications/System
166 %if "%{_vendor}" == "suse"
167 BuildRequires: libmysqlclient-devel
168 %if 0%{?suse_version} >= 1210
169 Requires: libmysqlclient18
171 Requires: libmysqlclient15
174 %if "%{_vendor}" == "redhat"
175 # el5 only provides mysql package
176 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
179 BuildRequires: mysql-libs
182 BuildRequires: mysql-devel
185 Requires: %{name} = %{version}-%{release}
187 %description ido-mysql
188 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
189 IDOUtils schema >= 1.10
193 Summary: IDO PostgreSQL database backend for Icinga 2
194 Group: Applications/System
195 %if "%{_vendor}" == "suse"
196 BuildRequires: postgresql-libs
198 %if "%{_vendor}" == "redhat"
199 # el5 only provides mysql package
200 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
201 BuildRequires: postgresql84
204 BuildRequires: postgresql-devel
205 Requires: postgresql-libs
206 Requires: %{name} = %{version}-%{release}
208 %description ido-pgsql
209 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
210 IDOUtils schema >= 1.10
213 %package classicui-config
214 Summary: Icinga 2 Classic UI Standalone configuration
215 Group: Applications/System
216 BuildRequires: %{apachename}
217 Requires: %{apachename}
218 Requires: %{name} = %{version}-%{release}
219 Provides: icinga-classicui-config
220 Conflicts: icinga-gui-config
222 %description classicui-config
223 Icinga 1.x Classic UI Standalone configuration with locations
228 %setup -q -n %{name}-%{version}
231 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
232 -DCMAKE_INSTALL_SYSCONFDIR=/etc \
233 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
234 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
235 -DICINGA2_USER=%{icinga_user} \
236 -DICINGA2_GROUP=%{icinga_group} \
237 -DICINGA2_COMMAND_USER=%{icinga_user} \
238 -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
239 %if "%{_vendor}" == "redhat"
240 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
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/boost141 \
244 -DBOOST_INCLUDEDIR=/usr/include/boost141 \
245 -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0' \
246 -DBoost_NO_SYSTEM_PATHS=TRUE \
247 -DBUILD_TESTING=FALSE \
248 -DBoost_NO_BOOST_CMAKE=TRUE"
257 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
259 DESTDIR="%{buildroot}"
261 # install classicui config
262 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
263 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
264 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
266 # fix plugin path on x64
267 %if "%{_vendor}" != "suse"
268 sed -i 's@PluginDir = .*@PluginDir = "%{_libdir}/nagios/plugins"@' %{buildroot}/%{_sysconfdir}/%{name}/constants.conf
271 # remove features-enabled symlinks
272 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
275 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
278 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
279 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
280 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}
284 %if 0%{?suse_version}
286 %{fillup_and_insserv icinga2}
290 # initial installation, enable default features
291 %{_sbindir}/icinga2-enable-feature checker
292 %{_sbindir}/icinga2-enable-feature notification
293 %{_sbindir}/icinga2-enable-feature mainlog
298 %restart_on_update icinga2
301 if [ "$1" = "0" ]; then
302 # deinstallation of the package - remove enabled features
303 rm -rf %{_sysconfdir}/%{name}/features-enabled
309 %stop_on_removal icinga2
315 /sbin/chkconfig --add icinga2
319 # initial installation, enable default features
320 %{_sbindir}/icinga2-enable-feature checker
321 %{_sbindir}/icinga2-enable-feature notification
322 %{_sbindir}/icinga2-enable-feature mainlog
328 if [ "$1" -ge "1" ]; then
329 /sbin/service icinga2 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
339 if [ "$1" = "0" ]; then
340 /sbin/service icinga2 stop > /dev/null 2>&1
341 /sbin/chkconfig --del icinga2
350 # initial installation, enable ido-mysql feature
351 %{_sbindir}/icinga2-enable-feature ido-mysql
357 if [ "$1" = "0" ]; then
358 # deinstallation of the package - remove feature
359 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-mysql
367 # initial installation, enable ido-pgsql feature
368 %{_sbindir}/icinga2-enable-feature ido-pgsql
374 if [ "$1" = "0" ]; then
375 # deinstallation of the package - remove feature
376 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-pgsql
381 %post classicui-config
384 # initial installation, enable features
385 %{_sbindir}/icinga2-enable-feature statusdata
386 %{_sbindir}/icinga2-enable-feature compatlog
387 %{_sbindir}/icinga2-enable-feature command
392 %postun classicui-config
393 if [ "$1" = "0" ]; then
394 # deinstallation of the package - remove feature
395 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature statusdata
396 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature compatlog
397 test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature command
405 %defattr(-,root,root,-)
406 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
407 %attr(755,-,-) %{_sysconfdir}/init.d/%{name}
408 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
409 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
410 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts
411 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts/localhost
412 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
413 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
414 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
415 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
416 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
417 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
418 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
419 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf
420 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf
421 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
422 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
424 %{_bindir}/%{name}-build-ca
425 %{_bindir}/%{name}-build-key
426 %{_bindir}/%{name}-sign-key
427 %{_sbindir}/%{name}-enable-feature
428 %{_sbindir}/%{name}-disable-feature
429 %{_sbindir}/%{name}-setup-agent
430 %{_sbindir}/%{name}-discover-agent
431 %{_sbindir}/%{name}-forget-agent
432 %{_sbindir}/%{name}-list-agents
433 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
434 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
437 %exclude %{_datadir}/%{name}/include
438 %{_mandir}/man8/%{name}.8.gz
440 %attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/cache/%{name}
441 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
442 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
443 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
444 %attr(0755,%{icinga_user},%{icinga_group}) %ghost %{_localstatedir}/run/%{name}
445 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
447 %attr(2755,%{icinga_user},%{icingacmd_group}) %ghost %{_localstatedir}/run/icinga2/cmd
450 %defattr(-,root,root,-)
451 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
452 %attr(755,-,-) %{_sysconfdir}/logrotate.d/%{name}
453 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
454 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
455 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
456 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
457 %{_datadir}/%{name}/include
460 %defattr(-,root,root,-)
461 %{_datadir}/doc/%{name}
462 %docdir %{_datadir}/doc/%{name}
465 %defattr(-,root,root,-)
466 %doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
467 %{_libdir}/%{name}/libdb_ido_mysql*
470 %defattr(-,root,root,-)
471 %doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
472 %{_libdir}/%{name}/libdb_ido_pgsql*
474 %files classicui-config
475 %defattr(-,root,root,-)
476 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
477 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
478 %config(noreplace) %{apacheconfdir}/icinga.conf
479 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd