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