# $Id: Portfile 43467 2008-12-11 01:07:12Z markd@macports.org $

PortSystem	1.0

name			network-weathermap
version			0.95b
revision		4
categories		net
maintainers		markd
platforms		darwin

description		Weathermap is a network visualisation tool, to take graphs you \
                        already have and display an overview of your network as a map. \
			It supports RRD, MRTG (RRD and old log-format), and tab-delimited \
                        text files. Other sources are via plugins or external scripts.

long_description	${description}

homepage		http://www.network-weathermap.com/
master_sites		http://www.network-weathermap.com/files

use_zip			yes
distfiles		php-weathermap-${version}${extract.suffix}
checksums		md5 6481970ad971dfe659eed535b440e678
worksrcdir		weathermap

depends_lib		path:bin/perl:perl5 \
			port:cacti

use_configure   no
build {}

set cactidir ${prefix}/share/cacti
set pluginsdir ${cactidir}/plugins

variant plugins description {Triggers plugins variant when installing Cacti} {}
variant_set plugins

post-patch {
# Set the rrdtool & php paths to point to the MacPorts versions
	reinplace "s|/usr/local|${prefix}|g" \
		${worksrcpath}/weathermap \
		${worksrcpath}/weathermap-cacti-rebuild.php

# Set perl location
	reinplace "s|/usr/bin/perl|${prefix}/bin/perl|g" \
		${worksrcpath}/random-bits/auto-overlib.pl
}

destroot {
	file delete ${worksrcpath}/configs/.htaccess

	file mkdir ${destroot}${pluginsdir}/weathermap
	system "cp -R ${worksrcpath}/* ${destroot}${pluginsdir}/weathermap"

	system "chown -R www:www ${destroot}${pluginsdir}/weathermap/"
}

post-activate {

ui_msg "\n **** To complete the Network Weather Map installation ****

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


1) Set the PHP path in ${pluginsdir}/weathermap to point to your PHP binary


2) Set Network Weather Map permissions to match the Cacti user permissions
   sudo chown -R <cacti-user>:<cacti-group> ${prefix}/share/${pluginsdir}/weathermap


3) Import the PA schema.
	cd ${cactidir}
	sudo cat ${cactidir}/pa.sql | mysql5 -u root -p cacti (cacti is the db name)


4) Edit ${cactidir}/include/global.php - add an entry to load the weathermap plugin as shown:

	\$plugins = array();
	\$plugins[] = 'weathermap';


5) Rename & edit the Network Weathermap Editor's config file
	cd ${pluginsdir}/weathermap
	cp editor-config.php-dist editor-config.php
	nano editor-config.php


6) Set the editor-config.php variables as shown:

	cacti_base = '${cactidir}';
	\$cacti_url = \"http://example.com/cacti/\";


7) Login to the Cacti interface and enable the Network Weather Map plugin; this
   creates a top-level tab for the plugin in the Cacti interface.
        Console -> User Management  (select a Cacti user and check the 'View Weathermaps' checkboxes)

\n"

}
