## ## cacti.spec -- OpenPKG RPM Package Specification ## Copyright (c) 2000-2005 OpenPKG Foundation e.V. ## Copyright (c) 2000-2005 Ralf S. Engelschall ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that ## the above copyright notice and this permission notice appear in all ## copies. ## ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## # package information Name: cacti Summary: Network Monitoring and Graphing Frontend URL: http://www.cacti.net/ Vendor: raXnet Packager: OpenPKG Distribution: OpenPKG Class: PLUS Group: Database License: GPL Version: 0.8.6f Release: 20050701 # list of sources Source0: http://www.cacti.net/downloads/cacti-%{version}.tar.gz Source1: cacti-setup.sh Source2: cacti-cron.sh Source3: cacti-apache.conf Source4: rc.cacti # build information Prefix: %{l_prefix} BuildRoot: %{l_buildroot} BuildPreReq: OpenPKG, openpkg >= 20040130 PreReq: OpenPKG, openpkg >= 20040130 PreReq: rrdtool, mysql, snmp, perl, php, wget PreReq: apache PreReq: apache::with_mod_php = yes PreReq: apache::with_mod_php_mysql = yes PreReq: apache::with_mod_php_xml = yes AutoReq: no AutoReqProv: no %description Cacti is a complete PHP-driven frontend to RRDTool. It stores all of the necessary information to create graphs and populate them with data in a MySQL database. Along with being able to maintain Graphs, Data Sources, and Round Robin Archives in a database, Cacti handles the data gathering as well. There is also SNMP support for those used to creating traffic graphs with MRTG. %track prog cacti = { version = %{version} url = http://www.cacti.net/downloads/ regex = cacti-(__VER__)\.tar\.gz } %prep %setup -q %build %install rm -rf $RPM_BUILD_ROOT # create installation hierarchy %{l_shtool} mkdir -f -p -m 755 \ $RPM_BUILD_ROOT%{l_prefix}/sbin \ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ $RPM_BUILD_ROOT%{l_prefix}/etc/cacti \ $RPM_BUILD_ROOT%{l_prefix}/share/cacti \ $RPM_BUILD_ROOT%{l_prefix}/var/cacti/run # adjust configuration %{l_shtool} subst \ -e 's;"cactiuser";"cacti";g' \ include/config.php %{l_shtool} subst \ -e 's;perl ;%{l_prefix}/bin/perl %{l_prefix}/share/cacti;' \ -e 's;\(path_php_binary.*\);\1%{l_prefix}/bin/php;' \ -e 's;\(path_snmpwalk.*\);\1%{l_prefix}/bin/snmpwalk;' \ -e 's;\(path_snmpget.*\);\1%{l_prefix}/bin/snmpget;' \ -e 's;\(path_rrdtool.*\);\1%{l_prefix}/bin/rrdtool;' \ -e 's;\(path_webroot.*\);\1%{l_prefix}/share/cacti;' \ -e 's;\(path_webcacti.*\);\1/cacti/;' \ -e 's;\(smnp_version.*\)ucd-snmp;\1net-snmp;' \ cacti.sql %{l_shtool} subst \ -e 's;docs/;../docs/;g' \ install/index.php %{l_shtool} subst \ -e 's;#!/usr/bin/php;#!%{l_prefix}/bin/php;' \ cmd.php # install all files and strip down installation afterwards cp -rp * $RPM_BUILD_ROOT%{l_prefix}/share/cacti/ ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti rm -f LICENSE README rm -rf cactid rm -f rra/.placeholder rm -f log/rrd.log ) || exit $? # move variable data into separate locations mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log \ $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log %{l_shtool} mkln -s \ $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log \ $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra \ $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra %{l_shtool} mkln -s \ $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra \ $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra # internally Cacti appends the webroot to its directory # but we don't want to do this, so use a self-ref link. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti ln -s . cacti ) || exit $? # install run-command script %{l_shtool} install -c -m 755 %{l_value -s -a} \ %{SOURCE rc.cacti} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ # install MySQL database setup script %{l_shtool} install -c -m 755 %{l_value -s -a} \ %{SOURCE cacti-setup.sh} \ $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-setup # install Cron job script %{l_shtool} install -c -m 755 %{l_value -s -a} \ %{SOURCE cacti-cron.sh} \ $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-cron # install custom Apache configuration l_hostname=`%{l_shtool} echo -e %h` l_domainname=`%{l_shtool} echo -e %d | cut -c2-` %{l_shtool} install -c -m 644 %{l_value -s -a} \ -e "s;@l_hostname@;$l_hostname;g" \ -e "s;@l_domainname@;$l_domainname;g" \ %{SOURCE cacti-apache.conf} \ $RPM_BUILD_ROOT%{l_prefix}/etc/cacti/ # determine installation files %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ %{l_files_std} \ '%config %{l_prefix}/etc/cacti/*' \ '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cacti' %files -f files %clean rm -rf $RPM_BUILD_ROOT %post if [ $1 -eq 1 ]; then # display final hints on initial installation ( echo "1. To complete this installation of Cacti please start MySQL and" echo " initialize the Cacti database like this:" echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start" echo " \$ $RPM_INSTALL_PREFIX/sbin/cacti-setup" echo "" echo "2. By default, Cacti is run by the OpenPKG cron jobs only every" echo " 15 minutes. To run Cacti every 5 minutes for more granular" echo " data gathering, set this variable:" echo " # $RPM_INSTALL_PREFIX/etc/rc.conf:" echo " cacti_cron=\"no\"" echo " and insert a new cronjob for user %{l_rusr}" echo " # system crontab:" echo " */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/cacti-cron" echo "" echo "3. By default, Cacti runs its own Apache server on IPv4 address" echo " 127.0.0.1, TCP port 8080. Please change this by editing the" echo " \"Port 8080\" and \"Listen 127.0.0.1:8080\" directives in" echo " $RPM_INSTALL_PREFIX/etc/cacti/cacti-apache.conf" echo "" echo "4. After this postinstallation, start Cacti by running" echo " \$ $RPM_INSTALL_PREFIX/etc/rc cacti start" echo " and connect with a browser to:" echo " http://127.0.0.1:8080/" echo " Follow Cacti's initial configuration dialogs, and then login" echo " as 'admin' (with initial password 'admin') to change the" echo " password to a custom one." ) | %{l_rpmtool} msg -b -t notice fi if [ $1 -eq 2 ]; then # after upgrade, restart service eval `%{l_rc} cacti status 2>/dev/null` [ ".$cacti_active" = .yes ] && %{l_rc} cacti restart fi exit 0 %preun if [ $1 -eq 0 ]; then # before erase, stop service and remove log files %{l_rc} cacti stop 2>/dev/null rm -f $RPM_INSTALL_PREFIX/var/cacti/log/* >/dev/null 2>&1 || true fi exit 0