]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
fix $HOME env var
[packages/nagios.git] / nagios.spec
1 # TODO
2 # - /var/log/nagios/archives -> /var/log/archive/nagios
3 #
4 # Conditional build:
5 %bcond_without  gd      # without statusmap and trends, which require gd library
6 # reeenable when http://tracker.nagios.org/view.php?id=51 is fixed
7 %bcond_with     tests
8
9 Summary:        Host/service/network monitoring program
10 Summary(pl.UTF-8):      Program do monitorowania serwerów/usług/sieci
11 Summary(pt_BR.UTF-8):   Programa para monitoração de máquinas e serviços
12 Name:           nagios
13 Version:        3.2.3
14 Release:        5
15 License:        GPL v2+
16 Group:          Networking
17 Source0:        http://downloads.sourceforge.net/nagios/%{name}-%{version}.tar.gz
18 # Source0-md5:  fe1be46e6976a52acdb021a782b5d04b
19 Source1:        %{name}-apache.conf
20 Source2:        %{name}.init
21 Source3:        %{name}.sysconfig
22 Source4:        %{name}-config-20090914.tar.bz2
23 # Source4-md5:  605f1cd28c00db961dad6f529d849f16
24 Source5:        %{name}-lighttpd.conf
25 Source6:        http://www.google.com/mapfiles/shadow50.png
26 # Source6-md5:  eff99f302f21b95a900d321743fce72b
27 Source7:        http://www.google.com/mapfiles/marker.png
28 # Source7-md5:  edefef4bdfc29e1c953694651f05b466
29 Source8:        googlemap.js
30 Patch0:         %{name}-resources.patch
31 Patch1:         %{name}-iconv-in-libc.patch
32 Patch2:         %{name}-webapps.patch
33 Patch3:         %{name}-cgi-http_charset.patch
34 Patch4:         %{name}-cmd-typo.patch
35 Patch5:         config.patch
36 Patch6:         %{name}-googlemap.patch
37 Patch7:         %{name}-doc-usermacros.patch
38 Patch8:         archivelog-timeformat.patch
39 URL:            http://www.nagios.org/
40 BuildRequires:  autoconf
41 BuildRequires:  automake
42 %if %{with gd}
43 BuildRequires:  gd-devel
44 BuildRequires:  libjpeg-devel
45 BuildRequires:  libpng-devel
46 %endif
47 BuildRequires:  rpmbuild(macros) >= 1.268
48 BuildRequires:  sed >= 4.0
49 Requires(post,preun):   /sbin/chkconfig
50 Requires:       %{name}-common = %{version}-%{release}
51 Requires:       rc-scripts
52 Requires:       sh-utils
53 Suggests:       nagios-notify >= 0.13
54 Suggests:       nagios-plugin-check_load
55 Suggests:       nagios-plugin-check_ping
56 Suggests:       nagios-plugins
57 Provides:       nagios-core
58 Obsoletes:      netsaint
59 Conflicts:      iputils-ping < 1:ss020124
60 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
61
62 %define         _sysconfdir     /etc/%{name}
63 %define         cgidir          %{_libdir}/%{name}/cgi
64 %define         htmldir         %{_prefix}/share/%{name}
65 %define         _localstatedir  /var/lib/%{name}
66 %define         _webapps        /etc/webapps
67 %define         _webapp         %{name}
68
69 %description
70 Nagios is a program that will monitor hosts and services on your
71 network. It has the ability to email or page you when a problem arises
72 and when a problem is resolved. Nagios is written in C and is designed
73 to run under Linux (and some other *NIX variants) as a background
74 process, intermittently running checks on various services that you
75 specify.
76
77 The actual service checks are performed by separate "plugin" programs
78 which return the status of the checks to Nagios. The plugins are
79 available in nagios-plugins packages.
80
81 Nagios is successor to NetSaint.
82
83 %description -l pl.UTF-8
84 Nagios to program, który monitoruje serwery oraz usługi w naszej
85 sieci. Posiada on możliwość wysyłania informacji o wystąpieniu oraz
86 rozwiązaniu problemu. Nagios został napisany w C oraz jest
87 zaprojektowany do pracy pod Linuksem (i niektórymi innymi uniksami)
88 jako proces pracujący w tle i bezustannie wykonujący pewne operacje
89 sprawdzające.
90
91 Właściwe sprawdzanie jest wykonywane przez osobne programy
92 ("wtyczki"), które zwracają informacje o statusie do Nagiosa. Wtyczki
93 są dostępne na stronie w pakietach nagios-plugins.
94
95 Nagios jest następcą NetSainta.
96
97 %description -l pt_BR.UTF-8
98 O Nagios é um programa que monitora máquinas e serviços na sua rede.
99 Ele pode enviar um email ou um aviso de pager para o administrador
100 quando surgir um problema e quando ele for resolvido. Nagios é escrito
101 em C e foi desenvolvido para rodar em plataformas Linux (e algumas
102 variações de *NIX) como um processo em segundo plano, periodicamente
103 executando checagens nos diversos serviços que forem especificados.
104
105 %package common
106 Summary:        Common files needed by both nagios and nrpe
107 Summary(pl.UTF-8):      Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe
108 Group:          Networking
109 Requires(postun):       /usr/sbin/groupdel
110 Requires(postun):       /usr/sbin/userdel
111 Requires(pre):  /bin/id
112 Requires(pre):  /usr/bin/getgid
113 Requires(pre):  /usr/sbin/groupadd
114 Requires(pre):  /usr/sbin/groupmod
115 Requires(pre):  /usr/sbin/useradd
116 Requires(pre):  /usr/sbin/usermod
117 Provides:       group(nagcmd)
118 Provides:       group(nagios)
119 Provides:       user(nagios)
120
121 %description common
122 Common files needed by both nagios and nrpe.
123
124 %description common -l pl.UTF-8
125 Wspólne pliki wymagane zarówno przez nagiosa jak i nrpe.
126
127 %package cgi
128 Summary:        CGI webinterface for Nagios
129 Summary(pl.UTF-8):      Interfejs WWW/CGI dla Nagiosa
130 Group:          Applications/WWW
131 # for dirs... and accessing local logs, nagios config
132 Requires:       %{name} = %{version}-%{release}
133 Requires:       %{name}-imagepaks
134 Requires:       %{name}-theme
135 Requires:       group(http)
136 Requires:       webapps
137 Requires:       webserver
138 Requires:       webserver(access)
139 Requires:       webserver(alias)
140 Requires:       webserver(auth)
141 Requires:       webserver(cgi)
142 Requires:       webserver(indexfile)
143 Suggests:       %{name}-doc
144
145 %description cgi
146 CGI webinterface for Nagios.
147
148 %description cgi -l pl.UTF-8
149 Interfejs CGI dla Nagiosa.
150
151 %package doc
152 Summary:        HTML Documentation for Nagios
153 Group:          Documentation
154 # does not require base
155
156 %description doc
157 HTML Documentation for Nagios.
158
159 %package theme-default
160 Summary:        Default Nagios theme
161 Summary(pl.UTF-8):      Domyślny motyw Nagiosa
162 Group:          Applications/WWW
163 Requires:       %{name}-cgi = %{version}-%{release}
164 Requires:       webserver(php)
165 Provides:       nagios-theme
166 Obsoletes:      nagios-theme
167
168 %description theme-default
169 Original theme from Nagios.
170
171 %description theme-default -l pl.UTF-8
172 Oryginalny motyw z Nagiosa.
173
174 %package devel
175 Summary:        Include files that Nagios-related applications may compile against
176 Summary(pl.UTF-8):      Pliki nagłówkowe, wykorzystywane przez aplikacje nagiosa
177 Summary(pt_BR.UTF-8):   Arquivos de cabeçalho necessários para desenvolvimento de aplicativos para o Nagios
178 Group:          Development/Libraries
179 # doesn't require base
180
181 %description devel
182 This package provides include files that Nagios-related applications
183 may compile against.
184
185 %description devel -l pl.UTF-8
186 Ten pakiet dostarcza pliki nagłówkowe, które mogą być wykorzystywane
187 przez aplikacje związane z nagiosem podczas kompilacji.
188
189 %description devel -l pt_BR.UTF-8
190 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
191 aplicativos para o Nagios.
192
193 %prep
194 %setup -q -a4
195 %patch0 -p0
196 %patch1 -p1
197 %patch2 -p1
198 %patch3 -p1
199 %patch4 -p1
200 %patch5 -p1
201 %patch6 -p1
202 %patch7 -p1
203 %patch8 -p1
204
205 find -name .cvsignore -o -name .gitignore | xargs rm
206
207 mv nagios-config-*/objects/*.cfg sample-config/template-object
208 mv nagios-config-*/*.cfg sample-config
209
210 # cleanup backups after patching
211 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
212
213 sed -i -e '
214         s,".*/var/rw/%{name}.cmd,"%{_localstatedir}/rw/%{name}.cmd,
215         s,".*/libexec/eventhandlers,"%{_libdir}/%{name}/eventhandlers,
216 ' $(find contrib/eventhandlers -type f)
217
218 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE1} > apache.conf
219 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE5} > lighttpd.conf
220
221 # fixup cgi config
222 %{__sed} -i -e '
223         # kill trailing spaces
224         s, \+$,,
225         # use real paths
226         s,/usr/local/%{name}/share,@datadir@,g
227         # we want all authorized users have default access
228         s,=nagiosadmin,=*,g
229 ' sample-config/*.cfg.in
230
231 # fixup paths in doc
232 %{__sed} -i -e '
233         s,/usr/local/%{name}/var/archives/,/var/log/%{name}/archives/,
234 ' html/docs/configmain.html
235
236 %build
237 cp -f /usr/share/automake/config.sub .
238 %{__aclocal}
239 %{__autoconf}
240 %configure \
241         CFLAGS="%{rpmcflags} %{rpmcppflags}" \
242         --bindir=%{_sbindir} \
243         --sbindir=%{cgidir} \
244         --datadir=%{htmldir} \
245         --with-nagios-user=%{name} \
246         --with-nagios-grp=%{name} \
247         --with-command-user=%{name} \
248         --with-command-grp=%{name} \
249         --with-lockfile=%{_localstatedir}/%{name}.pid \
250         --with-checkresult-dir=%{_var}/spool/%{name}/checkresults \
251         --with-ping_command='/bin/ping -n %%s -c %%d' \
252         %{!?with_gd:--disable-statusmap --disable-trends} \
253         %{?with_tests:--enable-libtap} \
254         --enable-event-broker
255
256 %{__make} all
257
258 %{?with_tests:%{__make} test}
259
260 %install
261 rm -rf $RPM_BUILD_ROOT
262 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_webapps}/%{_webapp}} \
263         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir}/rw} \
264         $RPM_BUILD_ROOT%{_sysconfdir}/{plugins,objects} \
265         $RPM_BUILD_ROOT%{_libdir}/%{name}/{eventhandlers,plugins,brokers} \
266 %if "%{_lib}" != "lib"
267         $RPM_BUILD_ROOT%{_prefix}/lib/%{name}/{eventhandlers,plugins} \
268 %endif
269
270 install -d $RPM_BUILD_ROOT%{_includedir}/%{name}
271 cp -a include/*.h       $RPM_BUILD_ROOT%{_includedir}/%{name}
272
273 %{__make} install-unstripped \
274         DESTDIR=$RPM_BUILD_ROOT \
275         INSTALL_OPTS="" \
276         INIT_OPTS="" \
277         COMMAND_OPTS=""
278
279 install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
280 cp -a %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
281
282 # install templated configuration files
283 for a in %{name}.cfg resource.cfg commands.cfg contactgroups.cfg contacts.cfg templates.cfg timeperiods.cfg; do
284         cp -a sample-config/$a $RPM_BUILD_ROOT%{_sysconfdir}
285 done
286
287 # webserver files
288 cp -a apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
289 cp -a apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
290 cp -a lighttpd.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
291 cp -a sample-config/cgi.cfg $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
292 cp -a %{SOURCE6} $RPM_BUILD_ROOT%{htmldir}/images
293 cp -a %{SOURCE7} $RPM_BUILD_ROOT%{htmldir}/images
294 cp -a %{SOURCE8} $RPM_BUILD_ROOT%{htmldir}/images
295 > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/passwd
296 echo 'nagios:' > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/group
297
298 # install event handlers, sample config
299 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
300 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
301 cp -a sample-config $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
302 find $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} -name '*.in' | xargs rm
303
304 # Object data/cache files
305 for i in {objects.{cache,precache},{retention,status}.dat,%{name}.{tmp,pid}}; do
306         > $RPM_BUILD_ROOT%{_localstatedir}/$i
307 done
308 > $RPM_BUILD_ROOT%{_localstatedir}/rw/%{name}.cmd
309
310 install -d $RPM_BUILD_ROOT%{_docdir}/%{name}
311 mv $RPM_BUILD_ROOT{%{htmldir}/docs/*,%{_docdir}/%{name}}
312
313 %clean
314 rm -rf $RPM_BUILD_ROOT
315
316 %post
317 for i in %{_localstatedir}/{objects.{cache,precache},{retention,status}.dat}; do
318         [ ! -f $i ] && touch $i
319         chown root:nagios $i
320         chmod 664 $i
321 done
322
323 /sbin/chkconfig --add %{name}
324 %service %{name} restart "Nagios service"
325
326 %preun
327 if [ "$1" = "0" ] ; then
328         %service %{name} stop
329         /sbin/chkconfig --del %{name}
330 fi
331
332 %pre common
333 # rename group netsaint -> nagios
334 if [ "$(getgid netsaint 2>/dev/null)" = "72" ]; then
335         /usr/sbin/groupmod -n nagios netsaint
336 fi
337 # rename group nagios-data -> nagcmd
338 if [ "$(getgid nagios-data 2>/dev/null)" = "147" ]; then
339         /usr/sbin/groupmod -n nagcmd nagios-data
340 fi
341 %groupadd -g 72 nagios
342 %groupadd -g 147 -f nagcmd
343 if [ -n "$(id -u netsaint 2>/dev/null)" ] && [ "$(id -u netsaint)" = "72" ]; then
344         /usr/sbin/usermod -d %{_libdir}/%{name} -l nagios -c "Nagios Daemon" -G nagcmd netsaint
345 fi
346 %useradd -u 72 -d %{_libdir}/%{name} -s /bin/false -c "Nagios Daemon" -g nagios -G nagcmd nagios
347
348 %postun common
349 if [ "$1" = "0" ]; then
350         %userremove nagios
351         %groupremove nagios
352         %groupremove nagcmd
353 fi
354
355 %post cgi
356 if [ "$1" = 1 ]; then
357 %banner %{name} -e <<EOF
358 NOTE:
359 You need to add user to %{_webapps}/%{_webapp}/passwd and
360 %{_webapps}/%{_webapp}/group to access Nagios via web.
361
362 EOF
363 fi
364
365 %triggerin cgi -- apache1 < 1.3.37-3, apache1-base
366 %addusertogroup http nagcmd
367 %webapp_register apache %{_webapp}
368
369 %triggerun cgi -- apache1 < 1.3.37-3, apache1-base
370 %webapp_unregister apache %{_webapp}
371
372 %triggerin cgi -- apache < 2.2.0, apache-base
373 %addusertogroup http nagcmd
374 %webapp_register httpd %{_webapp}
375
376 %triggerun cgi -- apache < 2.2.0, apache-base
377 %webapp_unregister httpd %{_webapp}
378
379 %triggerin cgi -- lighttpd
380 %addusertogroup lighttpd nagcmd
381 %webapp_register lighttpd %{_webapp}
382
383 %triggerun cgi -- lighttpd
384 %webapp_unregister lighttpd %{_webapp}
385
386 %triggerpostun -- nagios-cgi < 2.0-0.b3.21
387 chown root:http %{_sysconfdir}/cgi.cfg
388
389 %triggerpostun -- nagios < 3.1.2-4
390 # restore lost files
391 for a in dependencies.cfg services.cfg serviceextinfo.cfg hosts.cfg hostgroups.cfg hostextinfo.cfg escalations.cfg checkcommands.cfg misccommands.cfg; do
392         if [ -f %{_sysconfdir}/$a.rpmsave -a ! -f %{_sysconfdir}/$a ]; then
393                 mv -f %{_sysconfdir}/$a{.rpmsave,}
394         fi
395 done
396 %{__sed} -i -e 's,^check_result_path=.*,check_result_path=%{_var}/spool/%{name}/checkresults,' %{_sysconfdir}/%{name}.cfg
397
398 %files
399 %defattr(644,root,root,755)
400 %doc Changelog README* UPGRADING INSTALLING LICENSE
401 %attr(750,root,nagios) %dir %{_sysconfdir}/objects
402
403 # leave main nagios config readable for -cgi.
404 %attr(640,root,nagcmd) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}.cfg
405
406 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/commands.cfg
407 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/contactgroups.cfg
408 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/contacts.cfg
409 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/resource.cfg
410 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/templates.cfg
411 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/timeperiods.cfg
412
413 %attr(754,root,root) /etc/rc.d/init.d/%{name}
414 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
415
416 %attr(755,root,root) %{_sbindir}/%{name}
417 %attr(755,root,root) %{_sbindir}/nagiostats
418 %dir %{_libdir}/%{name}/brokers
419
420 %attr(770,root,nagcmd) %dir %{_var}/log/%{name}
421 %attr(770,root,nagcmd) %dir %{_var}/log/%{name}/archives
422
423 %attr(770,root,nagcmd) %dir %{_localstatedir}
424 %attr(2770,root,nagcmd) %dir %{_localstatedir}/rw
425 %attr(660,nagios,nagcmd) %ghost %{_localstatedir}/rw/%{name}.cmd
426 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.cache
427 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.precache
428 %attr(664,root,nagios) %ghost %{_localstatedir}/*.dat
429 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.tmp
430 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.pid
431
432 %attr(770,root,nagios) %dir %{_var}/spool/%{name}/checkresults
433
434 %{_examplesdir}/%{name}-%{version}
435
436 %files common
437 %defattr(644,root,root,755)
438 %attr(750,root,nagcmd) %dir %{_sysconfdir}
439 %attr(750,root,nagios) %dir %{_sysconfdir}/plugins
440 %dir %{_libdir}/%{name}
441 %dir %{_libdir}/%{name}/plugins
442 %dir %{_libdir}/%{name}/eventhandlers
443
444 %if "%{_lib}" != "lib"
445 %dir %{_prefix}/lib/%{name}
446 %dir %{_prefix}/lib/%{name}/plugins
447 %dir %{_prefix}/lib/%{name}/eventhandlers
448 %endif
449
450 %attr(770,root,nagios) %dir %{_var}/spool/%{name}
451
452 %files doc
453 %defattr(644,root,root,755)
454 %{_docdir}/%{name}
455
456 %files cgi
457 %defattr(644,root,root,755)
458 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
459 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
460 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
461 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/lighttpd.conf
462 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/cgi.cfg
463 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/passwd
464 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/group
465 %dir %{cgidir}
466 %attr(755,root,root) %{cgidir}/*.cgi
467
468 %dir %{htmldir}
469 %dir %{htmldir}/includes
470 %dir %{htmldir}/images
471 %dir %{htmldir}/stylesheets
472 %{htmldir}/robots.txt
473 %{htmldir}/contexthelp
474 %{htmldir}/media
475 %{htmldir}/ssi
476 %{htmldir}/images/favicon.ico
477 %{htmldir}/images/marker.png
478 %{htmldir}/images/shadow50.png
479
480 %files theme-default
481 %defattr(644,root,root,755)
482 %{htmldir}/*.php
483 %{htmldir}/includes/*
484 %{htmldir}/images/*
485 %exclude %{htmldir}/images/favicon.ico
486 %exclude %{htmldir}/images/marker.png
487 %exclude %{htmldir}/images/shadow50.png
488 %{htmldir}/stylesheets/*
489
490 %files devel
491 %defattr(644,root,root,755)
492 %dir %{_includedir}/%{name}
493 %{_includedir}/%{name}/*.h
This page took 0.094738 seconds and 3 git commands to generate.