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