forked from Icinga/icinga2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icinga2.spec
362 lines (312 loc) · 12.2 KB
/
icinga2.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#/******************************************************************************
# * Icinga 2 *
# * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
# * *
# * This program is free software; you can redistribute it and/or *
# * modify it under the terms of the GNU General Public License *
# * as published by the Free Software Foundation; either version 2 *
# * of the License, or (at your option) any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program; if not, write to the Free Software Foundation *
# * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
# ******************************************************************************/
%define revision 1
%if "%{_vendor}" == "redhat"
%define el5_boost_version 141
%define el5_boost_libs %{_libdir}/boost%{el5_boost_version}
%define el5_boost_includes /usr/include/boost%{el5_boost_version}
%define apachename httpd
%define apacheconfdir %{_sysconfdir}/httpd/conf.d
%define apacheuser apache
%define apachegroup apache
%endif
%if "%{_vendor}" == "suse"
%define opensuse_boost_version 1_49_0
%define sles_boost_version 1_54_0
%define apachename apache2
%define apacheconfdir %{_sysconfdir}/apache2/conf.d
%define apacheuser wwwrun
%define apachegroup www
%endif
%define icinga_user icinga
%define icinga_group icinga
%define icingacmd_group icingacmd
%define icingaclassicconfdir %{_sysconfdir}/icinga
%define logmsg logger -t %{name}/rpm
Summary: network monitoring application
Name: icinga2
Version: 0.0.4
Release: %{revision}%{?dist}
License: GPLv2+
Group: Applications/System
Source: %{name}-%{version}.tar.gz
URL: http://www.icinga.org/
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: doxygen
BuildRequires: openssl-devel
BuildRequires: gcc-c++
BuildRequires: libstdc++-devel
BuildRequires: cmake
BuildRequires: flex
BuildRequires: bison
BuildRequires: %{apachename}
# redhat
%if "%{_vendor}" == "redhat"
%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
# el5 requires EPEL
BuildRequires: boost%{el5_boost_version}-devel
BuildRequires: boost%{el5_boost_version}
Requires: boost%{el5_boost_version}-program-options
Requires: boost%{el5_boost_version}-system
Requires: boost%{el5_boost_version}-test
Requires: boost%{el5_boost_version}-thread
Requires: boost%{el5_boost_version}-regex
%else
BuildRequires: boost-devel >= 1.41
Requires: boost-program-options >= 1.41
Requires: boost-system >= 1.41
Requires: boost-test >= 1.41
Requires: boost-thread >= 1.41
Requires: boost-regex >= 1.41
%endif
%endif
#redhat
# suse
%if "%{_vendor}" == "suse"
# sles
# note: sles_version macro is not set in SLES11 anymore
# note: sles service packs are not under version control
%if 0%{?suse_version} == 1110
BuildRequires: gcc-fortran
BuildRequires: libgfortran43
BuildRequires: boost-license%{sles_boost_version}
BuildRequires: boost-devel >= 1.41
Requires: boost-license%{sles_boost_version}
Requires: libboost_program_options%{sles_boost_version}
Requires: libboost_system%{sles_boost_version}
Requires: libboost_test%{sles_boost_version}
Requires: libboost_thread%{sles_boost_version}
Requires: libboost_regex%{sles_boost_version}
%endif
# opensuse
%if 0%{?suse_version} >= 1210
BuildRequires: boost-devel >= 1.41
Requires: libboost_program_options%{opensuse_boost_version}
Requires: libboost_system%{opensuse_boost_version}
Requires: libboost_test%{opensuse_boost_version}
Requires: libboost_thread%{opensuse_boost_version}
Requires: libboost_regex%{opensuse_boost_version}
%endif
%endif
# suse
Requires: %{name}-common = %{version}
%description
Icinga is a general-purpose network monitoring application.
%package common
Summary: Common Icinga 2 configuration
Group: Applications/System
%if "%{_vendor}" == "redhat"
Requires(pre): shadow-utils
Requires(post): shadow-utils
%endif
%description common
Provides common directories, uid and gid among Icinga 2 related
packages.
%package doc
Summary: Documentation for Icinga 2
Group: Applications/System
Requires: %{name} = %{version}-%{release}
%description doc
Documentation for Icinga 2
%package ido-mysql
Summary: IDO MySQL database backend for Icinga 2
Group: Applications/System
%if "%{_vendor}" == "suse"
BuildRequires: libmysqlclient-devel
%if 0%{?suse_version} >= 1210
Requires: libmysqlclient18
%else
Requires: libmysqlclient15
%endif
%endif
%if "%{_vendor}" == "redhat"
# el5 only provides mysql package
%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
BuildRequires: mysql
%else
BuildRequires: mysql-libs
BuildRequires: mysql
%endif
BuildRequires: mysql-devel
Requires: mysql
%endif
Requires: %{name} = %{version}-%{release}
%description ido-mysql
Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
IDOUtils schema >= 1.10
%package ido-pgsql
Summary: IDO PostgreSQL database backend for Icinga 2
Group: Applications/System
%if "%{_vendor}" == "suse"
BuildRequires: postgresql-libs
%endif
%if "%{_vendor}" == "redhat"
# el5 only provides mysql package
%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
BuildRequires: postgresql84
%endif
%endif
BuildRequires: postgresql-devel
Requires: postgresql-libs
Requires: %{name} = %{version}-%{release}
%description ido-pgsql
Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
IDOUtils schema >= 1.10
%package classicui-config
Summary: Icinga 2 Classic UI Standalone configuration
Group: Applications/System
Requires: %{apachename}
Requires: %{name} = %{version}-%{release}
Provides: icinga-classicui-config
Conflicts: icinga-gui-config
%description classicui-config
Icinga 1.x Classic UI Standalone configuration with locations
for Icinga 2.
%prep
%setup -q -n %{name}-%{version}
%build
CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DICINGA2_USER=%{icinga_user} \
-DICINGA2_GROUP=%{icinga_group} \
-DICINGA2_COMMAND_USER=%{icinga_user} \
-DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
%if "%{_vendor}" == "redhat"
%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
-DBOOST_INCLUDEDIR=/usr/include/boost141 \
-DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0'"
%endif
%endif
cmake $CMAKE_OPTS .
make %{?_smp_mflags}
%install
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
make install \
DESTDIR="%{buildroot}"
# install classicui config
install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
# fix plugin path on x64
%if "%{_vendor}" != "suse"
sed -i 's@plugindir = .*@plugindir = "%{_libdir}/nagios/plugins"@' %{buildroot}/%{_sysconfdir}/%{name}/conf.d/macros.conf
%endif
%clean
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
%pre common
getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
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}
exit 0
%post ido-mysql
if [ ${1:-0} -eq 1 ]
then
# initial installation, enable ido-mysql feature
%{_sbindir}/icinga2-enable-feature ido-mysql
fi
%postun ido-mysql
if [ "$1" = "0" ]; then
# deinstallation of the package - remove feature
test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-mysql
fi
%post ido-pgsql
if [ ${1:-0} -eq 1 ]
then
# initial installation, enable ido-pgsql feature
%{_sbindir}/icinga2-enable-feature ido-pgsql
fi
%postun ido-pgsql
if [ "$1" = "0" ]; then
# deinstallation of the package - remove feature
test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-pgsql
fi
%post classicui-config
if [ ${1:-0} -eq 1 ]
then
# initial installation, enable features
%{_sbindir}/icinga2-enable-feature statusdata
%{_sbindir}/icinga2-enable-feature compatlog
%{_sbindir}/icinga2-enable-feature command
fi
%postun classicui-config
if [ "$1" = "0" ]; then
# deinstallation of the package - remove feature
test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature statusdata
test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature compatlog
test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature command
fi
%files
%defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
%attr(755,-,-) %{_sysconfdir}/init.d/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-enabled/*.conf
%{_sbindir}/%{name}
%{_bindir}/%{name}-migrate-config
%{_bindir}/%{name}-build-ca
%{_bindir}/%{name}-build-key
%{_sbindir}/%{name}-enable-feature
%{_sbindir}/%{name}-disable-feature
%exclude %{_libdir}/%{name}/libdb_ido_mysql*
%{_libdir}/%{name}
%{_datadir}/%{name}
%exclude %{_datadir}/%{name}/itl
%{_mandir}/man8/%{name}.8.gz
%attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/cache/%{name}
%attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
%attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
%attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
%attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/run/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
%attr(2755,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/run/icinga2/cmd
%files common
%defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/itl
%{_datadir}/%{name}/itl
%files doc
%defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
%{_datadir}/doc/%{name}
%docdir %{_datadir}/doc/%{name}
%files ido-mysql
%defattr(-,root,root,-)
%doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
%{_libdir}/%{name}/libdb_ido_mysql*
%files ido-pgsql
%defattr(-,root,root,-)
%doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
%{_libdir}/%{name}/libdb_ido_pgsql*
%files classicui-config
%defattr(-,root,root,-)
%config(noreplace) %{icingaclassicconfdir}/cgi.cfg
%config(noreplace) %{apacheconfdir}/icinga.conf
%config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
%changelog