Logoj0ke.net Open Build Service > Projects > server:monitoring:branches:gearman:1.0.1 > icinga > icinga.spec
Sign Up | Log In

File icinga.spec of Package icinga

 
1
#!BuildIgnore:          post-build-checks
2
%define name icinga
3
%define version 1.8.6
4
%define pkgversion 1.8.6
5
%define release 1
6
%define nsusr icinga
7
%define nsgrp icinga
8
%define cmdgrp icingacmd
9
%define wwwusr wwwrun
10
%define wwwgrp www
11
12
%define logdir /var/log/%{name}
13
14
%ifarch x86_64
15
%define arch x86_64
16
%else
17
%define arch i586
18
%endif
19
20
# Macro that print mesages to syslog at package (un)install time
21
%define nnmmsg logger -t %{name}/rpm
22
Provides:   monitoring_daemon
23
24
Summary: Host/service/network monitoring program
25
Name:       %{name}
26
Version:    %{version}
27
Release:    %{release}
28
License:    GPL
29
Group:      Application/System
30
Source0:    %{name}-%{pkgversion}.tar.bz2
31
Source1:    %{name}-rpmlintrc
32
BuildRoot:  %{_tmppath}/%{name}-buildroot
33
Requires:   gd > 1.8 zlib libpng libjpeg bash grep perl libdbi-drivers
34
Requires(pre):  pwdutils
35
PreReq: /bin/logger, sed, mktemp
36
BuildRequires:  gd-devel > 1.8 zlib-devel libpng-devel libjpeg-devel glibc-devel libgcc gcc gcc-c++ perl
37
BuildRequires:  openssl-devel
38
BuildRequires:  libdbi-devel libocilib-devel
39
40
%if 0%{?fedora_version} >= 7
41
BuildRequires:  perl-ExtUtils-MakeMaker
42
BuildRequires:  perl-ExtUtils-Embed
43
%endif
44
45
%description
46
Nagios is a program that will monitor hosts and services on your
47
network. It has the ability to email or page you when a problem arises
48
and when a problem is resolved. Nagios is written in C and is
49
designed to run under Linux (and some other *NIX variants) as a
50
background process, intermittently running checks on various services
51
that you specify.
52
53
The actual service checks are performed by separate "plugin" programs
54
which return the status of the checks to Nagios. The plugins are
55
available at http://sourceforge.net/projects/nagiosplug
56
57
This package provide core programs for icinga. The web interface,
58
documentation, and development files are built as separate packages
59
60
61
%package www
62
Group: Application/System
63
Summary: Provides the HTML and CGI files for the Nagios web interface
64
Requires: %{name} = %{version}
65
Requires: http_daemon
66
#Provides: icinga-api = %{version}
67
68
%description www
69
Nagios is a program that will monitor hosts and services on your
70
network. It has the ability to email or page you when a problem arises
71
and when a problem is resolved. Nagios is written in C and is
72
designed to run under Linux (and some other *NIX variants) as a
73
background process, intermittently running checks on various services
74
that you specify.
75
76
Several CGI programs are included with Nagios in order to allow you
77
to view the current service status, problem history, notification
78
history, and log file via the web. This package provides the HTML and
79
CGI files for the Nagios web interface. In addition, HTML
80
documentation is included in this package
81
82
83
%package devel
84
Group: Application/System
85
Summary: Provides include files that Nagios-related applications may compile against
86
Requires: %{name} = %{version}
87
88
%description devel
89
Nagios is a program that will monitor hosts and services on your
90
network. It has the ability to email or page you when a problem arises
91
and when a problem is resolved. Nagios is written in C and is
92
designed to run under Linux (and some other *NIX variants) as a
93
background process, intermittently running checks on various services
94
that you specify.
95
96
This package provides include files that Nagios-related applications
97
may compile against.
98
99
100
%prep
101
%setup -q -n %{name}-%{pkgversion}
102
103
%pre
104
# Create `icinga' user on the system if necessary
105
if /usr/bin/id %{nsusr} > /dev/null 2>&1 ; then
106
    : # user already exists
107
else
108
    /usr/sbin/useradd -r -d /var/log/icinga -s /bin/sh -c "%{nsusr}" %{nsusr} || \
109
        %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process.
