cacti.spec 8.1 KB

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