Portfile

# $Id: Portfile 21624 2007-01-31 07:16:54Z markd@macports.org $

PortSystem 1.0

name cacti
version 0.8.6j
categories net
maintainers markd@macports.org
platforms darwin

description Cacti is a complete RRDtool network graphing solution.

long_description Cacti is a complete network graphing solution designed \
to harness the power of RRDtool's data storage and \
graphing functions.

homepage http://www.cacti.net
master_sites http://www.cacti.net/downloads/

checksums ${distname}${extract.suffix} md5 29436be46b289d13dfce48e7618129e2

patchfiles tree_console_missing_hosts.patch

depends_lib port:mysql5 \
port:rrdtool

use_configure no
build {}
set cactidir ${prefix}/share/cacti

variant server {
# This variant doesn't do anything in this port, it only exists to trigger the server
# variant in the mysql5 port.
}

variant_set server

destroot {
xinstall -m 755 -d ${destroot}${cactidir}
system "cp -R ${worksrcpath}/* ${destroot}${cactidir}"
}

post-activate {

ui_msg "\n **** To complete the Cacti OS X installation ****

To complete the Cacti installation follow the steps below. Read the documentation
at http://www.cacti.net/documentation.php for operational instructions.


1) Install PHP (not covered) including command line interface (CLI) support.
After PHP is installed, make sure that your httpd.conf file has these
lines uncommented for CLI support.

'LoadModule php4_module ...' (Apache 1 & 2)
'AddModule mod_php4.c' (Apache 1)

Set mysql.default_socket path to ${prefix}/var/run/mysql5/mysqld.sock in file:
./phpx/lib/php.ini (in /usr/local, ${prefix}, or /Library depending on PHP package)


2) Set Cacti permissions.
sudo chown -R : ${prefix}/share/${name}/

3) Setup MySQL and prepare it for Cacti.
Configure MySQL (new MySQL installs)
sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db

Start MySQL:
sudo ${prefix}/share/mysql5/mysql/mysql.server start

Set MySQL to start at system boot (optional)
sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.mysql5.plist

Set a root MySQL password.
Follow the instructions that were given after you executed 'mysql_install_db' above.

Create a cacti MySQL user and cacti database.
mysql5 -u root -p (login with new root password when prompted)
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on cacti.* to cacti@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on cacti.* to cacti;
mysql> SET PASSWORD FOR cacti@localhost = OLD_PASSWORD('');
mysql> create database cacti;
mysql> exit;

Import the cacti database.
sudo cat ${cactidir}/cacti.sql | mysql5 -u root -p cacti (cacti is the db name)

Verify the Cacti Database.
mysql5 -u root -p
mysql> use cacti;
mysql> show tables;
mysql> exit;

4) Edit ${cactidir}/include/config.php to match your MySQL information.

\$database_type = \"mysql\";
\$database_default = \"cacti\";
\$database_hostname = \"localhost\";
\$database_username = \"cacti\";
\$database_password = \"\";

5) Place a symlink for Cacti inside your Apache document root.

ln -s ${cactidir} /cacti

6) Edit the Cacti user's crontab file.
sudo -u crontab -e

Insert the crontab entry below:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * ${cactidir}/poller.php > /dev/null 2>&1

7) Go to http://localhost/cacti/install/index.php.
The default login information is admin/admin. Select 'New Install' and
then enter the SNMP and RRDtool paths (see below) and click 'Finish'.
You may now use Cacti at http://localhost/cacti/index.php.

Paths:
snmpwalk binary path: /usr/bin/snmpwalk
snmpget binary path: /usr/bin/snmpget

RRDtool binary path: ${prefix}/bin/rrdtool
PHP binary path: /usr/bin/php (or appropriate PHP path)


\n"

}

files