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