cacti.spec 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. ##
  2. ## cacti.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.com/>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package information
  26. Name: cacti
  27. Summary: Network Monitoring and Graphing Frontend
  28. URL: http://www.raxnet.net/products/cacti/
  29. Vendor: raXnet
  30. Packager: The OpenPKG Project
  31. Distribution: OpenPKG [EVAL]
  32. Group: Database
  33. License: GPL
  34. Version: 0.8.4
  35. Release: 20031117
  36. # list of sources
  37. Source0: http://www.raxnet.net/downloads/cacti-%{version}.tar.gz
  38. Source1: cacti-setup.sh
  39. Source2: cacti-cron.sh
  40. Source3: cacti-apache.conf
  41. Source4: rc.cacti
  42. # build information
  43. Prefix: %{l_prefix}
  44. BuildRoot: %{l_buildroot}
  45. BuildPreReq: OpenPKG, openpkg >= 20030103
  46. PreReq: OpenPKG, openpkg >= 20030103
  47. PreReq: rrdtool, mysql, snmp, perl, php, wget
  48. PreReq: apache
  49. PreReq: apache::with_mod_php = yes
  50. PreReq: apache::with_mod_php_mysql = yes
  51. AutoReq: no
  52. AutoReqProv: no
  53. %description
  54. Cacti is a complete frontend to RRDTool, it stores all of the
  55. necessary information to create graphs and populate them with data
  56. in a MySQL database. The frontend is completely PHP driven. Along
  57. with being able to maintain Graphs, Data Sources, and Round Robin
  58. Archives in a database, Cacti handles the data gathering. There is
  59. also SNMP support for those used to creating traffic graphs with
  60. MRTG.
  61. %prep
  62. %setup -q
  63. %build
  64. %install
  65. rm -rf $RPM_BUILD_ROOT
  66. # create installation hierarchy
  67. %{l_shtool} mkdir -f -p -m 755 \
  68. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  69. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  70. $RPM_BUILD_ROOT%{l_prefix}/etc/cacti \
  71. $RPM_BUILD_ROOT%{l_prefix}/share/cacti \
  72. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/run
  73. # adjust configuration
  74. %{l_shtool} subst \
  75. -e 's;"cactiuser";"cacti";g' \
  76. include/config.php
  77. %{l_shtool} subst \
  78. -e 's;perl <path_cacti>;%{l_prefix}/bin/perl %{l_prefix}/share/cacti;' \
  79. -e 's;\(path_php_binary.*\)<DEFAULT>;\1%{l_prefix}/bin/php;' \
  80. -e 's;\(path_snmpwalk.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpwalk;' \
  81. -e 's;\(path_snmpget.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpget;' \
  82. -e 's;\(path_rrdtool.*\)<DEFAULT>;\1%{l_prefix}/bin/rrdtool;' \
  83. -e 's;\(path_webroot.*\)<DEFAULT>;\1%{l_prefix}/share/cacti;' \
  84. -e 's;\(path_webcacti.*\)<DEFAULT>;\1/cacti/;' \
  85. -e 's;\(smnp_version.*\)ucd-snmp;\1net-snmp;' \
  86. cacti.sql
  87. %{l_shtool} subst \
  88. -e 's;docs/;../docs/;g' \
  89. install/index.php
  90. %{l_shtool} subst \
  91. -e 's;#!/usr/bin/php;#!%{l_prefix}/bin/php;' \
  92. cmd.php
  93. # install all files and strip down installation afterwards
  94. cp -rp * $RPM_BUILD_ROOT%{l_prefix}/share/cacti/
  95. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
  96. rm -f LICENSE README
  97. rm -rf cactid
  98. rm -f rra/.placeholder
  99. rm -f log/rrd.log
  100. ) || exit $?
  101. # move variable data into separate locations
  102. mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log \
  103. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log
  104. %{l_shtool} mkln -s \
  105. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log \
  106. $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log
  107. mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra \
  108. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra
  109. %{l_shtool} mkln -s \
  110. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra \
  111. $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra
  112. # internally Cacti appends the webroot to its directory
  113. # but we don't want to do this, so use a self-ref link.
  114. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
  115. ln -s . cacti
  116. ) || exit $?
  117. # install run-command script
  118. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  119. %{SOURCE rc.cacti} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  120. # install MySQL database setup script
  121. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  122. %{SOURCE cacti-setup.sh} \
  123. $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-setup
  124. # install Cron job script
  125. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  126. %{SOURCE cacti-cron.sh} \
  127. $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-cron
  128. # install custom Apache configuration
  129. l_hostname=`%{l_shtool} echo -e %h`
  130. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  131. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  132. -e "s;@l_hostname@;$l_hostname;g" \
  133. -e "s;@l_domainname@;$l_domainname;g" \
  134. %{SOURCE cacti-apache.conf} \
  135. $RPM_BUILD_ROOT%{l_prefix}/etc/cacti/
  136. # determine installation files
  137. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  138. %{l_files_std} \
  139. '%config %{l_prefix}/etc/cacti/*' \
  140. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cacti'
  141. %files -f files
  142. %clean
  143. rm -rf $RPM_BUILD_ROOT
  144. %post
  145. if [ $1 -eq 1 ]; then
  146. # display final hints on initial installation
  147. ( echo "1. To complete installation of the Cacti package please you have"
  148. echo " start MySQL and setup the initial Cacti database. For this run"
  149. echo " the following commands:"
  150. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  151. echo " \$ $RPM_INSTALL_PREFIX/sbin/cacti-setup"
  152. echo ""
  153. echo "2. Cacti by default is run by the OpenPKG cron jobs every 15"
  154. echo " minutes only. Usually Cacti wants to run every 5 minutes for"
  155. echo " more granular data gathering. For this set:"
  156. echo " # $RPM_INSTALL_PREFIX/etc/rc.conf:"
  157. echo " cacti_cron=\"no\""
  158. echo " and setup a cronjob for user %{l_rusr}"
  159. echo " # system crontab:"
  160. echo " */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/cacti-cron"
  161. echo ""
  162. echo "3. Cacti by default is running with an own Apache server on"
  163. echo " IPv4 address 127.0.0.1, TCP port 8080. Please change this"
  164. echo " by editing the \"Port 8080\" and \"Listen 127.0.0.1:8080\""
  165. echo " directives in $RPM_INSTALL_PREFIX/etc/cacti/cacti-apache.conf"
  166. echo ""
  167. echo "4. After this post-installation steps, startup Cacti by running"
  168. echo " \$ $RPM_INSTALL_PREFIX/etc/rc cacti start"
  169. echo " and connecting with your browser to:"
  170. echo " http://127.0.0.1:8080/"
  171. echo " Then proceed Cacti's initial configuration dialog. Then login"
  172. echo " as 'admin' (with initial password 'admin') and change the"
  173. echo " password to a custom one."
  174. ) | %{l_rpmtool} msg -b -t notice
  175. fi
  176. %preun
  177. if [ $1 -eq 0 ]; then
  178. # remove generated logfiles
  179. rm -f $RPM_INSTALL_PREFIX/var/cacti/log/*
  180. fi