-
Notifications
You must be signed in to change notification settings - Fork 0
/
thruk.spec
522 lines (470 loc) · 17.7 KB
/
thruk.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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
%if %{defined suse_version}
%define apacheuser wwwrun
%define apachegroup www
%define apachedir apache2
%else
%define apacheuser apache
%define apachegroup apache
%define apachedir httpd
%endif
%undefine _disable_source_fetch
Name: thruk
Version: 3.12
Release: 12878.1
License: GPL-2.0-or-later
Packager: Sven Nierlein <sven.nierlein@consol.de>
Vendor: Labs Consol
URL: http://thruk.org
%define fullname %{name}-%{version}
Source0: https://github.com/sni/Thruk/archive/refs/tags/v%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
Group: Applications/Monitoring
BuildRequires: autoconf, automake, perl, patch
Summary: Monitoring Webinterface for Nagios/Naemon/Icinga and Shinken
AutoReqProv: no
BuildRequires: libthruk >= 2.44.2
Requires: thruk-base = %{version}-%{release}
Requires: thruk-plugin-reporting = %{version}-%{release}
%if 0%{?suse_version} < 1315
Requires(pre): shadow-utils
%endif
%if 0%{?systemd_requires}
%systemd_requires
%endif
%description
Thruk is a multibackend monitoring webinterface which currently
supports Naemon, Nagios, Icinga and Shinken as backend using the Livestatus
API. It is designed to be a 'dropin' replacement and covers almost
all of the original features plus adds additional enhancements for
large installations.
# disable binary striping
%global __os_install_post %{nil}
# disable creating useless empty debug packages
%global debug_package %{nil}
%package base
Summary: Thruk Gui Base Files
Group: Applications/System
Requires: libthruk >= 2.44.2
Requires(preun): libthruk
Requires(post): libthruk
Requires: perl logrotate gd wget
AutoReqProv: no
#sles and opensuse
%if %{defined suse_version}
%if 0%{?suse_version} >= 1315
BuildRequires: apache2
Requires: apache2 apache2-mod_fcgid cronie
%endif
%if 0%{?suse_version} < 1315
BuildRequires: apache2
Requires: apache2 apache2-mod_fcgid cron
%endif
%else
BuildRequires: perl(Module::Install)
%endif
# rhel6 requirements
%if 0%{?el6}
BuildRequires: httpd
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(Time::HiRes)
Requires: perl(Time::HiRes)
Requires: httpd mod_fcgid cronie
%else
# >=rhel7 and fedora
%if 0%{?el7}%{?el8}%{?el9}%{?fedora}
BuildRequires: perl(ExtUtils::Install) httpd
Requires: httpd mod_fcgid cronie
Requires: perl-LWP-Protocol-https
%endif
%endif
%description base
This package contains the base files for thruk.
%package plugin-reporting
Summary: Thruk Gui Reporting Addon
Group: Applications/System
Requires: %{name}-base = %{version}-%{release}
%if %{defined suse_version}
Requires: xorg-x11-fonts
%else
Requires: urw-fonts
%endif
AutoReqProv: no
%description plugin-reporting
This package contains the reporting addon for thruk useful for sla
and event reporting.
%prep
%setup -q -n Thruk-%{version}
%build
export PERL5LIB=/usr/lib/thruk/perl5:/usr/lib64/thruk/perl5
%configure \
--bindir="%{_bindir}" \
--datadir="%{_datadir}/thruk" \
--libdir="%{_libdir}/thruk" \
--localstatedir="%{_localstatedir}/lib/thruk" \
--with-tempdir="%{_localstatedir}/cache/thruk" \
--sysconfdir="%{_sysconfdir}/thruk" \
--mandir="%{_mandir}" \
--with-initdir="%{_initrddir}" \
--with-logdir="%{_localstatedir}/log/thruk" \
--with-logrotatedir="%{_sysconfdir}/logrotate.d" \
--with-bashcompletedir="%{_sysconfdir}/bash_completion.d" \
--with-thruk-user="%{apacheuser}" \
--with-thruk-group="%{apachegroup}" \
--with-thruk-libs="%{_libdir}/thruk/perl5" \
--with-httpd-conf="%{_sysconfdir}/%{apachedir}/conf.d" \
--with-htmlurl="/thruk"
%{__make} %{?_smp_mflags} all
# make sure themes are built as this point
test -f themes/themes-available/Light/stylesheets/Light.css || %{__make} themes
test -f themes/themes-available/Light/stylesheets/Light.css || exit 1
# replace /usr/bin/env according to https://fedoraproject.org/wiki/Packaging:Guidelines#Shebang_lines
sed -e 's%/usr/bin/env perl%/usr/bin/perl%' -i \
script/thruk_server.pl \
support/thruk_authd.pl \
# this plugin is shipped separatly
rm plugins/plugins-enabled/reports2
%if 0%{?rhel} == 6
cp support/apache_fcgid.conf.apache22 support/apache_fcgid.conf
cp support/thruk_cookie_auth.example.apache22 support/thruk_cookie_auth.example
cp support/thruk_cookie_auth.include.apache22 support/thruk_cookie_auth.include
cp support/thruk_cookie_auth_vhost.conf.apache22 support/thruk_cookie_auth_vhost.conf
%endif
# remove version control files
find . -name .gitignore -delete
%install
%{__rm} -rf %{buildroot}
%{__make} install \
DESTDIR="%{buildroot}" \
INSTALL_OPTS="" \
COMMAND_OPTS="" \
INIT_OPTS=""
mkdir -p %{buildroot}%{_localstatedir}/lib/thruk
# enable su logrotate directive if required
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 || 0%{?sles_version} >= 12
sed -i -e 's/^.*#su/ su/' %{buildroot}/%{_sysconfdir}/logrotate.d/thruk-base
%endif
touch plugin-reporting.files
# files file cannot be empty
echo "%%defattr(-,root,root)" >> plugin-reporting.files
%if %{?_unitdir:1}0
rm %{buildroot}%{_initrddir}/thruk
%endif
test -f %{buildroot}/usr/share/thruk/root/thruk/cache/thruk-panorama-*.js || exit 1
%clean
%{__rm} -rf %{buildroot}
%pre base
# save themes, plugins and ssi so we don't reenable them on every update
rm -rf /tmp/thruk_update
if test -d /etc/thruk/themes/themes-enabled/. && test -n "$(ls -A /etc/thruk/themes/themes-enabled/)"; then
mkdir -p /tmp/thruk_update/themes
cp -rp /etc/thruk/themes/themes-enabled/* /tmp/thruk_update/themes/
fi
if test -d /etc/thruk/plugins/plugins-enabled/. && test -n "$(ls -A /etc/thruk/plugins/plugins-enabled/)"; then
mkdir -p /tmp/thruk_update/plugins
cp -rp /etc/thruk/plugins/plugins-enabled/* /tmp/thruk_update/plugins/
fi
if test -d /etc/thruk/ssi/. && test -n "$(ls -A /etc/thruk/ssi/)"; then
mkdir -p /tmp/thruk_update/ssi
cp -rp /etc/thruk/ssi/* /tmp/thruk_update/ssi/
fi
exit 0
%post base
set +e
case "$*" in
2)
# Upgrading, restart apache webserver
%if %{defined suse_version}
%if %{?_unitdir:1}0
systemctl daemon-reload >/dev/null
systemctl condrestart apache2.service >/dev/null
%else
/etc/init.d/apache2 restart >/dev/null
%endif
%else
%if %{?_unitdir:1}0
systemctl daemon-reload >/dev/null
systemctl condrestart httpd.service >/dev/null
%else
/etc/init.d/httpd condrestart >/dev/null
%endif
%endif
rm -rf /var/cache/thruk/*
/usr/bin/thruk -a clearcache,installcron --local > /dev/null
;;
1)
# Installing
mkdir -p /var/cache/thruk/reports \
/var/log/thruk \
/etc/thruk/bp \
/etc/thruk/panorama \
/var/lib/thruk \
/etc/thruk/thruk_local.d
touch /var/log/thruk/thruk.log
chown -R %{apacheuser}:%{apachegroup} \
/var/lib/thruk \
/var/cache/thruk \
/var/log/thruk \
/etc/thruk/plugins/plugins-enabled \
/etc/thruk/thruk_local.conf \
/etc/thruk/bp \
/etc/thruk/panorama \
/etc/thruk/thruk_local.d
/usr/bin/crontab -l -u %{apacheuser} 2>/dev/null | /usr/bin/crontab -u %{apacheuser} -
%if %{defined suse_version}
/usr/sbin/a2enmod alias
/usr/sbin/a2enmod fcgid
/usr/sbin/a2enmod auth_basic
/usr/sbin/a2enmod rewrite
%endif
%if %{?_unitdir:1}0
#%systemd_post thruk.service
%else
chkconfig --add thruk
%endif
rm -rf /var/cache/thruk/*
/usr/bin/thruk -a clearcache,installcron --local > /dev/null
echo "Thruk have been configured for http://$(hostname)/thruk/."
echo "The default user is 'thrukadmin' with password 'thrukadmin'. You can usually change that by 'htpasswd /etc/thruk/htpasswd thrukadmin'"
;;
*) echo case "$*" not handled in post
esac
if [ "$(getenforce 2>/dev/null)" = "Enforcing" ]; then
echo "******************************************";
echo "Thruk will not work when SELinux is enabled";
echo "SELinux: "$(getenforce);
echo "******************************************";
fi
exit 0
%posttrans base
# restore themes and plugins
if [ -d /tmp/thruk_update/themes/. ]; then
# do not remove the new default theme
test -h /tmp/thruk_update/themes/Light || mv /etc/thruk/themes/themes-enabled/Light /etc/thruk/themes/themes-enabled/.Light
test -h /tmp/thruk_update/themes/Dark || mv /etc/thruk/themes/themes-enabled/Dark /etc/thruk/themes/themes-enabled/.Dark
rm -f /etc/thruk/themes/themes-enabled/*
cp -rp /tmp/thruk_update/themes/* /etc/thruk/themes/themes-enabled/
test -h /etc/thruk/themes/themes-enabled/.Light && mv /etc/thruk/themes/themes-enabled/.Light /etc/thruk/themes/themes-enabled/Light
test -h /etc/thruk/themes/themes-enabled/.Dark && mv /etc/thruk/themes/themes-enabled/.Dark /etc/thruk/themes/themes-enabled/Dark
fi
# remove broken/old symlinks
for link in /etc/thruk/themes/themes-enabled/*; do test -e $link/. || rm $link; done
if [ -d /tmp/thruk_update/plugins/. ]; then
rm -f /etc/thruk/plugins/plugins-enabled/*
cp -rp /tmp/thruk_update/plugins/* /etc/thruk/plugins/plugins-enabled/
fi
# remove broken/old symlinks
for link in /etc/thruk/plugins/plugins-enabled/*; do test -e $link/. || rm $link; done
echo "thruk plugins enabled:" $(ls /etc/thruk/plugins/plugins-enabled/)
if [ -d /tmp/thruk_update/ssi/. ]; then
rm -f /etc/thruk/ssi/*
cp -rp /tmp/thruk_update/ssi/* /etc/thruk/ssi/
fi
rm -rf /tmp/thruk_update
exit 0
%preun base
case "$*" in
1)
# Upgrade, don't do anything
;;
0)
# Uninstall, go ahead and stop before removing
# last version will be deinstalled
/usr/bin/thruk -a uninstallcron --local
%if %{?_unitdir:1}0
%else
/etc/init.d/thruk stop
chkconfig --del thruk 2>/dev/null
%endif
;;
*) echo case "$*" not handled in preun
esac
exit 0
%postun base
set +e
case "$*" in
0)
# POSTUN
rm -rf %{_localstatedir}/cache/thruk
rm -rf %{_datadir}/thruk/root/thruk/plugins
rmdir /etc/thruk/plugins/plugins-available 2>/dev/null
rmdir /etc/thruk/plugins/plugins-enabled 2>/dev/null
rmdir /etc/thruk/plugins 2>/dev/null
rmdir /etc/thruk/bp 2>/dev/null
rmdir /etc/thruk/panorama 2>/dev/null
rmdir /etc/thruk/thruk_local.d 2>/dev/null
rmdir /etc/thruk 2>/dev/null
rmdir /usr/share/thruk/plugins/plugins-available 2>/dev/null
rmdir /usr/share/thruk/plugins 2>/dev/null
rmdir /usr/share/thruk 2>/dev/null
%if 0%{?insserv_cleanup}
%{insserv_cleanup}
%endif
# remove broken/old symlinks
for link in /etc/thruk/themes/themes-available/*; do test -e $link/. || rm -f $link; done
for link in /etc/thruk/themes/themes-enabled/*; do test -e $link/. || rm -f $link; done
for link in /etc/thruk/plugins/plugins-available/*; do test -e $link/. || rm -f $link; done
for link in /etc/thruk/plugins/plugins-enabled/*; do test -e $link/. || rm -f $link; done
rmdir /usr/share/thruk/script \
/usr/share/thruk \
/usr/lib/thruk \
/etc/thruk/ssi \
/etc/thruk/action_menus \
/etc/thruk/bp \
/etc/thruk/panorama \
/etc/thruk \
2>/dev/null
;;
1)
# POSTUPDATE
/usr/bin/thruk -a livecachestop --local >/dev/null 2>&1
rm -rf %{_localstatedir}/cache/thruk/*
mkdir -p /var/cache/thruk/reports
chown -R %{apacheuser}:%{apachegroup} /var/cache/thruk
# remove broken/old symlinks
for link in /etc/thruk/themes/themes-available/*; do test -e $link/. || rm -f $link; done
for link in /etc/thruk/themes/themes-enabled/*; do test -e $link/. || rm -f $link; done
for link in /etc/thruk/plugins/plugins-available/*; do test -e $link/. || rm -f $link; done
for link in /etc/thruk/plugins/plugins-enabled/*; do test -e $link/. || rm -f $link; done
;;
*) echo case "$*" not handled in postun
esac
exit 0
%post plugin-reporting
rm -f /etc/thruk/plugins/plugins-enabled/reports2
ln -s ../plugins-available/reports2 /etc/thruk/plugins/plugins-enabled/reports2
%if %{?_unitdir:1}0
%else
/etc/init.d/thruk condrestart >/dev/null || :
%endif
exit 0
%preun plugin-reporting
if [ -e /etc/thruk/plugins/plugins-enabled/reports2 ]; then
rm -f /etc/thruk/plugins/plugins-enabled/reports2
%if %{?_unitdir:1}0
%else
/etc/init.d/thruk condrestart >/dev/null || :
%endif
fi
exit 0
%postun plugin-reporting
case "$*" in
0)
# POSTUN
# try to clean some empty folders
rmdir /etc/thruk/plugins/plugins-available 2>/dev/null
rmdir /etc/thruk/plugins/plugins-enabled 2>/dev/null
rmdir /etc/thruk/plugins 2>/dev/null
rmdir /etc/thruk 2>/dev/null
rmdir /usr/share/thruk/plugins/plugins-available 2>/dev/null
rmdir /usr/share/thruk/plugins 2>/dev/null
rmdir /usr/share/thruk/script 2>/dev/null
rmdir /usr/share/thruk 2>/dev/null
;;
1)
# POSTUPDATE
;;
*) echo case "$*" not handled in postun
esac
exit 0
%files
%files base
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/thruk
%attr(0755,root,root) %{_bindir}/naglint
%attr(0755,root,root) %{_bindir}/nagexp
%if %{?_unitdir:1}0
%else
%attr(0755,root,root) %{_initrddir}/thruk
%endif
%config %{_sysconfdir}/thruk/ssi
%config %{_sysconfdir}/thruk/action_menus
%config %{_sysconfdir}/thruk/thruk.conf
%attr(0644,%{apacheuser},%{apachegroup}) %config(noreplace) %{_sysconfdir}/thruk/thruk_local.conf
%attr(0644,%{apacheuser},%{apachegroup}) %config(noreplace) %{_sysconfdir}/thruk/cgi.cfg
%attr(0644,%{apacheuser},%{apachegroup}) %config(noreplace) %{_sysconfdir}/thruk/htpasswd
%attr(0755,%{apacheuser},%{apachegroup}) %dir /var/log/thruk/
%config(noreplace) %{_sysconfdir}/thruk/naglint.conf
%config(noreplace) %{_sysconfdir}/thruk/log4perl.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/thruk-base
%config(noreplace) %{_sysconfdir}/bash_completion.d/thruk-base
%config(noreplace) %{_sysconfdir}/%{apachedir}/conf.d/thruk.conf
%config(noreplace) %{_sysconfdir}/%{apachedir}/conf.d/thruk_cookie_auth_vhost.conf
%{_datadir}/%{name}/plugins/plugins-available/business_process
%config %{_sysconfdir}/%{name}/plugins/plugins-enabled/business_process
%config %{_sysconfdir}/%{name}/plugins/plugins-available/business_process
%{_datadir}/%{name}/plugins/plugins-available/conf
%config %{_sysconfdir}/%{name}/plugins/plugins-enabled/conf
%config %{_sysconfdir}/%{name}/plugins/plugins-available/conf
%{_datadir}/%{name}/plugins/plugins-available/minemap
%config %{_sysconfdir}/%{name}/plugins/plugins-enabled/minemap
%config %{_sysconfdir}/%{name}/plugins/plugins-available/minemap
%{_datadir}/%{name}/plugins/plugins-available/panorama
%config %{_sysconfdir}/%{name}/plugins/plugins-enabled/panorama
%config %{_sysconfdir}/%{name}/plugins/plugins-available/panorama
%{_datadir}/%{name}/plugins/plugins-available/shinken_features
%config %{_sysconfdir}/%{name}/plugins/plugins-enabled/shinken_features
%config %{_sysconfdir}/%{name}/plugins/plugins-available/shinken_features
%{_datadir}/%{name}/plugins/plugins-available/core_scheduling
%config %{_sysconfdir}/%{name}/plugins/plugins-available/core_scheduling
%{_datadir}/%{name}/plugins/plugins-available/agents
%config %{_sysconfdir}/%{name}/plugins/plugins-available/agents
%config(noreplace) %{_sysconfdir}/thruk/themes
%config(noreplace) %{_sysconfdir}/thruk/menu_local.conf
%config(noreplace) %{_sysconfdir}/thruk/usercontent/
%config(noreplace) %{_sysconfdir}/thruk/bp/bp_functions.pm
%config(noreplace) %{_sysconfdir}/thruk/bp/bp_filter.pm
%attr(0755,root,root) %{_datadir}/thruk/thruk_auth
%attr(0755,root,root) %{_datadir}/thruk/script/thruk_fastcgi.pl
%attr(0755,root,root) %{_datadir}/thruk/script/thruk.psgi
%attr(0755,root,root) %{_datadir}/thruk/script/grafana_export.sh
%attr(0755,root,root) %{_datadir}/thruk/script/html2pdf.sh
%attr(0644,root,root) %{_datadir}/thruk/script/puppeteer.js
%attr(0755,root,root) %{_datadir}/thruk/script/install_puppeteer.sh
%attr(0755,root,root) %{_datadir}/thruk/script/pnp_export.sh
%attr(0755,root,root) %{_datadir}/thruk/script/convert_old_datafile
%attr(0755,root,root) %{_datadir}/thruk/script/check_thruk_rest
%{_datadir}/thruk/support
%{_datadir}/thruk/root
%{_datadir}/thruk/templates
%{_datadir}/thruk/themes
%{_datadir}/thruk/lib
%{_datadir}/thruk/Changes
%{_datadir}/thruk/LICENSE
%{_datadir}/thruk/menu.conf
%{_datadir}/thruk/dist.ini
%{_datadir}/thruk/thruk_cookie_auth.include
%attr(0755,root,root) %{_datadir}/thruk/fcgid_env.sh
%attr(0755,root,root) %{_datadir}/thruk/thruk_authd.pl
%doc %{_mandir}/man3/nagexp.3
%doc %{_mandir}/man3/naglint.3
%doc %{_mandir}/man3/thruk.3
%doc %{_mandir}/man8/thruk.8
%docdir %{_defaultdocdir}
%if 0%{?suse_version} >= 1315
%attr(0755,root,root) %dir %{_sysconfdir}/apache2
%attr(0755,root,root) %dir %{_sysconfdir}/apache2/conf.d
%attr(0755,root,root) %dir %{_sysconfdir}/thruk
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/bp
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/plugins
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/plugins/plugins-available
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/plugins/plugins-enabled
%attr(0755,root,root) %dir %{_datadir}/thruk
%attr(0755,root,root) %dir %{_datadir}/thruk/plugins
%attr(0755,root,root) %dir %{_datadir}/thruk/script
%attr(0755,root,root) %dir %{_datadir}/thruk/plugins/plugins-available
%endif
%files plugin-reporting -f plugin-reporting.files
%{_sysconfdir}/thruk/plugins/plugins-available/reports2
%{_datadir}/thruk/plugins/plugins-available/reports2
%changelog
* Wed Feb 14 2024 Will Haines <william.haines@colorado.edu>
- Fork for CU Boulder
* Fri Jun 12 2015 Sven Nierlein <sven@consol.de> - 2.00
- split into several subpackages
* Sat Dec 07 2013 Sven Nierlein <sven@consol.de> - 1.82
- changed to default installation routine
* Sat Apr 14 2012 Sven Nierlein <sven@consol.de> - 1.28
- added init script
- added log rotation
* Fri Feb 10 2012 Sven Nierlein <sven@consol.de> - 1.2
- First build