cacti.spec 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.3
  35. Release: 20030829
  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. ( mv include/adodb/drivers/adodb-mysql* .
  99. rm -rf include/adodb/drivers/*
  100. mv adodb-mysql* include/adodb/drivers/
  101. mv include/adodb/datadict/datadict-mssql* .
  102. rm -rf include/adodb/datadict/*
  103. mv datadict-mssql* include/adodb/datadict/
  104. ) || exit $?
  105. rm -f rra/.placeholder
  106. rm -f log/rrd.log
  107. ) || exit $?
  108. # move variable data into separate locations
  109. mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log \
  110. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log
  111. %{l_shtool} mkln -s \
  112. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log \
  113. $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log
  114. mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra \
  115. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra
  116. %{l_shtool} mkln -s \
  117. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra \
  118. $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra
  119. # internally Cacti appends the webroot to its directory
  120. # but we don't want to do this, so use a self-ref link.
  121. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
  122. ln -s . cacti
  123. ) || exit $?
  124. # install run-command script
  125. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  126. %{SOURCE rc.cacti} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  127. # install MySQL database setup script
  128. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  129. %{SOURCE cacti-setup.sh} \
  130. $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-setup
  131. # install Cron job script
  132. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  133. %{SOURCE cacti-cron.sh} \
  134. $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-cron
  135. # install custom Apache configuration
  136. l_hostname=`%{l_shtool} echo -e %h`
  137. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  138. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  139. -e "s;@l_hostname@;$l_hostname;g" \
  140. -e "s;@l_domainname@;$l_domainname;g" \
  141. %{SOURCE cacti-apache.conf} \
  142. $RPM_BUILD_ROOT%{l_prefix}/etc/cacti/
  143. # determine installation files
  144. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  145. %{l_files_std} \
  146. '%config %{l_prefix}/etc/cacti/*' \
  147. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cacti'
  148. %files -f files
  149. %clean
  150. rm -rf $RPM_BUILD_ROOT
  151. %post
  152. if [ $1 -eq 1 ]; then
  153. # display final hints on initial installation
  154. ( echo "1. To complete installation of the Cacti package please you have"
  155. echo " start MySQL and setup the initial Cacti database. For this run"
  156. echo " the following commands:"
  157. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  158. echo " \$ $RPM_INSTALL_PREFIX/sbin/cacti-setup"
  159. echo ""
  160. echo "2. Cacti by default is run by the OpenPKG cron jobs every 15"
  161. echo " minutes only. Usually Cacti wants to run every 5 minutes for"
  162. echo " more granular data gathering. For this set:"
  163. echo " # $RPM_INSTALL_PREFIX/etc/rc.conf:"
  164. echo " cacti_cron=\"no\""
  165. echo " and setup a cronjob for user %{l_rusr}"
  166. echo " # system crontab:"
  167. echo " */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/cacti-cron"
  168. echo ""
  169. echo "3. Cacti by default is running with an own Apache server on"
  170. echo " IPv4 address 127.0.0.1, TCP port 8080. Please change this"
  171. echo " by editing the \"Port 8080\" and \"Listen 127.0.0.1:8080\""
  172. echo " directives in $RPM_INSTALL_PREFIX/etc/cacti/cacti-apache.conf"
  173. echo ""
  174. echo "4. After this post-installation steps, startup Cacti by running"
  175. echo " \$ $RPM_INSTALL_PREFIX/etc/rc cacti start"
  176. echo " and connecting with your browser to:"
  177. echo " http://127.0.0.1:8080/"
  178. echo " Then proceed Cacti's initial configuration dialog. Then login"
  179. echo " as 'admin' (with initial password 'admin') and change the"
  180. echo " password to a custom one."
  181. ) | %{l_rpmtool} msg -b -t notice
  182. fi
  183. %preun
  184. if [ $1 -eq 0 ]; then
  185. # remove generated logfiles
  186. rm -f $RPM_INSTALL_PREFIX/var/cacti/log/*
  187. fi