110
fi
111
112
# id cannot tell us if the group already exists
113
# so just try to create it and assume it works
114
/usr/sbin/groupadd %{nsgrp} > /dev/null 2>&1
115
/usr/sbin/groupadd %{cmdgrp} > /dev/null 2>&1
116
 
117
# if LSB standard /etc/init.d does not exist,
118
# create it as a symlink to the first match we find
119
if [ -d /etc/init.d -o -L /etc/init.d ]; then
120
  : # we're done
121
elif [ -d /etc/rc.d/init.d ]; then
122
  ln -s /etc/rc.d/init.d /etc/init.d
123
elif [ -d /usr/local/etc/rc.d ]; then
124
  ln -s  /usr/local/etc/rc.d /etc/init.d
125
elif [ -d /sbin/init.d ]; then
126
  ln -s /sbin/init.d /etc/init.d
127
fi
128
129
130
%preun
131
%if 0%{?suse_version}
132
%stop_on_removal icinga
133
%else
134
if [ "$1" = 0 ]; then
135
    /sbin/service icinga stop > /dev/null 2>&1
136
    /sbin/chkconfig --del icinga
137
fi
138
%endif
139
140
%postun
141
if [ "$1" -ge "1" ]; then
142
    /sbin/service icinga condrestart >/dev/null 2>&1 || :
143
fi
144
# Delete icinga user and group
145
# (if grep doesn't find a match, then it is NIS or LDAP served and cannot be deleted)
146
if [ $1 = 0 ]; then
147
    /bin/grep '^%{nsusr}:' /etc/passwd > /dev/null 2>&1 && /usr/sbin/userdel %{nsusr} || %nnmmsg "User %{nsusr} could not be deleted."
148
    /bin/grep '^%{nsgrp}:' /etc/group > /dev/null 2>&1 && /usr/sbin/groupdel %{nsgrp} || %nnmmsg "Group %{nsgrp} could not be deleted."
149
    /bin/grep '^%{cmdgrp}:' /etc/group > /dev/null 2>&1 && /usr/sbin/groupdel %{cmdgrp} || %nnmmsg "Group %{cmdgrp} could not be deleted."
150
fi
151
%insserv_cleanup icinga
152
 
153
154
%post www
155
# If apache is installed, and we can find the apache user, set a shell var
156
wwwusr=`awk '/^[ \t]*User[ \t]+[a-zA-Z0-9]+/ {print $2}' /etc/apache2/*.conf`
157
if [ "z" == "z$wwwusr" ]; then # otherwise, use the default
158
    wwwusr=%{wwwusr}
159
fi
160
# if apache user is not in cmdgrp, add it
161
if /usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/grep -q %{cmdgrp} > /dev/null 2>&1 ; then
162
    : # $wwwusr (default: apache) is already in nagiocmd group
163
else
164
    # first find apache primary group
165
    pgrp=`/usr/bin/id -gn $wwwusr 2>/dev/null`
166
    # filter apache primary group from secondary groups
167
    sgrps=`/usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/sed "s/^$pgrp //;s/ $pgrp //;s/^$pgrp$//;s/ /,/g;"`
168
    if [ "z" == "z$sgrps" ] ; then
169
        sgrps=%{nsgrp}
170
    else
171
        sgrps=$sgrps,%{cmdgrp}
172
    fi
173
    # modify apache user, adding it to cmdgrp
174
    /usr/sbin/usermod -G $sgrps $wwwusr >/dev/null 2>&1
175
    %nnmmsg "User $wwwusr added to group %{cmdgrp} so sending commands to Nagios from the command CGI is possible."
176
fi
177
178
179
%preun www
180
if [ $1 = 0 ]; then
181
if test -f /etc/apache2/httpd.conf; then
182
    TEMPFILE=`mktemp /etc/apache2/httpd.conf.tmp.XXXXXX`
183
    if grep "^ *Include /etc/apache2/conf.d/icinga.conf" /etc/apache2/httpd.conf > /dev/null; then
184
        grep -v "^ *Include /etc/apache2/conf.d/icinga.conf" /etc/apache2/httpd.conf > $TEMPFILE
185
        mv $TEMPFILE /etc/apache2/httpd.conf
186
        chmod 644 /etc/apache2/httpd.conf
187
        /etc/init.d/apache2 restart
188
  fi
189
fi
190
fi
191
%stop_on_removal icinga
192
193
194
%build
195
export PATH=$PATH:/usr/sbin
196
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
197
./configure \
198
    --host=%{arch}-suse-linux-gnu \
