| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- ##
- ## nagios.spec -- OpenPKG RPM Package Specification
- ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
- ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
- ##
- ## Permission to use, copy, modify, and distribute this software for
- ## any purpose with or without fee is hereby granted, provided that
- ## the above copyright notice and this permission notice appear in all
- ## copies.
- ##
- ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
- ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- ## SUCH DAMAGE.
- ##
- # package versions
- %define V_nagios 2.8
- %define V_nagios_plugins 1.4.7
- %define V_perl_nagios_plugin 0.14
- %define V_perl_nagios_object 0.17
- %define V_perl_nagios_cmd 0.05
- # package information
- Name: nagios
- Summary: System and Network Monitoring
- URL: http://www.nagios.org/
- Vendor: Ethan Galstad et al.
- Packager: OpenPKG Foundation e.V.
- Distribution: OpenPKG Community
- Class: PLUS
- Group: Monitoring
- License: GPL
- Version: %{V_nagios}
- Release: 20070329
- # package options
- %option with_perl yes
- %option with_fsl yes
- # list of sources
- Source0: http://switch.dl.sourceforge.net/sourceforge/nagios/nagios-%{V_nagios}.tar.gz
- Source1: http://switch.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-%{V_nagios_plugins}.tar.gz
- Source2: http://www.cpan.org/authors/id/T/TO/TONVOON/Nagios-Plugin-%{V_perl_nagios_plugin}.tar.gz
- Source3: http://www.cpan.org/authors/id/T/TO/TOBEYA/Nagios-Object-%{V_perl_nagios_object}.tar.gz
- Source4: http://www.cpan.org/authors/id/T/TO/TOBEYA/Nagios-Cmd-%{V_perl_nagios_cmd}.tar.gz
- Source5: nagios.txt
- Source6: rc.nagios
- Source7: fsl.nagios
- Patch0: nagios.patch
- # build information
- Prefix: %{l_prefix}
- BuildRoot: %{l_buildroot}
- BuildPreReq: OpenPKG, openpkg >= 20060823, gcc
- PreReq: OpenPKG, openpkg >= 20060823, apache, MTA
- %if "%{with_perl}" == "yes"
- BuildPreReq: perl-openpkg
- BuildPreReq: perl, perl-net, perl-util
- %endif
- PreReq: perl, perl-net, perl-util
- BuildPreReq: zlib, jpeg, png, gd
- PreReq: zlib, jpeg, png, gd
- BuildPreReq: traceroute, openssl, openssh, coreutils, inetutils, fping, nail, snmp
- PreReq: traceroute, openssl, openssh, coreutils, inetutils, fping, nail, snmp
- %if "%{with_fsl}" == "yes"
- BuildPreReq: fsl >= 1.3.0
- PreReq: fsl >= 1.3.0
- %endif
- AutoReq: no
- AutoReqProv: no
- %description
- Nagios is a system and network monitoring application. It watches
- hosts and services that you specify, alerting you when things go bad
- and when they get better.
- %track
- prog nagios = {
- version = %{V_nagios}
- url = http://prdownloads.sourceforge.net/nagios/
- regex = nagios-(\d+(\.\d+)+)\.tar\.gz
- }
- prog nagios:plugins = {
- version = %{V_nagios_plugins}
- url = http://prdownloads.sourceforge.net/nagiosplug/
- regex = nagios-plugins-(\d+(\.\d+)+)\.tar\.gz
- }
- prog nagios:Nagios-Plugin = {
- version = %{V_perl_nagios_plugin}
- url = http://www.cpan.org/authors/id/T/TO/TONVOON/
- regex = Nagios-Plugin-(__VER__)\.tar\.gz
- }
- prog nagios:Nagios-Object = {
- version = %{V_perl_nagios_object}
- url = http://www.cpan.org/authors/id/T/TO/TOBEYA/
- regex = Nagios-Object-(__VER__)\.tar\.gz
- }
- prog nagios:Nagios-Cmd = {
- version = %{V_perl_nagios_cmd}
- url = http://www.cpan.org/authors/id/T/TO/TOBEYA/
- regex = Nagios-Cmd-(__VER__)\.tar\.gz
- }
- %prep
- %setup -q
- %setup -q -T -D -a 1
- %setup -q -T -D -a 2
- %setup -q -T -D -a 3
- %setup -q -T -D -a 4
- %patch -p0
- %{l_shtool} subst \
- -e 's;/usr/local/nagios/var/;%{l_prefix}/var/nagios/log;' \
- p1.pl
- %build
- # configure and build Nagios
- CC="%{l_cc}" \
- CFLAGS="%{l_cflags -O}" \
- LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
- LIBS="%{l_fsl_libs} -lpng -lz -ljpeg" \
- PATH_TO_TRACEROUTE="%{l_prefix}/sbin/traceroute" \
- ./configure \
- --prefix=%{l_prefix} \
- --sbindir=%{l_prefix}/cgi/nagios \
- --sysconfdir=%{l_prefix}/etc/nagios \
- --libexecdir=%{l_prefix}/libexec/nagios \
- --localstatedir=%{l_prefix}/var/nagios \
- --datadir=%{l_prefix}/share/nagios \
- --with-cgiurl=/nagios/cgi \
- --with-htmurl=/nagios \
- --with-nagios-user=%{l_rusr} \
- --with-nagios-group=%{l_rgrp} \
- --with-command-user=%{l_nusr} \
- --with-command-group=%{l_ngrp} \
- --with-gd-lib=%{l_prefix}/lib \
- --with-gd-inc=%{l_prefix}/include \
- --with-lockfile=%{l_prefix}/var/nagios/run/nagios.pid \
- %if "%{with_perl}" == "yes"
- --enable-embedded-perl \
- --with-perlcache \
- %endif
- --without-init-dir
- %{l_make} %{l_mflags} all
- # configure and build Nagios plugins
- ( cd nagios-plugins-%{V_nagios_plugins}/
- ( echo "ac_cv_ping_packets_first=yes"
- echo "ac_cv_ping_has_timeout=no"
- ) >config.cache
- CC="%{l_cc}" \
- CFLAGS="%{l_cflags -O}" \
- LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
- LIBS="-lssl -lcrypto" \
- ./configure \
- --cache-file=./config.cache \
- --prefix=%{l_prefix}/libexec/nagios \
- --libexecdir=%{l_prefix}/libexec/nagios \
- --with-cgiurl=/nagios/cgi \
- --with-openssl=%{l_prefix} \
- --with-perl=%{l_prefix}/bin/perl \
- --with-df-command="%{l_prefix}/bin/gdf" \
- --with-ping-command="%{l_prefix}/bin/gping -n -c %d %s" \
- --with-ssh-command="%{l_prefix}/bin/ssh" \
- --with-snmpget-command="%{l_prefix}/bin/snmpget" \
- --with-snmpgetnext-command="%{l_prefix}/bin/snmpgetnext"
- %{l_make} %{l_mflags}
- ) || exit $?
- %install
- rm -rf $RPM_BUILD_ROOT
- # create installation hierarchy
- %{l_shtool} mkdir -f -p -m 755 \
- $RPM_BUILD_ROOT%{l_prefix}/etc/nagios \
- $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
- $RPM_BUILD_ROOT%{l_prefix}/libexec/nagios \
- $RPM_BUILD_ROOT%{l_prefix}/var/nagios/log \
- $RPM_BUILD_ROOT%{l_prefix}/var/nagios/run \
- $RPM_BUILD_ROOT%{l_prefix}/var/nagios/cmd
- # install Nagios
- %{l_make} install DESTDIR="$RPM_BUILD_ROOT" INSTALL_OPTS="" COMMAND_OPTS=""
- # install Nagios plugins
- ( cd nagios-plugins-%{V_nagios_plugins}/
- %{l_make} install DESTDIR="$RPM_BUILD_ROOT" \
- MKINSTALLDIRS="%{l_shtool} install -d"
- ) || exit $?
- %if "%{with_perl}" == "yes"
- # install Perl modules
- %{l_prefix}/bin/perl-openpkg prepare
- %{l_prefix}/bin/perl-openpkg -d Nagios-Plugin-%{V_perl_nagios_plugin} configure build install
- %{l_prefix}/bin/perl-openpkg -d Nagios-Object-%{V_perl_nagios_object} configure build install
- %{l_prefix}/bin/perl-openpkg -d Nagios-Cmd-%{V_perl_nagios_cmd} configure build install
- %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
- %else
- >perl-openpkg-files
- %endif
- # post-adjust installation
- %if "%{with_perl}" == "yes"
- mv $RPM_BUILD_ROOT%{l_prefix}/bin/p1.pl \
- $RPM_BUILD_ROOT%{l_prefix}/libexec/nagios/p1.pl
- %endif
- chmod 0755 $RPM_BUILD_ROOT%{l_prefix}/libexec/nagios/utils.sh
- rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/nagios/archives
- rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/nagios/share
- # install default configuration
- for name in `grep "^<file" %{SOURCE nagios.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do
- (echo ""; cat %{SOURCE nagios.txt}; echo "") |\
- sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name
- %{l_shtool} install -c -m 644 %{l_value -s -a} \
- $name $RPM_BUILD_ROOT%{l_prefix}/etc/nagios/
- done
- # install run-command script
- %{l_shtool} install -c -m 755 %{l_value -s -a} \
- %{SOURCE rc.nagios} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
- # install OSSP fsl configuration
- %{l_shtool} mkdir -f -p -m 755 \
- $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
- %{l_shtool} install -c -m 644 %{l_value -s -a} \
- %{SOURCE fsl.nagios} \
- $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
- # determine installation files
- %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
- %{l_files_std} `cat perl-openpkg-files` \
- '%not %dir %{l_prefix}/etc/fsl' \
- '%config %{l_prefix}/etc/fsl/fsl.nagios' \
- '%config %{l_prefix}/etc/nagios/*' \
- '%config %attr(600,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/nagios/resource.cfg' \
- '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/nagios/*' \
- '%attr(2775,%{l_rusr},%{l_ngrp}) %{l_prefix}/var/nagios/cmd'
- %files -f files
- %clean
- rm -rf $RPM_BUILD_ROOT
- %post
- if [ $1 -eq 1 ]; then
- # add hook to Apache configuration
- apacheconf="$RPM_INSTALL_PREFIX/etc/apache/apache.conf"
- if [ -f $apacheconf ]; then
- ( echo "Include $RPM_INSTALL_PREFIX/etc/nagios/apache.conf"
- ) | $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
- -a -i "$RPM_INSTALL_PREFIX:nagios" $apacheconf
- fi
- # display final hints on initial installation
- ( echo "To complete this installation of Nagios please start the"
- echo "Nagios daemon (backend) Apache webserver (frontend) with:"
- echo " \$ $RPM_INSTALL_PREFIX/etc/rc nagios start"
- echo " \$ $RPM_INSTALL_PREFIX/etc/rc apache start"
- echo "After this you can connect to the Nagios frontend via URL"
- echo " http://127.0.0.1/nagios/"
- echo "and login with username \"nagios\" and password \"nagios\"."
- echo "You can change the password with:"
- echo " \$ $RPM_INSTALL_PREFIX/bin/htpasswd \\ "
- echo " $RPM_INSTALL_PREFIX/etc/nagios/apache.passwd nagios"
- ) | %{l_rpmtool} msg -b -t notice
- fi
- if [ $1 -eq 2 ]; then
- # after upgrade, restart service
- eval `%{l_rc} nagios status 2>/dev/null`
- [ ".$nagios_active" = .yes ] && %{l_rc} nagios restart
- fi
- exit 0
- %preun
- if [ $1 -eq 0 ]; then
- # remove hook from Apache configuration
- apacheconf="$RPM_INSTALL_PREFIX/etc/apache/apache.conf"
- if [ -f $apacheconf ]; then
- $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
- -r -i "$RPM_INSTALL_PREFIX:nagios" $apacheconf
- fi
- # before erase, stop service and remove log files
- %{l_rc} nagios stop 2>/dev/null
- rm -f $RPM_INSTALL_PREFIX/var/nagios/log/* >/dev/null 2>&1 || true
- rm -f $RPM_INSTALL_PREFIX/var/nagios/run/* >/dev/null 2>&1 || true
- rm -f $RPM_INSTALL_PREFIX/var/nagios/cmd/* >/dev/null 2>&1 || true
- fi
- exit 0
|