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