199
    --build=%{arch}-suse-linux-gnu \
200
    --target=%{arch}-suse-linux \
201
    --with-init-dir=/etc/init.d \
202
    --with-cgiurl=/icinga/cgi-bin \
203
    --with-htmurl=/icinga \
204
    --with-lockfile=/var/run/icinga.pid \
205
    --with-icinga-user=%{nsusr} \
206
    --with-icinga-group=%{nsgrp} \
207
    --prefix=%{_prefix} \
208
    --exec-prefix=%{_prefix}/sbin \
209
    --bindir=%{_sbindir} \
210
    --sbindir=%{_prefix}/lib/icinga/cgi \
211
    --libdir=%{_libdir}/icinga \
212
    --libexecdir=%{_prefix}/lib/icinga/plugins \
213
    --datarootdir=%{_prefix}/share/icinga \
214
    --datadir=%{_prefix}/share/icinga \
215
    --mandir=%{_mandir} \
216
    --docdir=%{_docdir}/%{name} \
217
    --sysconfdir=/etc/icinga \
218
    --localstatedir=/var/log/icinga \
219
    --with-log-dir=%{logdir} \
220
    --with-cgi-log-dir=%{logdir}/cgi \
221
    --with-phpapi-log-dir=%{logdir}/api \
222
    --with-gd-lib=%{_libdir} \
223
    --with-gd-inc=/usr/include \
224
    --with-dbi-lib=%{_libdir} \
225
    --with-dbi-inc=%{_includedir}/db \
226
    --with-libdbi-driver-dir=%{_libdir}/dbd \
227
    --with-oci-lib=%{_libdir} \
228
    --with-oci-inc=%{_includedir} \
229
    --with-ssl-dir=%{_prefix} \
230
    --with-ssl-lib=%{_libdir} \
231
    --with-ssl-inc=%{_includedir}/openssl \
232
    --enable-nanosleep \
233
    --enable-event-broker \
234
    --enable-idoutils \
235
    --with-httpd-conf=/etc/apache2/conf.d \
236
    --with-checkresult-dir=/var/spool/icinga/checkresults
237
238
%__make all
239
240
# make daemonchk.cgi and event handlers
241
cd contrib
242
%__make
243
cd eventhandlers
244
for f in `find . -type f` ; do
245
    F=`mktemp temp.XXXXXX`
246
    sed "s=/usr/local/icinga/var/rw/=/var/spool/icinga/=; \
247
        s=/usr/local/icinga/libexec/eventhandlers/=%{_prefix}/lib/icinga/plugins/eventhandlers=; \
248
        s=/usr/local/icinga/test/var=/var/log/icinga=" ${f} > ${F}
249
    mv ${F} ${f}
250
done
251
cd ../..
252
253
%install
254
install -d -m 0775 ${RPM_BUILD_ROOT}/var/spool/icinga
255
install -d -m 0775 ${RPM_BUILD_ROOT}/var/spool/icinga/checkresults
256
install -d -m 0755 ${RPM_BUILD_ROOT}%{_prefix}/include/icinga
257
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/init.d
258
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/logrotate.d
259
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/apache2/conf.d
260
install -d -m 0755 ${RPM_BUILD_ROOT}/etc/icinga
261
make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" INSTALL_OPTS_WEB="" COMMAND_OPTS="" install
262
make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" INSTALL_OPTS_WEB="" COMMAND_OPTS="" INIT_OPTS="" install-daemoninit
263
make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" INSTALL_OPTS_WEB="" COMMAND_OPTS="" install-idoutils
264
mv %{buildroot}/etc/icinga/ido2db.cfg-sample %{buildroot}/etc/icinga/ido2db.cfg
265
mv %{buildroot}/etc/icinga/idomod.cfg-sample %{buildroot}/etc/icinga/idomod.cfg
266
267
# install templated configuration files
268
cd sample-config
269
for f in {icinga,cgi}.cfg ; do
270
  [ -f $f ] && install -c -m 664 $f ${RPM_BUILD_ROOT}/etc/icinga/${f}
271
done
272
###mkdir -p ${RPM_BUILD_ROOT}/etc/icinga/private
273
for f in resource.cfg ; do
274
  [ -f $f ] && install -c -m 664 $f ${RPM_BUILD_ROOT}/etc/icinga/${f}
