nagios.spec 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. ##
  2. ## nagios.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2006 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package versions
  25. %define V_nagios 1.3
  26. %define V_nagios_plugins 1.4.2
  27. # package information
  28. Name: nagios
  29. Summary: System and Network Monitoring
  30. URL: http://www.nagios.org/
  31. Vendor: Ethan Galstad et al.
  32. Packager: OpenPKG
  33. Distribution: OpenPKG
  34. Class: EVAL
  35. Group: Network
  36. License: GNU
  37. Version: %{V_nagios}
  38. Release: 20060123
  39. # package options
  40. %option with_eperl yes
  41. %option with_fsl yes
  42. %option with_ldap yes
  43. # list of sources
  44. Source0: http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-%{V_nagios}.tar.gz
  45. Source1: http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-%{V_nagios_plugins}.tar.gz
  46. Source2: etc.tar
  47. Source3: rc.nagios
  48. Source4: fsl.nagios
  49. Patch0: nagios.patch
  50. # build information
  51. Prefix: %{l_prefix}
  52. BuildRoot: %{l_buildroot}
  53. BuildPreReq: OpenPKG, openpkg >= 20040130, traceroute, gcc
  54. PreReq: OpenPKG, openpkg >= 20040130, traceroute, apache, MTA
  55. BuildPreReq: zlib, jpeg, png, gd
  56. PreReq: zlib, jpeg, png, gd
  57. BuildPreReq: openssl, openssh, coreutils, inetutils, fping
  58. PreReq: openssl, openssh, coreutils, inetutils, fping
  59. %if "%{with_ldap}" == "yes"
  60. BuildPreReq: openldap
  61. PreReq: openldap
  62. %endif
  63. %if "%{with_fsl}" == "yes"
  64. BuildPreReq: fsl >= 1.3.0
  65. PreReq: fsl >= 1.3.0
  66. %endif
  67. AutoReq: no
  68. AutoReqProv: no
  69. %description
  70. Nagios is a system and network monitoring application. It watches
  71. hosts and services that you specify, alerting you when things go bad
  72. and when they get better.
  73. %track
  74. prog nagios = {
  75. version = %{V_nagios}
  76. url = http://prdownloads.sourceforge.net/nagios/
  77. regex = nagios-(\d+(\.\d+)+)\.tar\.gz
  78. }
  79. prog nagios:plugins = {
  80. version = %{V_nagios_plugins}
  81. url = http://prdownloads.sourceforge.net/nagiosplug/
  82. regex = nagios-plugins-(\d+(\.\d+)+)\.tar\.gz
  83. }
  84. %prep
  85. %setup -q
  86. %setup -q -T -D -a 1
  87. %setup -q -T -D -a 2
  88. %patch -p0
  89. %{l_shtool} subst \
  90. -e 's;LDAPLIBS=.*-lldap.*;LDAPLIBS="-lldap -llber -lssl -lcrypto";' \
  91. -e 's;LDAPINCLUDE=.*-I.*;LDAPINCLUDE="-I/%{l_prefix}/include";' \
  92. nagios-plugins-%{V_nagios_plugins}/configure
  93. %build
  94. CC="%{l_cc}" \
  95. CFLAGS="%{l_cflags -O}" \
  96. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
  97. LIBS="%{l_fsl_libs} -lpng -ljpeg" \
  98. PATH_TO_TRACEROUTE="%{l_prefix}/sbin/traceroute" \
  99. ./configure \
  100. --prefix=%{l_prefix} \
  101. --sbindir=%{l_prefix}/cgi/nagios \
  102. --sysconfdir=%{l_prefix}/etc/nagios \
  103. --libexecdir=%{l_prefix}/libexec/nagios \
  104. --localstatedir=%{l_prefix}/var/nagios \
  105. --datadir=%{l_prefix}/web/nagios \
  106. --with-cgiurl=/nagios/cgi \
  107. --with-htmurl=/nagios \
  108. --with-nagios-user=%{l_musr} \
  109. --with-nagios-grp=%{l_mgrp} \
  110. --with-gd-lib=%{l_prefix}/lib \
  111. --with-gd-inc=%{l_prefix}/include \
  112. --with-lockfile=%{l_prefix}/var/nagios/nagios.pid \
  113. %if "%{with_eperl}" == "yes"
  114. --enable-embedded-perl \
  115. %endif
  116. --without-init-dir
  117. %{l_make} %{l_mflags} all GDLIBS="-lgd -lm -lpng -lz -ljpeg"
  118. # configure and build plugins
  119. ( cd nagios-plugins-%{V_nagios_plugins}/
  120. CC="%{l_cc}" \
  121. CFLAGS="%{l_cflags -O}" \
  122. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
  123. PATH_TO_PING="%{l_prefix}/bin/gping" \
  124. PING_PACKETS_FIRST="yes" \
  125. PATH_TO_SSH="%{l_prefix}/bin/ssh" \
  126. LIBS="-lssl -lcrypto"
  127. ./configure \
  128. --prefix=%{l_prefix}/libexec/nagios \
  129. --libexecdir=%{l_prefix}/libexec/nagios \
  130. --with-openssl=%{l_prefix} \
  131. --with-df-command=%{l_prefix}/bin/gdf \
  132. --with-ping-command="%{l_prefix}/bin/gping -n -c %d %s" \
  133. --with-nagios-user=%{l_musr} \
  134. --with-nagios-group=%{l_mgrp} \
  135. --with-cgiurl=/nagios/cgi
  136. %{l_make} %{l_mflags}
  137. ) || exit $?
  138. %install
  139. rm -rf $RPM_BUILD_ROOT
  140. %{l_shtool} mkdir -f -p -m 755 \
  141. $RPM_BUILD_ROOT%{l_prefix}/etc/nagios \
  142. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  143. $RPM_BUILD_ROOT%{l_prefix}/libexec/nagios \
  144. $RPM_BUILD_ROOT%{l_prefix}/var/nagios/log \
  145. $RPM_BUILD_ROOT%{l_prefix}/var/nagios/rw
  146. %{l_make} install DESTDIR="$RPM_BUILD_ROOT" INSTALL_OPTS="" COMMAND_OPTS=""
  147. # install plugins
  148. ( cd nagios-plugins-%{V_nagios_plugins}/
  149. %{l_make} install DESTDIR="$RPM_BUILD_ROOT"
  150. ) || exit $?
  151. # install default configuration
  152. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  153. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/nagios/
  154. # install start script
  155. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  156. %{SOURCE rc.nagios} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  157. # install OSSP fsl configuration
  158. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  159. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  160. %{SOURCE fsl.nagios} \
  161. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  162. # determine installation files
  163. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  164. %{l_files_std} \
  165. '%not %dir %{l_prefix}/etc/fsl' \
  166. '%config %{l_prefix}/etc/fsl/fsl.nagios' \
  167. '%config %{l_prefix}/etc/nagios/*'
  168. %files -f files
  169. %clean
  170. rm -rf $RPM_BUILD_ROOT
  171. %post
  172. # after upgrade, restart service
  173. [ $1 -eq 2 ] || exit 0
  174. eval `%{l_rc} nagios status 2>/dev/null`
  175. [ ".$nagios_active" = .yes ] && %{l_rc} nagios restart
  176. exit 0
  177. %preun
  178. # before erase, stop service and remove log files
  179. [ $1 -eq 0 ] || exit 0
  180. %{l_rc} nagios stop 2>/dev/null
  181. rm -f $RPM_INSTALL_PREFIX/var/nagios/log/*.log* >/dev/null 2>&1 || true
  182. rm -f $RPM_INSTALL_PREFIX/var/nagios/status.sav >/dev/null 2>&1 || true
  183. exit 0