Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
>
icinga
> icinga.spec
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File icinga.spec of Package icinga (Revision 2)
Currently displaying revision
2
,
show latest
#!BuildIgnore: post-build-checks %define name icinga %define version 0.8.2 %define release 1 %define nsusr icinga %define nsgrp icinga %define cmdgrp icingacmd %define wwwusr wwwrun %define wwwgrp www %ifarch x86_64 %define arch x86_64 %else %define arch i586 %endif # Macro that print mesages to syslog at package (un)install time %define nnmmsg logger -t %{name}/rpm Summary: Host/service/network monitoring program Name: %{name} Version: %{version} Release: %{release} License: GPL Group: Application/System Source0: %{name}-%{version}.tar.bz2 Source1: %{name}-rpmlintrc Patch0: %{name}-init-lsb.patch BuildRoot: %{_tmppath}/%{name}-buildroot Requires: gd > 1.8 zlib libpng libjpeg bash grep perl PreReq: /bin/logger, sed, mktemp BuildRequires: gd-devel > 1.8 zlib-devel libpng-devel libjpeg-devel glibc-devel libgcc gcc gcc-c++ perl BuildRequires: libdbi-devel %if 0%{?fedora_version} >= 7 BuildRequires: perl-ExtUtils-MakeMaker BuildRequires: perl-ExtUtils-Embed %endif %description Nagios is a program that will monitor hosts and services on your network. It has the ability to email or page you when a problem arises and when a problem is resolved. Nagios is written in C and is designed to run under Linux (and some other *NIX variants) as a background process, intermittently running checks on various services that you specify. The actual service checks are performed by separate "plugin" programs which return the status of the checks to Nagios. The plugins are available at http://sourceforge.net/projects/nagiosplug This package provide core programs for icinga. The web interface, documentation, and development files are built as separate packages %package www Group: Application/System Summary: Provides the HTML and CGI files for the Nagios web interface Requires: %{name} = %{version} Requires: http_daemon %description www Nagios is a program that will monitor hosts and services on your network. It has the ability to email or page you when a problem arises and when a problem is resolved. Nagios is written in C and is designed to run under Linux (and some other *NIX variants) as a background process, intermittently running checks on various services that you specify. Several CGI programs are included with Nagios in order to allow you to view the current service status, problem history, notification history, and log file via the web. This package provides the HTML and CGI files for the Nagios web interface. In addition, HTML documentation is included in this package %package devel Group: Application/System Summary: Provides include files that Nagios-related applications may compile against Requires: %{name} = %{version} %description devel Nagios is a program that will monitor hosts and services on your network. It has the ability to email or page you when a problem arises and when a problem is resolved. Nagios is written in C and is designed to run under Linux (and some other *NIX variants) as a background process, intermittently running checks on various services that you specify. This package provides include files that Nagios-related applications may compile against. %prep %setup -q %patch0 %pre # Create `icinga' user on the system if necessary if /usr/bin/id %{nsusr} > /dev/null 2>&1 ; then : # user already exists else /usr/sbin/useradd -r -d /var/log/icinga -s /bin/sh -c "%{nsusr}" %{nsusr} || \ %nnmmsg Unexpected error adding user "%{nsusr}". Aborting install process. fi # id cannot tell us if the group already exists # so just try to create it and assume it works /usr/sbin/groupadd %{nsgrp} > /dev/null 2>&1 /usr/sbin/groupadd %{cmdgrp} > /dev/null 2>&1 # if LSB standard /etc/init.d does not exist, # create it as a symlink to the first match we find if [ -d /etc/init.d -o -L /etc/init.d ]; then : # we're done elif [ -d /etc/rc.d/init.d ]; then ln -s /etc/rc.d/init.d /etc/init.d elif [ -d /usr/local/etc/rc.d ]; then ln -s /usr/local/etc/rc.d /etc/init.d elif [ -d /sbin/init.d ]; then ln -s /sbin/init.d /etc/init.d fi %preun %if 0%{?suse_version} %stop_on_removal icinga %else if [ "$1" = 0 ]; then /sbin/service icinga stop > /dev/null 2>&1 /sbin/chkconfig --del icinga fi %endif %postun if [ "$1" -ge "1" ]; then /sbin/service icinga condrestart >/dev/null 2>&1 || : fi # Delete icinga user and group # (if grep doesn't find a match, then it is NIS or LDAP served and cannot be deleted) if [ $1 = 0 ]; then /bin/grep '^%{nsusr}:' /etc/passwd > /dev/null 2>&1 && /usr/sbin/userdel %{nsusr} || %nnmmsg "User %{nsusr} could not be deleted." /bin/grep '^%{nsgrp}:' /etc/group > /dev/null 2>&1 && /usr/sbin/groupdel %{nsgrp} || %nnmmsg "Group %{nsgrp} could not be deleted." /bin/grep '^%{cmdgrp}:' /etc/group > /dev/null 2>&1 && /usr/sbin/groupdel %{cmdgrp} || %nnmmsg "Group %{cmdgrp} could not be deleted." fi %insserv_cleanup icinga %post www # If apache is installed, and we can find the apache user, set a shell var wwwusr=`awk '/^[ \t]*User[ \t]+[a-zA-Z0-9]+/ {print $2}' /etc/apache2/*.conf` if [ "z" == "z$wwwusr" ]; then # otherwise, use the default wwwusr=%{wwwusr} fi # if apache user is not in cmdgrp, add it if /usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/grep -q %{cmdgrp} > /dev/null 2>&1 ; then : # $wwwusr (default: apache) is already in nagiocmd group else # first find apache primary group pgrp=`/usr/bin/id -gn $wwwusr 2>/dev/null` # filter apache primary group from secondary groups sgrps=`/usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/sed "s/^$pgrp //;s/ $pgrp //;s/^$pgrp$//;s/ /,/g;"` if [ "z" == "z$sgrps" ] ; then sgrps=%{nsgrp} else sgrps=$sgrps,%{cmdgrp} fi # modify apache user, adding it to cmdgrp /usr/sbin/usermod -G $sgrps $wwwusr >/dev/null 2>&1 %nnmmsg "User $wwwusr added to group %{cmdgrp} so sending commands to Nagios from the command CGI is possible." fi %preun www if [ $1 = 0 ]; then if test -f /etc/apache2/httpd.conf; then TEMPFILE=`mktemp /etc/apache2/httpd.conf.tmp.XXXXXX` if grep "^ *Include /etc/apache2/conf.d/icinga.conf" /etc/apache2/httpd.conf > /dev/null; then grep -v "^ *Include /etc/apache2/conf.d/icinga.conf" /etc/apache2/httpd.conf > $TEMPFILE mv $TEMPFILE /etc/apache2/httpd.conf chmod 644 /etc/apache2/httpd.conf /etc/init.d/apache2 restart fi fi fi %stop_on_removal icinga %build export PATH=$PATH:/usr/sbin CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \ ./configure \ --host=%{arch}-suse-linux-gnu \ --build=%{arch}-suse-linux-gnu \ --target=%{arch}-suse-linux \ --with-init-dir=/etc/init.d \ --with-cgiurl=/icinga/cgi-bin \ --with-htmurl=/icinga \ --with-lockfile=/var/run/icinga.pid \ --with-icinga-user=%{nsusr} \ --with-icinga-group=%{nsgrp} \ --prefix=%{_prefix} \ --exec-prefix=%{_prefix}/sbin \ --bindir=%{_prefix}/sbin \ --sbindir=%{_prefix}/lib/icinga/cgi \ --libexecdir=%{_prefix}/lib/icinga/plugins \ --datarootdir=%{_prefix}/share/icinga \ --datadir=%{_prefix}/share/icinga \ --mandir=%{_mandir} \ --docdir=%{_docdir}/%{name} \ --sysconfdir=/etc/icinga \ --localstatedir=/var/log/icinga \ --with-gd-lib=/usr/lib \ --with-gd-inc=/usr/include \ --enable-nanosleep \ --enable-event-broker \ --enable-idoutils \ --with-httpd-conf=/etc/apache2/conf.d \ --with-checkresult-dir=/var/spool/icinga/checkresults make all # make sample configs ###cd sample-config ###F=`mktemp temp.XXXXXX` ###sed -e 's=/var/log/icinga/rw/=/var/spool/icinga/=;s=@sysconfdir@/resource.cfg=@sysconfdir@/private/resource.cfg=' icinga.cfg > ${F} ###mv ${F} icinga.cfg ###cd .. # make daemonchk.cgi and event handlers cd contrib make cd eventhandlers for f in `find . -type f` ; do F=`mktemp temp.XXXXXX` sed "s=/usr/local/icinga/var/rw/=/var/spool/icinga/=; \ s=/usr/local/icinga/libexec/eventhandlers/=%{_prefix}/lib/icinga/plugins/eventhandlers=; \ s=/usr/local/icinga/test/var=/var/log/icinga=" ${f} > ${F} mv ${F} ${f} done cd ../.. %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT install -d -m 0775 ${RPM_BUILD_ROOT}/var/spool/icinga install -d -m 0755 ${RPM_BUILD_ROOT}%{_prefix}/include/icinga install -d -m 0755 ${RPM_BUILD_ROOT}/etc/init.d install -d -m 0755 ${RPM_BUILD_ROOT}/etc/logrotate.d install -d -m 0755 ${RPM_BUILD_ROOT}/etc/apache2/conf.d install -d -m 0755 ${RPM_BUILD_ROOT}/etc/icinga ### install -d -m 0755 ${RPM_BUILD_ROOT}/etc/icinga/private make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" install make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" INIT_OPTS="" install-daemoninit make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" install-idoutils mv %{buildroot}/etc/icinga/ido2db.cfg-sample %{buildroot}/etc/icinga/ido2db.cfg mv %{buildroot}/etc/icinga/idomod.cfg-sample %{buildroot}/etc/icinga/idomod.cfg # install templated configuration files cd sample-config for f in {icinga,cgi}.cfg ; do [ -f $f ] && install -c -m 664 $f ${RPM_BUILD_ROOT}/etc/icinga/${f} done ###mkdir -p ${RPM_BUILD_ROOT}/etc/icinga/private for f in resource.cfg ; do [ -f $f ] && install -c -m 664 $f ${RPM_BUILD_ROOT}/etc/icinga/${f} done cd template-object for f in {hosts,hostgroups,services,contacts,contactgroups,dependencies,escalations,timeperiods,checkcommands,misccommands,minimal}.cfg do [ -f $f ] && install -c -m 664 $f ${RPM_BUILD_ROOT}/etc/icinga/${f} done cd .. cd .. # install headers for development package install -m 0644 include/locations.h ${RPM_BUILD_ROOT}%{_prefix}/include/icinga # install httpd configuration in RH80-style httpd config subdir cp sample-config/httpd.conf ${RPM_BUILD_ROOT}/etc/apache2/conf.d/icinga.conf # install CGIs cd contrib make INSTALL=install DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" CGIDIR=%{_prefix}/lib/icinga/cgi install #mv ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/cgi/convertcfg ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/ #mv ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/cgi/mini_epn ${RPM_BUILD_ROOT}%{_prefix}/sbin/ cd .. # install event handlers cd contrib/eventhandlers install -d -m 0755 ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/eventhandlers for file in * ; do test -f $file && install -m 0755 $file ${RPM_BUILD_ROOT}%{_prefix}/lib/icinga/eventhandlers && rm -f $file done cd ../.. %clean rm -rf $RPM_BUILD_ROOT %files %defattr(755,root,root) /etc/init.d/icinga /etc/init.d/ido2db %{_sbindir}/icinga %{_sbindir}/icingastats %{_sbindir}/mini_epn %{_sbindir}/new_mini_epn %{_sbindir}/ido2db %{_sbindir}/idomod.o %dir %{_prefix}/lib/icinga/eventhandlers %{_prefix}/lib/icinga/eventhandlers/* %{_sbindir}/convertcfg %dir /etc/icinga %defattr(644,root,root) %config(noreplace) /etc/icinga/*.cfg %defattr(750,root,%{nsgrp}) ###%dir /etc/icinga/private %defattr(640,root,%{nsgrp}) ### %config(noreplace) /etc/icinga/private/resource.cfg %defattr(755,%{nsusr},%{nsgrp}) %dir /var/log/icinga %dir /var/log/icinga/archives %defattr(2775,%{nsusr},%{nsgrp}) %dir /var/spool/icinga %defattr(0644,root,root) %doc Changelog INSTALLING LICENSE README UPGRADING %files www %defattr(755,root,root) %dir %{_prefix}/lib/icinga/cgi %{_prefix}/lib/icinga/cgi/* %dir %{_prefix}/share/icinga %defattr(-,root,root) %{_prefix}/share/icinga/* %config(noreplace) /etc/apache2/conf.d/icinga.conf %files devel %defattr(-,root,root) %dir %{_prefix}/include/icinga %{_prefix}/include/icinga/locations.h %changelog * Thu Aug 13 2009 Carsten Schoene <cs@linux-administrator.com> - 0.8.2-1 - update to release 0.8.2 * Sun Jul 19 2009 Carsten Schoene <cs@linux-administrator.com> - 0.8.1-1 - initial icinga build