275
done
276
cd template-object
277
for f in {hosts,hostgroups,services,contacts,contactgroups,dependencies,escalations,timeperiods,checkcommands,misccommands,minimal}.cfg
278
do
279
  [ -f $f ] && install -c -m 664 $f ${RPM_BUILD_ROOT}/etc/icinga/${f}
280
done
281
cd ..
282
cd ..
283
284
# install headers for development package
285
install -m 0644 include/locations.h ${RPM_BUILD_ROOT}%{_prefix}/include/icinga
286
287
# install httpd configuration in RH80-style httpd config subdir
288
cp sample-config/httpd.conf ${RPM_BUILD_ROOT}/etc/apache2/conf.d/icinga.conf
289
290
# install CGIs
291
cd contrib
292
make INSTALL=install DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" CGIDIR=%{_prefix}/lib/icinga/cgi install
293
cd ..
294
295
# install event handlers
296
cd contrib/eventhandlers
297
install -d -m 0755 ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/eventhandlers
298
for file in * ; do
299
    test -f $file && install -m 0755 $file ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/eventhandlers && rm -f $file
300
done
301
cd ../..
302
303
install -d -m 0755 ${RPM_BUILD_ROOT}/var/log/icinga/rw
304
305
chmod +x %{buildroot}/etc/init.d/ido2db
306
cd %{buildroot}%{_sbindir}
307
ln -sf /etc/init.d/icinga rcicinga
308
ln -sf /etc/init.d/ido2db rcido2db
309
# remove placeholder files
310
find %{buildroot} -name PLACEHOLDER -exec rm {} \;
311
312
%clean
313
rm -rf $RPM_BUILD_ROOT
314
315
316
%files
317
%defattr(755,root,root)
318
/etc/init.d/icinga
319
/etc/init.d/ido2db
320
%{_sbindir}/icinga
321
%{_sbindir}/icingastats
322
%{_sbindir}/mini_epn
323
%{_sbindir}/new_mini_epn
324
%{_sbindir}/ido2db
325
%{_sbindir}/log2ido
326
%{_sbindir}/rcicinga
327
%{_sbindir}/rcido2db
328
%{_libdir}/icinga/idomod.so
329
%dir %{_prefix}/lib/icinga/eventhandlers
330
%{_prefix}/lib/icinga/eventhandlers/*
331
%{_sbindir}/convertcfg
332
%dir /etc/icinga
333
%defattr(644,root,root)
334
%config(noreplace) /etc/icinga/*.cfg
335
%dir /etc/icinga/modules
336
%config /etc/icinga/modules/idoutils.cfg-sample
337
%dir /etc/icinga/objects
338
%config /etc/icinga/objects/ido2db_check_proc.cfg
339
%defattr(750,root,%{nsgrp})
340
%defattr(640,root,%{nsgrp})
341
%defattr(755,%{nsusr},%{nsgrp})
342
%dir /var/log/icinga
343
%dir /var/log/icinga/rw
344
%dir /var/log/icinga/archives
345
%defattr(2775,%{nsusr},%{nsgrp})
346
%dir /var/spool/icinga
347
%dir /var/spool/icinga/checkresults 
348
%defattr(0644,root,root)
349
%doc Changelog INSTALLING LICENSE README UPGRADING
350
%doc module/idoutils/db/mysql/mysql.sql
351
%doc module/idoutils/db/oracle/oracle.sql
352
%doc module/idoutils/db/pgsql/pgsql.sql
353
%doc sample-config/updates/
354
%doc module/idoutils/config/updates/
355
%defattr(-,%{nsusr},%{nsgrp})
356
%dir %{logdir}
357
358
%files www
359
%defattr(755,root,root)
360
%dir %{_prefix}/lib/icinga/cgi
361
%{_prefix}/lib/icinga/cgi/*
362
%dir %{_prefix}/share/icinga
363
%defattr(-,root,root)
364
%{_prefix}/share/icinga/*
365
%config(noreplace) /etc/apache2/conf.d/icinga.conf
366
%defattr(-,%{wwwusr},%{wwwgrp})
367
%dir %{logdir}/cgi
368
%{logdir}/cgi/index.htm
369
%{logdir}/cgi/.htaccess
370
371
%files devel
372
%defattr(-,root,root)
373
%dir %{_prefix}/include/icinga
374
%{_prefix}/include/icinga/locations.h
375
376
377
%changelog
378