]> git.pld-linux.org Git - packages/nagios.git/blob - nagios.spec
- created common package holding base dirs and uid/gid
[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):    Program do monitorowania serwerów/us³ug/sieci
7 Summary(pt_BR): Programa para monitoração de máquinas e serviços
8 Name:           nagios
9 Version:        2.0
10 %define _rc     b3
11 Release:        0.%{_rc}.26
12 License:        GPL v2
13 Group:          Networking
14 Source0:        http://dl.sourceforge.net/nagios/%{name}-%{version}%{_rc}.tar.gz
15 # Source0-md5:  051760458d961b6ee015b5932a8437c4
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 Patch0:         %{name}-resources.patch
22 Patch1:         %{name}-iconv-in-libc.patch
23 Patch2:         %{name}-config.patch
24 Patch3:         %{name}-favicon.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 BuildRequires:  sed >= 4.0
33 %endif
34 BuildRequires:  rpmbuild(macros) >= 1.202
35 PreReq:         %{name}-common = %{version}-%{release}
36 PreReq:         rc-scripts
37 PreReq:         sh-utils
38 Requires:       mailx
39 Requires:       nagios-plugins
40 Requires(triggerpostun):        sed >= 4.0
41 Provides:       nagios-core
42 Conflicts:      iputils-ping < 1:ss020124
43 Obsoletes:      netsaint
44 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
45
46 %define         _sysconfdir     /etc/%{name}
47 %define         _bindir         %{_prefix}/sbin
48 %define         _sbindir        %{_libdir}/%{name}/cgi
49 %define         _datadir        %{_prefix}/share/%{name}
50 %define         _localstatedir  /var/lib/%{name}
51
52 %define         _apache1dir     /etc/apache
53 %define         _apache2dir     /etc/httpd
54
55 %description
56 Nagios is a program that will monitor hosts and services on your
57 network. It has the ability to email or page you when a problem arises
58 and when a problem is resolved. Nagios is written in C and is designed
59 to run under Linux (and some other *NIX variants) as a background
60 process, intermittently running checks on various services that you
61 specify.
62
63 The actual service checks are performed by separate "plugin" programs
64 which return the status of the checks to Nagios. The plugins are
65 available in nagios-plugins packages.
66
67 Nagios is successor to NetSaint.
68
69 %description -l pl
70 Nagios to program, który monitoruje serwery oraz us³ugi w naszej
71 sieci. Posiada on mo¿liwo¶æ wysy³ania informacji o wyst±pieniu oraz
72 rozwi±zaniu problemu. Nagios zosta³ napisany w C oraz jest
73 zaprojektowany do pracy pod Linuksem (i niektórymi innymi uniksami)
74 jako proces pracuj±cy w tle i bezustannie wykonuj±cy pewne operacje
75 sprawdzaj±ce.
76
77 W³a¶ciwe sprawdzanie jest wykonywane przez osobne programy
78 ("wtyczki"), które zwracaj± informacje o statusie do Nagiosa. Wtyczki
79 s± dostêpne na stronie w pakietach nagios-plugins.
80
81 Nagios jest nastêpc± NetSainta.
82
83 %description -l pt_BR
84 O Nagios é um programa que monitora máquinas e serviços na sua rede.
85 Ele pode enviar um email ou um aviso de pager para o administrador
86 quando surgir um problema e quando ele for resolvido. Nagios é escrito
87 em C e foi desenvolvido para rodar em plataformas Linux (e algumas
88 variações de *NIX) como um processo em segundo plano, periodicamente
89 executando checagens nos diversos serviços que forem especificados.
90
91 %package common
92 Summary:        Common files needed by both nagios and nrpe
93 Group:          Networking
94 Requires(pre):  /usr/bin/getgid
95 Requires(pre):  /bin/id
96 Requires(pre):  /usr/sbin/groupadd
97 Requires(pre):  /usr/sbin/groupmod
98 Requires(pre):  /usr/sbin/useradd
99 Requires(pre):  /usr/sbin/usermod
100 Requires(post,postun):  /sbin/chkconfig
101 Requires(postun):       /usr/sbin/groupdel
102 Requires(postun):       /usr/sbin/userdel
103 Provides:       user(nagios)
104 Provides:       group(nagios)
105 Provides:       group(nagios-data)
106
107 %description common
108 Common files needed by both nagios and nrpe.
109
110 %package cgi
111 Summary:        CGI webinterface for Nagios
112 Summary(pl):    Interfejs WWW/CGI dla Nagiosa
113 Group:          Networking
114 # for dirs... and accessing local logs(?)
115 Requires:       %{name} = %{version}-%{release}
116 Requires:       %{name}-imagepaks
117 Requires:       webserver = apache
118 Requires:       apache(mod_alias)
119 Requires:       apache(mod_cgi)
120 Requires:       apache(mod_auth)
121 Requires:       group(http)
122
123 %description cgi
124 CGI webinterface for Nagios.
125
126 %description cgi -l pl
127 Interfejs CGI dla Nagiosa.
128
129 %package devel
130 Summary:        Include files that Nagios-related applications may compile against
131 Summary(pl):    Pliki nag³ówkowe, wykorzystywane przez aplikacje nagiosa
132 Summary(pt_BR): Arquivos de cabeçalho necessários para desenvolvimento de aplicativos para o Nagios
133 Group:          Development/Libraries
134 # doesn't require base
135
136 %description devel
137 This package provides include files that Nagios-related applications
138 may compile against.
139
140 %description devel -l pl
141 Ten pakiet dostarcza pliki nag³ówkowe, które mog± byæ wykorzystywane
142 przez aplikacje zwi±zane z nagiosem podczas kompilacji.
143
144 %description devel -l pt_BR
145 Este pacote contém arquivos de cabeçalho usados no desenvolvimento de
146 aplicativos para o Nagios.
147
148 %prep
149 %setup -q -n %{name}-%{version}%{?_rc}
150 %patch0 -p0
151 %patch1 -p1
152 %patch2 -p1
153 %patch3 -p1
154
155 sed -i -e '
156         s,".*/var/rw/nagios.cmd,"%{_localstatedir}/rw/nagios.cmd,
157         s,".*/libexec/eventhandlers,"%{_libdir}/%{name}/eventhandlers,
158 ' $(find contrib/eventhandlers -type f)
159
160 %build
161 cp -f /usr/share/automake/config.sub .
162 %{__aclocal}
163 %{__autoconf}
164 %configure \
165         --with-nagios-user=%{name} \
166         --with-nagios-grp=%{name} \
167         --with-command-user=%{name} \
168         --with-command-grp=%{name} \
169         --with-lockfile=%{_localstatedir}/%{name}.pid \
170         --with-ping_command='/bin/ping -n %%s -c %%d' \
171         %{!?with_gd:--disable-statusmap --disable-trends}
172
173 %{__make} all
174
175 %install
176 rm -rf $RPM_BUILD_ROOT
177 install -d $RPM_BUILD_ROOT{/etc/{sysconfig,rc.d/init.d},%{_includedir}/%{name},%{_libdir}/%{name}/{eventhandlers,plugins}} \
178         $RPM_BUILD_ROOT{%{_var}/log/%{name}/archives,%{_localstatedir},%{_sysconfdir},%{_examplesdir}/%{name}-%{version}}
179
180 install include/locations.h     $RPM_BUILD_ROOT%{_includedir}/%{name}
181
182 %{__make} install install-html install-init install-commandmode fullinstall \
183         DESTDIR=$RPM_BUILD_ROOT \
184         INSTALL_OPTS="" \
185         INIT_OPTS="" \
186         COMMAND_OPTS=""
187
188 install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache-%{name}.conf
189 install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
190 install %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
191 install %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}
192
193 # install templated configuration files
194 install sample-config/{nagios,cgi,resource}.cfg $RPM_BUILD_ROOT%{_sysconfdir}
195 install sample-config/{contact{s,groups},{misccommand,dependencie,escalation,hostgroup,host,service,timeperiod,checkcommand}s}.cfg $RPM_BUILD_ROOT%{_sysconfdir}
196 install sample-config/{service,host}extinfo.cfg $RPM_BUILD_ROOT%{_sysconfdir}
197 > $RPM_BUILD_ROOT%{_sysconfdir}/passwd
198 echo 'nagios:' > $RPM_BUILD_ROOT%{_sysconfdir}/group
199
200 # install event handlers
201 cp -a contrib/eventhandlers $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
202
203 # Object data/cache files
204 for i in {objects.cache,{comments,downtime,retention,status}.dat,nagios.tmp}; do
205         > $RPM_BUILD_ROOT%{_localstatedir}/$i
206 done
207 > $RPM_BUILD_ROOT%{_localstatedir}/rw/nagios.cmd
208
209 %clean
210 rm -rf $RPM_BUILD_ROOT
211
212 %post
213 /sbin/chkconfig --add %{name}
214 if [ -f /var/lock/subsys/%{name} ]; then
215         /etc/rc.d/init.d/%{name} restart 1>&2
216 fi
217
218 for i in %{_localstatedir}/{objects.cache,{comments,downtime,retention,status}.dat}; do
219         [ ! -f $i ] && touch $i
220         chown root:nagios $i
221         chmod 664 $i
222 done
223
224 %preun
225 if [ "$1" = "0" ] ; then
226         if [ -f /var/lock/subsys/%{name} ]; then
227                 /etc/rc.d/init.d/%{name} stop 1>&2
228         fi
229         /sbin/chkconfig --del %{name}
230 fi
231
232 %pre common
233 if [ "`getgid netsaint`" = "72" ]; then
234         /usr/sbin/groupmod -n nagios netsaint
235 fi
236 %groupadd -g 72 nagios
237 %groupadd -g 147 -f nagios-data
238 if [ -n "`id -u netsaint 2>/dev/null`" ] && [ "`id -u netsaint`" = "72" ]; then
239         /usr/sbin/usermod -d %{_libdir}/nagios -l nagios -c "Nagios User" -G nagios-data netsaint
240 fi
241 %useradd -u 72 -d %{_libdir}/nagios -s /bin/false -c "Nagios User" -g nagios -G nagios-data nagios
242
243 %postun common
244 if [ "$1" = "0" ]; then
245         %userremove nagios
246         %groupremove nagios
247         %groupremove nagios-data
248 fi
249
250 %post cgi
251 %addusertogroup http nagios-data
252
253 # apache1
254 if [ -d %{_apache1dir}/conf.d ]; then
255         ln -sf %{_sysconfdir}/apache-%{name}.conf %{_apache1dir}/conf.d/99_%{name}.conf
256         if [ -f /var/lock/subsys/apache ]; then
257                 /etc/rc.d/init.d/apache restart 1>&2
258         fi
259 fi
260 # apache2
261 if [ -d %{_apache2dir}/httpd.conf ]; then
262         ln -sf %{_sysconfdir}/apache-%{name}.conf %{_apache2dir}/httpd.conf/99_%{name}.conf
263         if [ -f /var/lock/subsys/httpd ]; then
264                 /etc/rc.d/init.d/httpd restart 1>&2
265         fi
266 fi
267
268 if [ "$1" = 1 ]; then
269 %banner %{name} -e <<EOF
270 NOTE:
271 You need to add user to %{_sysconfdir}/passwd and %{_sysconfdir}/group to acccess nagios via web.
272
273 EOF
274 fi
275
276 %preun cgi
277 if [ "$1" = "0" ]; then
278         # apache1
279         if [ -d %{_apache1dir}/conf.d ]; then
280                 rm -f %{_apache1dir}/conf.d/99_%{name}.conf
281                 if [ -f /var/lock/subsys/apache ]; then
282                         /etc/rc.d/init.d/apache restart 1>&2
283                 fi
284         fi
285         # apache2
286         if [ -d %{_apache2dir}/httpd.conf ]; then
287                 rm -f %{_apache2dir}/httpd.conf/99_%{name}.conf
288                 if [ -f /var/lock/subsys/httpd ]; then
289                         /etc/rc.d/init.d/httpd restart 1>&2
290                 fi
291         fi
292 fi
293
294 %triggerpostun -- nagios-cgi < 2.0-0.b3.21
295 chown root:http %{_sysconfdir}/cgi.cfg
296
297 %triggerpostun -- nagios < 2.0-0.b3.21
298 chown root:nagios %{_sysconfdir}/*.cfg
299 chown root:nagios-data %{_sysconfdir}/nagios.cfg
300 %addusertogroup nagios nagios-data
301
302 # must unify nagios.cfg
303 sed -i -e '
304 s,^status_file=.*,status_file=%{_localstatedir}/status.dat,
305 s,^comment_file=.*,comment_file=%{_localstatedir}/comments.dat,
306 s,^downtime_file=.*,downtime_file=%{_localstatedir}/downtime.dat,
307 s,^lock_file=.*,lock_file=%{_localstatedir}/nagios.pid,
308 s,^temp_file=.*,temp_file=%{_localstatedir}/nagios.tmp,
309 s,^state_retention_file=.*,state_retention_file=%{_localstatedir}/retention.dat,
310
311 # option changes
312 s,^log_passive_service_checks=,log_passive_checks=,
313 s,^inter_check_delay_method=,service_inter_check_delay_method=,
314 s,^use_agressive_host_checking=,use_aggressive_host_checking=,
315 s,^freshness_check_interval=,service_freshness_check_interval=,
316
317 ' %{_sysconfdir}/nagios.cfg
318
319 sed -i -e '
320 s,\$DATETIME\$,$LONGDATETIME$,g
321 s,Nagios/1.2,Nagios/%{version},g
322 ' %{_sysconfdir}/misccommands.cfg
323
324 mv -f /var/log/nagios/status.log %{_localstatedir}/status.dat 2>/dev/null
325 mv -f /var/log/nagios/comment.log %{_localstatedir}/comments.dat 2>/dev/null
326 mv -f /var/log/nagios/downtime.log %{_localstatedir}/downtime.dat 2>/dev/null
327 mv -f /var/run/nagios.pid %{_localstatedir}/nagios.pid 2>/dev/null
328 mv -f /var/log/nagios/nagios.tmp %{_localstatedir}/nagios.tmp 2>/dev/null
329 mv -f /var/log/nagios/status.sav %{_localstatedir}/retention.dat 2>/dev/null
330 chown nagios:nagios %{_localstatedir}/nagios.pid 2>/dev/null
331 chown nagios:nagios-data %{_localstatedir}/rw/nagios.cmd 2>/dev/null
332
333 if [ -f /var/lock/subsys/%{name} ]; then
334         /etc/rc.d/init.d/%{name} restart 1>&2 || :
335 fi
336
337 # apache2 config was also moved.
338 if [ -f /etc/httpd/nagios.conf.rpmsave ]; then
339         cp -f %{_sysconfdir}/apache-%{name}.conf{,.rpmnew}
340         mv -f /etc/httpd/nagios.conf.rpmsave %{_sysconfdir}/apache-%{name}.conf
341
342         if [ -f /var/lock/subsys/httpd ]; then
343                 /etc/rc.d/init.d/httpd restart 1>&2 || :
344         fi
345 fi
346
347 echo "Please read http://nagios.sourceforge.net/docs/2_0/whatsnew.html
348 there are changes that no longer work in Nagios 2.0"
349
350 %files
351 %defattr(644,root,root,755)
352 %doc Changelog README* UPGRADING INSTALLING LICENSE
353 %doc sample-config/template-object/{bigger,minimal}.cfg
354 %attr(640,root,nagios-data) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/nagios.cfg
355 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/[!n]*.cfg
356 %exclude %{_sysconfdir}/cgi.cfg
357
358 %attr(754,root,root) /etc/rc.d/init.d/%{name}
359 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
360
361 %attr(755,root,root) %{_bindir}/%{name}
362 %attr(755,root,root) %{_bindir}/nagiostats
363
364 %attr(770,root,nagios-data) %{_var}/log/%{name}
365 %attr(770,root,nagios-data) %dir %{_var}/log/%{name}/archives
366
367 %attr(770,root,nagios-data) %dir %{_localstatedir}
368 %attr(2770,root,nagios-data) %dir %{_localstatedir}/rw
369 # NOTE: the permissions are set in post script
370 %ghost %{_localstatedir}/rw/nagios.cmd
371 %ghost %{_localstatedir}/objects.cache
372 %ghost %{_localstatedir}/*.dat
373 %ghost %{_localstatedir}/%{name}.tmp
374
375 %{_examplesdir}/%{name}-%{version}
376
377 %files common
378 %defattr(644,root,root,755)
379 %attr(750,root,nagios-data) %dir %{_sysconfdir}
380 %dir %{_libdir}/%{name}
381 %dir %{_libdir}/%{name}/plugins
382 %dir %{_libdir}/%{name}/eventhandlers
383
384 %files cgi
385 %defattr(644,root,root,755)
386 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache-%{name}.conf
387 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cgi.cfg
388 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/passwd
389 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/group
390 %dir %{_sbindir}
391 %attr(755,root,root) %{_sbindir}/*.cgi
392 %{_datadir}
393
394 %files devel
395 %defattr(644,root,root,755)
396 %dir %{_includedir}/%{name}
397 %{_includedir}/%{name}/*.h
This page took 0.19946 seconds and 4 git commands to generate.