cacti.spec 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. ##
  2. ## cacti.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 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.cacti.net/
  29. Vendor: raXnet
  30. Packager: The OpenPKG Project
  31. Distribution: OpenPKG
  32. Class: PLUS
  33. Group: Database
  34. License: GPL
  35. Version: 0.8.6b
  36. Release: 20041007
  37. # list of sources
  38. Source0: http://www.cacti.net/downloads/cacti-%{version}.tar.gz
  39. Source1: cacti-setup.sh
  40. Source2: cacti-cron.sh
  41. Source3: cacti-apache.conf
  42. Source4: rc.cacti
  43. # build information
  44. Prefix: %{l_prefix}
  45. BuildRoot: %{l_buildroot}
  46. BuildPreReq: OpenPKG, openpkg >= 20040130
  47. PreReq: OpenPKG, openpkg >= 20040130
  48. PreReq: rrdtool, mysql, snmp, perl, php, wget
  49. PreReq: apache
  50. PreReq: apache::with_mod_php = yes
  51. PreReq: apache::with_mod_php_mysql = yes
  52. PreReq: apache::with_mod_php_xml = yes
  53. AutoReq: no
  54. AutoReqProv: no
  55. %description
  56. Cacti is a complete PHP-driven frontend to RRDTool. It stores all
  57. of the necessary information to create graphs and populate them
  58. with data in a MySQL database. Along with being able to maintain
  59. Graphs, Data Sources, and Round Robin Archives in a database,
  60. Cacti handles the data gathering as well. There is also SNMP
  61. support for those used to creating traffic graphs with MRTG.
  62. %track
  63. prog cacti = {
  64. version = %{version}
  65. url = http://www.cacti.net/downloads/
  66. regex = cacti-(__VER__)\.tar\.gz
  67. }
  68. %prep
  69. %setup -q
  70. %build
  71. %install
  72. rm -rf $RPM_BUILD_ROOT
  73. # create installation hierarchy
  74. %{l_shtool} mkdir -f -p -m 755 \
  75. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  76. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  77. $RPM_BUILD_ROOT%{l_prefix}/etc/cacti \
  78. $RPM_BUILD_ROOT%{l_prefix}/share/cacti \
  79. $RPM_BUILD_ROOT%{l_prefix}/var/cacti/run
  80. # adjust configuration
  81. %{l_shtool} subst \
  82. -e 's;"cactiuser";"cacti";g' \
  83. include/config.php
  84. %{l_shtool} subst \
  85. -e 's;perl <path_cacti>;%{l_prefix}/bin/perl %{l_prefix}/share/cacti;' \
  86. -e 's;\(path_php_binary.*\)<DEFAULT>;\1%{l_prefix}/bin/php;' \
  87. -e 's;\(path_snmpwalk.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpwalk;' \
  88. -e 's;\(path_snmpget.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpget;' \
  89. -e 's;\(path_rrdtool.*\)<DEFAULT>;\1%{l_prefix}/bin/rrdtool;' \
  90. -e 's;\(path_webroot.*\)<DEFAULT>;\1%{l_prefix}/share/cacti;' \
  91. -e 's;\(path_webcacti.*\)<DEFAULT>;\1/cacti/;' \
  92. -e 's;\(smnp_version.*\)ucd-snmp;\1net-snmp;' \
  93. cacti.sql
  94. %{l_shtool} subst \
  95. -e 's;docs/;../docs/;g' \
  96. install/index.php
  97. %{l_shtool} subst \
  98. -e 's;#!/usr/bin/php;#!%{l_prefix}/bin/php;' \
  99. cmd.php
  100. # install all files and strip down installation afterwards
  101. cp -rp * $RPM_BUILD_ROOT%{l_prefix}/share/cacti/
  102. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
  103. rm -f LICENSE README
  104. rm -rf cactid
  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 this installation of Cacti please start MySQL and"
  155. echo " initialize the Cacti database like this:"
  156. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  157. echo " \$ $RPM_INSTALL_PREFIX/sbin/cacti-setup"
  158. echo ""
  159. echo "2. By default, Cacti is run by the OpenPKG cron jobs only every"
  160. echo " 15 minutes. To run Cacti every 5 minutes for more granular"
  161. echo " data gathering, set this variable:"
  162. echo " # $RPM_INSTALL_PREFIX/etc/rc.conf:"
  163. echo " cacti_cron=\"no\""
  164. echo " and insert a new cronjob for user %{l_rusr}"
  165. echo " # system crontab:"
  166. echo " */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/cacti-cron"
  167. echo ""
  168. echo "3. By default, Cacti runs its own Apache server on IPv4 address"
  169. echo " 127.0.0.1, TCP port 8080. Please change this by editing the"
  170. echo " \"Port 8080\" and \"Listen 127.0.0.1:8080\" directives in"
  171. echo " $RPM_INSTALL_PREFIX/etc/cacti/cacti-apache.conf"
  172. echo ""
  173. echo "4. After this postinstallation, start Cacti by running"
  174. echo " \$ $RPM_INSTALL_PREFIX/etc/rc cacti start"
  175. echo " and connect with a browser to:"
  176. echo " http://127.0.0.1:8080/"
  177. echo " Follow Cacti's initial configuration dialogs, and then login"
  178. echo " as 'admin' (with initial password 'admin') to change the"
  179. echo " password to a custom one."
  180. ) | %{l_rpmtool} msg -b -t notice
  181. fi
  182. if [ $1 -eq 2 ]; then
  183. # after upgrade, restart service
  184. eval `%{l_rc} cacti status 2>/dev/null`
  185. [ ".$cacti_active" = .yes ] && %{l_rc} cacti restart
  186. fi
  187. exit 0
  188. %preun
  189. if [ $1 -eq 0 ]; then
  190. # before erase, stop service and remove log files
  191. %{l_rc} cacti stop 2>/dev/null
  192. rm -f $RPM_INSTALL_PREFIX/var/cacti/log/* >/dev/null 2>&1 || true
  193. fi
  194. exit 0