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