]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
- use install-unstripped, remove duplicate or unneccessary install targets
[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.4
9 Release:        1
10 License:        GPL v2
11 Group:          Networking
12 Source0:        http://dl.sourceforge.net/nagios/%{name}-%{version}.tar.gz
13 # Source0-md5:  bb8f0106dc7f282c239f54db1f308445
14 Source1:        %{name}-apache.conf
15 Source2:        %{name}.init
16 Source3:        %{name}.sysconfig
17 Source4:        http://www.nagios.org/images/favicon.ico
18 # Source4-md5:  1c4201c7da53d6c7e48251d3a9680449
19 Source5:        %{name}-config-20050514.tar.bz2
20 # Source5-md5:  a2883c65377ef7beb55d48af85ec7ef7
21 Patch0:         %{name}-resources.patch
22 Patch1:         %{name}-iconv-in-libc.patch
23 Patch2:         %{name}-favicon.patch
24 Patch3:         %{name}-webapps.patch
25 URL:            http://www.nagios.org/
26 BuildRequires:  autoconf
27 BuildRequires:  automake
28 %if %{with gd}
29 BuildRequires:  gd-devel
30 BuildRequires:  libjpeg-devel
31 BuildRequires:  libpng-devel
32 %endif
33 BuildRequires:  rpmbuild(macros) >= 1.268
34 BuildRequires:  sed >= 4.0
35 BuildRequires:  tar >= 1:1.15.1
36 Requires(post,preun):   /sbin/chkconfig
37 Requires(triggerpostun):        sed >= 4.0
38 Requires:       %{name}-common = %{version}-%{release}
39 Requires:       /bin/mail
40 Requires:       nagios-plugins
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
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
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):    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
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):    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:       apache(mod_alias)
123 Requires:       apache(mod_auth)
124 Requires:       apache(mod_cgi)
125 Requires:       group(http)
126 Requires:       webapps
127 Requires:       webserver = apache
128
129 %description cgi
130 CGI webinterface for Nagios.
131
132 %description cgi -l pl
133 Interfejs CGI dla Nagiosa.
134
135 %package theme-default
136 Summary:        Default Nagios theme
137 Summary(pl):    Domy¶lny motyw Nagiosa
138 Group:          Applications/WWW
139 Requires:       nagios-cgi = %{version}-%{release}
140 Provides:       nagios-theme
141 Obsoletes:      nagios-theme
142
143 %description theme-default
144 Original theme from Nagios.
145
146 %description theme-default -l pl
147 Oryginalny motyw z Nagiosa.
148
149 %package devel
150 Summary:        Include files that Nagios-related applications may compile against
151 Summary(pl):    Pliki nag³ówkowe, wykorzystywane przez aplikacje nagiosa
152 Summary(pt_BR): Arquivos de cabeçalho necessários para desenvolvimento de aplicativos para o Nagios
153 Group:          Development/Libraries
154 # doesn't require base
155
156 %description devel
157 This package provides include files that Nagios-related applications
158 may compile against.
159
160 %description devel -l pl
161 Ten pakiet dostarcza pliki nag³ówkowe, które mog± byæ wykorzystywane
162 przez aplikacje zwi±zane z nagiosem podczas kompilacji.
163
164 %description devel -l pt_BR
165 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
166 aplicativos para o Nagios.
167
168 %prep
169 %setup -q
170 %patch0 -p0
171 %patch1 -p1
172 %patch2 -p1
173 %patch3 -p1
174
175 sed -i -e '
176         s,".*/var/rw/nagios.cmd,"%{_localstatedir}/rw/nagios.cmd,
177         s,".*/libexec/eventhandlers,"%{_libdir}/%{name}/eventhandlers,
178 ' $(find contrib/eventhandlers -type f)
179
180 sed -e 's,%{_prefix}/lib/,%{_libdir}/,' %{SOURCE1} > apache.conf
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         --enable-event-broker \
194         %{!?with_gd:--disable-statusmap --disable-trends}
195
196 %{__make} all
197
198 %install
199 rm -rf $RPM_BUILD_ROOT
200 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_includedir}/%{name},%{_libdir}/%{name}/{eventhandlers,plugins}} \
201         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir}/rw,%{_sysconfdir}/{plugins,local},%{_examplesdir}/%{name}-%{version}} \
202         $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
203
204 install include/*.h     $RPM_BUILD_ROOT%{_includedir}/%{name}
205
206 %{__make} install-unstripped \
207         DESTDIR=$RPM_BUILD_ROOT \
208         INSTALL_OPTS="" \
209         INIT_OPTS="" \
210         COMMAND_OPTS=""
211
212 install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
213 install %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
214 install %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}
215
216 # install templated configuration files
217 tar jxf %{SOURCE5} --strip-components=1 -C $RPM_BUILD_ROOT%{_sysconfdir}
218 sed -i -e 's,%{_prefix}/lib/,%{_libdir}/,' $RPM_BUILD_ROOT%{_sysconfdir}/resource.cfg
219
220 # webserver files
221 install apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
222 install apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
223 mv $RPM_BUILD_ROOT{%{_sysconfdir}/cgi.cfg,%{_webapps}/%{_webapp}}
224 > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/passwd
225 echo 'nagios:' > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/group
226
227 # install event handlers
228 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
229
230 # Object data/cache files
231 for i in {objects.cache,{comments,downtime,retention,status}.dat,nagios.tmp}; do
232         > $RPM_BUILD_ROOT%{_localstatedir}/$i
233 done
234 > $RPM_BUILD_ROOT%{_localstatedir}/rw/nagios.cmd
235
236 %clean
237 rm -rf $RPM_BUILD_ROOT
238
239 %post
240 for i in %{_localstatedir}/{objects.cache,{comments,downtime,retention,status}.dat}; do
241         [ ! -f $i ] && touch $i
242         chown root:nagios $i
243         chmod 664 $i
244 done
245
246 /sbin/chkconfig --add %{name}
247 %service %{name} restart "Nagios service"
248
249 %preun
250 if [ "$1" = "0" ] ; then
251         %service %{name} stop
252         /sbin/chkconfig --del %{name}
253 fi
254
255 %pre common
256 if [ "`getgid netsaint`" = "72" ]; then
257         /usr/sbin/groupmod -n nagios netsaint
258 fi
259 %groupadd -g 72 nagios
260 %groupadd -g 147 -f nagios-data
261 if [ -n "`id -u netsaint 2>/dev/null`" ] && [ "`id -u netsaint`" = "72" ]; then
262         /usr/sbin/usermod -d %{_libdir}/nagios -l nagios -c "Nagios User" -G nagios-data netsaint
263 fi
264 %useradd -u 72 -d %{_libdir}/nagios -s /bin/false -c "Nagios User" -g nagios -G nagios-data nagios
265
266 %postun common
267 if [ "$1" = "0" ]; then
268         %userremove nagios
269         %groupremove nagios
270         %groupremove nagios-data
271 fi
272
273 %post cgi
274 if [ "$1" = 1 ]; then
275 %banner %{name} -e <<EOF
276 NOTE:
277 You need to add user to %{_webapps}/%{_webapp}/passwd and
278 %{_webapps}/%{_webapp}/group to access Nagios via web.
279
280 EOF
281 fi
282
283 %triggerin cgi -- apache1
284 %addusertogroup http nagios-data
285 %webapp_register apache %{_webapp}
286
287 %triggerun cgi -- apache1
288 %webapp_unregister apache %{_webapp}
289
290 %triggerin cgi -- apache < 2.2.0, apache-base
291 %addusertogroup http nagios-data
292 %webapp_register httpd %{_webapp}
293
294 %triggerun cgi -- apache < 2.2.0, apache-base
295 %webapp_unregister httpd %{_webapp}
296
297 %triggerpostun -- nagios-cgi < 2.0-0.b3.21
298 chown root:http %{_sysconfdir}/cgi.cfg
299
300 %triggerpostun -- nagios < 2.0-0.b3.21
301 chown root:nagios %{_sysconfdir}/*.cfg
302 chown root:nagios-data %{_sysconfdir}/nagios.cfg
303 %addusertogroup nagios nagios-data
304
305 # must unify nagios.cfg
306 sed -i -e '
307 s,^status_file=.*,status_file=%{_localstatedir}/status.dat,
308 s,^comment_file=.*,comment_file=%{_localstatedir}/comments.dat,
309 s,^downtime_file=.*,downtime_file=%{_localstatedir}/downtime.dat,
310 s,^lock_file=.*,lock_file=%{_localstatedir}/nagios.pid,
311 s,^temp_file=.*,temp_file=%{_localstatedir}/nagios.tmp,
312 s,^state_retention_file=.*,state_retention_file=%{_localstatedir}/retention.dat,
313
314 # option changes
315 s,^log_passive_service_checks=,log_passive_checks=,
316 s,^inter_check_delay_method=,service_inter_check_delay_method=,
317 s,^use_agressive_host_checking=,use_aggressive_host_checking=,
318 s,^freshness_check_interval=,service_freshness_check_interval=,
319
320 ' %{_sysconfdir}/nagios.cfg
321
322 sed -i -e '
323 s,\$DATETIME\$,$LONGDATETIME$,g
324 s,Nagios/1.2,Nagios/%{version},g
325 ' %{_sysconfdir}/misccommands.cfg
326
327 mv -f /var/log/nagios/status.log %{_localstatedir}/status.dat 2>/dev/null
328 mv -f /var/log/nagios/comment.log %{_localstatedir}/comments.dat 2>/dev/null
329 mv -f /var/log/nagios/downtime.log %{_localstatedir}/downtime.dat 2>/dev/null
330 mv -f /var/run/nagios.pid %{_localstatedir}/nagios.pid 2>/dev/null
331 mv -f /var/log/nagios/nagios.tmp %{_localstatedir}/nagios.tmp 2>/dev/null
332 mv -f /var/log/nagios/status.sav %{_localstatedir}/retention.dat 2>/dev/null
333 chown nagios:nagios %{_localstatedir}/nagios.pid 2>/dev/null
334 chown nagios:nagios-data %{_localstatedir}/rw/nagios.cmd 2>/dev/null
335
336 %service -q %{name} restart
337
338 %banner -e %{name}-2.0 <<'EOF'
339 Please read <http://nagios.sourceforge.net/docs/2_0/whatsnew.html>
340 there are changes that no longer work in Nagios 2.0.
341
342 You could also try use <http://oss.op5.se/nagios/object_config_fix.php.gz>
343 to convert your config (yes i know it's too late to say it now, after
344 the upgrade, but still :))
345 EOF
346 #'vim
347
348 # webapps trigger
349 %triggerpostun cgi -- %{name}-cgi < 2.0-0.b6.0.2
350 for i in cgi.cfg group passwd; do
351         if [ -f /etc/nagios/$i.rpmsave ]; then
352                 mv -f %{_webapps}/%{_webapp}/$i{,.rpmnew}
353                 mv -f /etc/nagios/$i.rpmsave %{_webapps}/%{_webapp}/$i
354         fi
355 done
356
357 # migrate from httpd (apache2) config dir
358 if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
359         cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
360         mv -f /etc/httpd/%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
361 fi
362
363 # migrate from apache-config macros
364 if [ -f /etc/%{name}/apache-nagios.conf.rpmsave ]; then
365         if [ -d /etc/apache/webapps.d ]; then
366                 cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
367                 cp -f /etc/%{name}/apache-nagios.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
368         fi
369
370         if [ -d /etc/httpd/webapps.d ]; then
371                 cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
372                 cp -f /etc/%{name}/apache-nagios.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
373         fi
374         rm -f /etc/%{name}/apache-nagios.conf.rpmsave
375 fi
376
377 # place new config location, as trigger puts config only on first install, do it here.
378 if [ -L /etc/apache/conf.d/99_%{name}.conf ]; then
379         rm -f /etc/apache/conf.d/99_%{name}.conf
380         apache_reload=1
381 fi
382 if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
383         rm -f /etc/httpd/httpd.conf/99_%{name}.conf
384         httpd_reload=1
385 fi
386
387 if [ "$apache_reload" ]; then
388         /usr/sbin/webapp register apache %{_webapp}
389         %service -q apache reload
390 fi
391 if [ "$httpd_reload" ]; then
392         /usr/sbin/webapp register httpd %{_webapp}
393         %service -q httpd reload
394 fi
395
396 %files
397 %defattr(644,root,root,755)
398 %doc Changelog README* UPGRADING INSTALLING LICENSE
399 %doc sample-config/template-object/{bigger,minimal}.cfg
400 %attr(640,root,nagios-data) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nagios.cfg
401 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/[!n]*.cfg
402
403 %attr(754,root,root) /etc/rc.d/init.d/%{name}
404 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
405
406 %attr(755,root,root) %{_bindir}/%{name}
407 %attr(755,root,root) %{_bindir}/nagiostats
408
409 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}
410 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}/archives
411
412 %attr(770,root,nagios-data) %dir %{_localstatedir}
413 %attr(2770,root,nagios-data) %dir %{_localstatedir}/rw
414 %attr(660,nagios,nagios-data) %ghost %{_localstatedir}/rw/nagios.cmd
415 %attr(664,root,nagios) %ghost %{_localstatedir}/objects.cache
416 %attr(664,root,nagios) %ghost %{_localstatedir}/*.dat
417 %attr(664,root,nagios) %ghost %{_localstatedir}/%{name}.tmp
418
419 %{_examplesdir}/%{name}-%{version}
420
421 %files common
422 %defattr(644,root,root,755)
423 %attr(750,root,nagios-data) %dir %{_sysconfdir}
424 %attr(2750,root,nagios) %dir %{_sysconfdir}/plugins
425 %attr(2750,root,nagios) %dir %{_sysconfdir}/local
426 %dir %{_libdir}/%{name}
427 %dir %{_libdir}/%{name}/plugins
428 %dir %{_libdir}/%{name}/eventhandlers
429
430 %files cgi
431 %defattr(644,root,root,755)
432 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
433 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
434 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
435 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/cgi.cfg
436 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/passwd
437 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/group
438 %dir %{_sbindir}
439 %attr(755,root,root) %{_sbindir}/*.cgi
440
441 %dir %{_datadir}
442 %dir %{_datadir}/images
443 %dir %{_datadir}/stylesheets
444 %{_datadir}/favicon.ico
445 %{_datadir}/robots.txt
446 %{_datadir}/contexthelp
447 %{_datadir}/docs
448 %{_datadir}/media
449 %{_datadir}/ssi
450
451 %files theme-default
452 %defattr(644,root,root,755)
453 %{_datadir}/*.html
454 %{_datadir}/images/*
455 %{_datadir}/stylesheets/*
456
457 %files devel
458 %defattr(644,root,root,755)
459 %dir %{_includedir}/%{name}
460 %{_includedir}/%{name}/*.h
This page took 0.070136 seconds and 4 git commands to generate.