cacti.spec 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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: 20031208
  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 PHP-driven frontend to RRDTool. It stores all
  55. of the necessary information to create graphs and populate them
  56. with data in a MySQL database. Along with being able to maintain
  57. Graphs, Data Sources, and Round Robin Archives in a database,
  58. Cacti handles the data gathering as well. There is also SNMP
  59. support for those used to creating traffic graphs with MRTG.
  60. %prep
  61. %setup -q
  62. %build
  63. %install
  64. rm -rf $RPM_BUILD_ROOT
  65. # create installation hierarchy
  66. %{l_shtool} mkdir -f -p -m 755 \
  67. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  68. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  69. $RPM_BUILD_ROOT%{l_prefix}/etc/cacti \
  70. $RPM_BUILD_ROOT%{l_prefix}/share/cacti \
  71. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/run
  72. # adjust configuration
  73. %{l_shtool} subst \
  74. -e 's;"cactiuser";"cacti";g' \
  75. include/config.php
  76. %{l_shtool} subst \
  77. -e 's;perl <path_cacti>;%{l_prefix}/bin/perl %{l_prefix}/share/cacti;' \
  78. -e 's;\(path_php_binary.*\)<DEFAULT>;\1%{l_prefix}/bin/php;' \
  79. -e 's;\(path_snmpwalk.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpwalk;' \
  80. -e 's;\(path_snmpget.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpget;' \
  81. -e 's;\(path_rrdtool.*\)<DEFAULT>;\1%{l_prefix}/bin/rrdtool;' \
  82. -e 's;\(path_webroot.*\)<DEFAULT>;\1%{l_prefix}/share/cacti;' \
  83. -e 's;\(path_webcacti.*\)<DEFAULT>;\1/cacti/;' \
  84. -e 's;\(smnp_version.*\)ucd-snmp;\1net-snmp;' \
  85. cacti.sql
  86. %{l_shtool} subst \
  87. -e 's;docs/;../docs/;g' \
  88. install/index.php
  89. %{l_shtool} subst \
  90. -e 's;#!/usr/bin/php;#!%{l_prefix}/bin/php;' \
  91. cmd.php
  92. # install all files and strip down installation afterwards
  93. cp -rp * $RPM_BUILD_ROOT%{l_prefix}/share/cacti/
  94. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
  95. rm -f LICENSE README
  96. rm -rf cactid
  97. rm -f rra/.placeholder
  98. rm -f log/rrd.log
  99. ) || exit $?
  100. # move variable data into separate locations
  101. mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log \
  102. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log
  103. %{l_shtool} mkln -s \
  104. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log \
  105. $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log
  106. mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra \
  107. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra
  108. %{l_shtool} mkln -s \
  109. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra \
  110. $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra
  111. # internally Cacti appends the webroot to its directory
  112. # but we don't want to do this, so use a self-ref link.
  113. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
  114. ln -s . cacti
  115. ) || exit $?
  116. # install run-command script
  117. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  118. %{SOURCE rc.cacti} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  119. # install MySQL database setup script
  120. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  121. %{SOURCE cacti-setup.sh} \
  122. $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-setup
  123. # install Cron job script
  124. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  125. %{SOURCE cacti-cron.sh} \
  126. $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-cron
  127. # install custom Apache configuration
  128. l_hostname=`%{l_shtool} echo -e %h`
  129. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  130. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  131. -e "s;@l_hostname@;$l_hostname;g" \
  132. -e "s;@l_domainname@;$l_domainname;g" \
  133. %{SOURCE cacti-apache.conf} \
  134. $RPM_BUILD_ROOT%{l_prefix}/etc/cacti/
  135. # determine installation files
  136. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  137. %{l_files_std} \
  138. '%config %{l_prefix}/etc/cacti/*' \
  139. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cacti'
  140. %files -f files
  141. %clean
  142. rm -rf $RPM_BUILD_ROOT
  143. %post
  144. if [ $1 -eq 1 ]; then
  145. # display final hints on initial installation
  146. ( echo "1. To complete this installation of Cacti please start MySQL and"
  147. echo " initialize the Cacti database like this:"
  148. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  149. echo " \$ $RPM_INSTALL_PREFIX/sbin/cacti-setup"
  150. echo ""
  151. echo "2. By default, Cacti is run by the OpenPKG cron jobs only every"
  152. echo " 15 minutes. To run Cacti every 5 minutes for more granular"
  153. echo " data gathering, set this variable:"
  154. echo " # $RPM_INSTALL_PREFIX/etc/rc.conf:"
  155. echo " cacti_cron=\"no\""
  156. echo " and insert a new cronjob for user %{l_rusr}"
  157. echo " # system crontab:"
  158. echo " */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/cacti-cron"
  159. echo ""
  160. echo "3. By default, Cacti runs its own Apache server on IPv4 address"
  161. echo " 127.0.0.1, TCP port 8080. Please change this by editing the"
  162. echo " \"Port 8080\" and \"Listen 127.0.0.1:8080\" directives in"
  163. echo " $RPM_INSTALL_PREFIX/etc/cacti/cacti-apache.conf"
  164. echo ""
  165. echo "4. After this postinstallation, start Cacti by running"
  166. echo " \$ $RPM_INSTALL_PREFIX/etc/rc cacti start"
  167. echo " and connect with a browser to:"
  168. echo " http://127.0.0.1:8080/"
  169. echo " Follow Cacti's initial configuration dialogs, and then login"
  170. echo " as 'admin' (with initial password 'admin') to change the"
  171. echo " password to a custom one."
  172. ) | %{l_rpmtool} msg -b -t notice
  173. fi
  174. if [ $1 -eq 2 ]; then
  175. # after upgrade, restart service
  176. eval `%{l_rc} cacti status 2>/dev/null`
  177. [ ".$cacti_active" = .yes ] && %{l_rc} cacti restart
  178. fi
  179. exit 0
  180. %preun
  181. if [ $1 -eq 0 ]; then
  182. # before erase, stop service and remove log files
  183. %{l_rc} cacti stop 2>/dev/null
  184. rm -f $RPM_INSTALL_PREFIX/var/cacti/log/* >/dev/null 2>&1 || true
  185. fi
  186. exit 0