diff options
17 files changed, 368 insertions, 0 deletions
diff --git a/net-mgmt/Makefile b/net-mgmt/Makefile index d2601de21544..3e6d134c5274 100644 --- a/net-mgmt/Makefile +++ b/net-mgmt/Makefile @@ -78,6 +78,7 @@ SUBDIR += grepcidr SUBDIR += grepip SUBDIR += gsnmp + SUBDIR += guifi-snpservices SUBDIR += hastmon SUBDIR += hawk SUBDIR += horde3-nic diff --git a/net-mgmt/guifi-snpservices/Makefile b/net-mgmt/guifi-snpservices/Makefile new file mode 100644 index 000000000000..6924ab40edd7 --- /dev/null +++ b/net-mgmt/guifi-snpservices/Makefile @@ -0,0 +1,33 @@ +# Created by: Tassilo Philipp <tphilipp@potion-studios.com> +# $FreeBSD$ + +PORTNAME= snpservices +DISTVERSION= 0.2.2-5 +CATEGORIES= www +MASTER_SITES= http://serveis.guifi.net/debian/guifi/ \ + http://www.potion-studios.com/ +PKGNAMEPREFIX= guifi- +DISTNAME= ${PORTNAME}_${DISTVERSION} + +MAINTAINER= tphilipp@potion-studios.com +COMMENT= Graphics server for the guifi.net meshnet + +RUN_DEPENDS= mrtg:${PORTSDIR}/net-mgmt/mrtg \ + rrdtool:${PORTSDIR}/databases/rrdtool + +USE_PHP= gd simplexml dom + +SNPSERVICES_TMPDIR?= /var/tmp/${PORTNAME} +SUB_FILES= pkg-install pkg-deinstall pkg-message +SUB_LIST= SNPSERVICES_TMPDIR=${SNPSERVICES_TMPDIR} + +WRKSRC= ${WRKDIR}/${PORTNAME}-0.2.2 +NO_BUILD= yes + +do-install: + ${MKDIR} ${STAGEDIR}${WWWDIR} + (cd ${WRKSRC} \ + && ${COPYTREE_SHARE} \* ${STAGEDIR}${WWWDIR}) + ${FIND} ${STAGEDIR}${WWWDIR} -type f -exec ${CHMOD} 644 '{}' + + +.include <bsd.port.mk> diff --git a/net-mgmt/guifi-snpservices/distinfo b/net-mgmt/guifi-snpservices/distinfo new file mode 100644 index 000000000000..d0e362fa0ffc --- /dev/null +++ b/net-mgmt/guifi-snpservices/distinfo @@ -0,0 +1,2 @@ +SHA256 (snpservices_0.2.2-5.tar.gz) = b08d003221d9d5ad688602a973838a0f83b1c99022a11c1ed08a520de8debb51 +SIZE (snpservices_0.2.2-5.tar.gz) = 185825 diff --git a/net-mgmt/guifi-snpservices/files/patch-common-config.php.template b/net-mgmt/guifi-snpservices/files/patch-common-config.php.template new file mode 100644 index 000000000000..0e66c09e525c --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-common-config.php.template @@ -0,0 +1,64 @@ +--- common/config.php.template.orig 2014-02-21 15:53:13.000000000 +0000 ++++ common/config.php.template 2014-04-10 13:41:47.000000000 +0000 +@@ -1,10 +1,10 @@ + <?php + + // snp_pat: full directory where snp services are located +-$snp_path='/var/www/html/snpservices'; ++$snp_path='/usr/local/www/snpservices'; + + // SNPGraphServerID: Default Graph Server ID +-$SNPGraphServerId = 6579; ++$SNPGraphServerId = 67063; + + // rootZone: which is the ROOT zone + $rootZone = 3671; +@@ -15,21 +15,21 @@ + // MRTGConfigSource: mrtg csv data + // As a input, could be either a local (to be created from + // cached CNML file, or remote +-$MRTGConfigSource='http://proves.elserrat.guifi.net/snpservices/graphs/cnml2mrtgcsv.php'; +-//$MRTGConfigSource='../data/guifi_mrtg.csv'; ++$MRTGConfigSource='http://guifi.net/snpservices/graphs/cnml2mrtgcsv.php?server='.$SNPGraphServerId; ++//$MRTGConfigSource='/var/tmp/snpservices/data/guifi_mrtg.csv'; + + // CNMLSource: url for CNML node query, use sprintf syntax + // MySQL-drupal source +-//$CNMLSource='http://proves.elserrat.guifi.net/guifi/cnml/%s/node'; ++//$CNMLSource='http://guifi.net/guifi/cnml/%s/node'; + // Cached CNML source (prefered) +-$CNMLSource='http://proves.elserrat.guifi.net/snpservices/common/qnodes.php?nodes=%s'; ++$CNMLSource='http://guifi.net/snpservices/common/qnodes.php?nodes=%s'; + +-$CNMLData='../data/guifi.cnml'; ++$CNMLData='/var/tmp/snpservices/data/guifi.cnml'; + + // rrdtool parameters +-$rrdtool_path='/usr/bin/rrdtool'; +-$rrddb_path='/home1/comesfa/mrtg/logs/'; +-$rrdimg_path='/home1/comesfa/mrtg/images/'; ++$rrdtool_path='/usr/local/bin/rrdtool'; ++$rrddb_path='/var/tmp/snpservices/logs/'; ++$rrdimg_path='/var/tmp/snpservices/images/'; + + // which version does have this server? + // currently supported versions are: +@@ -38,8 +38,7 @@ + $rrdtool_version = "1.3"; + + // mrtg local header +-$rrdtool_header='# PathAdd: /usr/local/rrdtool-1.2.12/bin +-# LibAdd: /usr/local/rrdtool-1.2.12/lib/perl/5.8.8/i386-linux-thread-multi ++$rrdtool_header='PathAdd: /usr/local/bin/ + HtmlDir: %s + ImageDir: %s + LogDir: %s +@@ -57,7 +56,7 @@ + <TR><TD>Description:</TD><TD>ping</TD></TR> + <TR><TD>IP:</TD> <TD>%s</TD></TR> + </TABLE> +-Target[%s_ping]: `/etc/mrtg/ping.sh %s` ++Target[%s_ping]: `sh '.$snp_path.'/common/ping.sh %s` + MaxBytes[%s_ping]: 2000 + Options[%s_ping]: growright,unknaszero,nopercent,gauge + LegendI[%s_ping]: Perduts % diff --git a/net-mgmt/guifi-snpservices/files/patch-common-misc.php b/net-mgmt/guifi-snpservices/files/patch-common-misc.php new file mode 100644 index 000000000000..899eede0907d --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-common-misc.php @@ -0,0 +1,20 @@ +--- common/misc.php.orig 2014-04-10 14:05:20.000000000 +0000 ++++ common/misc.php 2014-04-10 14:05:45.000000000 +0000 +@@ -177,7 +177,7 @@ + foreach ($an as $nc) { + $try = 0; + $xml = false; +- $fn = $prefix.'tmp/'.$nc.'.cnml'; ++ $fn = $prefix.'/var/tmp/snpservices/tmp/'.$nc.'.cnml'; + do { + // print " Processing $nc try $try cache: $waitcache\n<br>"; + if (file_exists($fn)) { +@@ -232,7 +232,7 @@ + if ($xml) { + $xpnxml = $xml->xpath('//node'); + foreach ($xpnxml as $nxml) { +- $fn = $prefix.'tmp/'.$nxml->attributes()->id.'.cnml'; ++ $fn = $prefix.'/var/tmp/snpservices/tmp/'.$nxml->attributes()->id.'.cnml'; + $wcnml = @fopen($fn, "w+") or die("\n<br>Error caching XML, can't write $fn\n"); + fwrite($wcnml,'<cnml>'.$nxml->asXML().'</cnml>'); + fclose($wcnml); diff --git a/net-mgmt/guifi-snpservices/files/patch-common-ping.sh b/net-mgmt/guifi-snpservices/files/patch-common-ping.sh new file mode 100644 index 000000000000..6da57a01b14e --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-common-ping.sh @@ -0,0 +1,22 @@ +--- ./common/ping.sh.orig 2014-02-21 15:53:13.000000000 +0000 ++++ ./common/ping.sh 2014-04-10 14:19:56.000000000 +0000 +@@ -1,15 +1,15 @@ + #!/bin/sh +- PING="/bin/ping" ++ PING="/sbin/ping" + ADDR=$1 +- DATA=`$PING -c5 -i 0.2 $ADDR -q -W 4` ++ DATA=`$PING -c 5 -i 0.2 -q -W 4 $ADDR` + LOSS=`echo $DATA | awk '{print $18 }' | tr -d %` + ERRORS=`echo $DATA | awk '{print $19 }' | tr -d %` +- if [ $ERRORS = "errors," ] ++ if [ "$ERRORS" = "errors," ] + then + LOSS=`echo $DATA | awk '{print $20 }' | tr -d %` + fi + echo $LOSS +- if [ $LOSS = 100 ]; ++ if [ "$LOSS" = 100 ]; + then + echo 0 + else diff --git a/net-mgmt/guifi-snpservices/files/patch-common-qnodes.php b/net-mgmt/guifi-snpservices/files/patch-common-qnodes.php new file mode 100644 index 000000000000..16d67bac4454 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-common-qnodes.php @@ -0,0 +1,11 @@ +--- common/qnodes.php.orig 2014-04-10 12:44:55.000000000 +0000 ++++ common/qnodes.php 2014-04-10 12:45:28.000000000 +0000 +@@ -19,7 +19,7 @@ + // Opening CNML source + $doc = new DOMDocument; + $doc->preserveWhiteSpace = false; +-$doc->Load('../data/guifi.cnml'); ++$doc->Load('/var/tmp/snpservices/data/guifi.cnml'); + + // building the xpath query for requested nodes + $xpath = new DOMXPath($doc); diff --git a/net-mgmt/guifi-snpservices/files/patch-common-refresh_cnml.php b/net-mgmt/guifi-snpservices/files/patch-common-refresh_cnml.php new file mode 100644 index 000000000000..ff7a9b5c6696 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-common-refresh_cnml.php @@ -0,0 +1,19 @@ +--- common/refresh_cnml.php.orig 2014-04-10 12:41:40.000000000 +0000 ++++ common/refresh_cnml.php 2014-04-10 12:43:16.000000000 +0000 +@@ -27,14 +27,14 @@ + echo "Getting CNML file\n"; + $hcnml = @fopen($SNPDataServer_url."/guifi/cnml/".$rootZone."/detail", "r") + or die ('Error redaing CNML source\n'); +- $wcnml = @fopen("../data/guifi.cnml.tmp", "w"); ++ $wcnml = @fopen("/var/tmp/snpservices/data/guifi.cnml.tmp", "w"); + while (!feof($hcnml)) { + $buffer = fgets($hcnml, 4096); + fwrite($wcnml,$buffer); + } + fclose($hcnml); + fclose($wcnml); +- exec ("/bin/cp ../data/guifi.cnml.tmp ../data/guifi.cnml"); ++ exec ("/bin/cp /var/tmp/snpservices/data/guifi.cnml.tmp /var/tmp/snpservices/data/guifi.cnml"); + + $hlast= @fopen("/tmp/last_update.cnml", "w") or die('Error!'); + fwrite($hlast,$last_now); diff --git a/net-mgmt/guifi-snpservices/files/patch-common-refresh_mrtg.php b/net-mgmt/guifi-snpservices/files/patch-common-refresh_mrtg.php new file mode 100644 index 000000000000..a2fc3c710268 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-common-refresh_mrtg.php @@ -0,0 +1,11 @@ +--- common/refresh_mrtg.php.orig 2014-04-10 12:44:08.000000000 +0000 ++++ common/refresh_mrtg.php 2014-04-10 12:44:27.000000000 +0000 +@@ -29,7 +29,7 @@ + + echo "Getting MRTG CSV file\n"; + $hcnml = @fopen($MRTGConfigSource, "r"); +- $wcnml = @fopen("../data/guifi_mrtg.csv", "w"); ++ $wcnml = @fopen("/var/tmp/snpservices/data/guifi_mrtg.csv", "w"); + while (!feof($hcnml)) { + $buffer = fgets($hcnml, 4096); + fwrite($wcnml,$buffer); diff --git a/net-mgmt/guifi-snpservices/files/patch-graphs-cnml2mrtgcsv.php b/net-mgmt/guifi-snpservices/files/patch-graphs-cnml2mrtgcsv.php new file mode 100644 index 000000000000..3ec2c299ad50 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-graphs-cnml2mrtgcsv.php @@ -0,0 +1,11 @@ +--- graphs/cnml2mrtgcsv.php.orig 2014-04-10 12:35:09.000000000 +0000 ++++ graphs/cnml2mrtgcsv.php 2014-04-10 12:35:19.000000000 +0000 +@@ -267,7 +267,7 @@ + // Opening CNML source + $cnml = new DOMDocument; + $cnml->preserveWhiteSpace = false; +-$cnml->Load('../data/guifi.cnml'); ++$cnml->Load('/var/tmp/snpservices/data/guifi.cnml'); + $time_s = microtime(true); + //print "# file guifi.cnml loaded".($time_s - $time_start)."\n"; + diff --git a/net-mgmt/guifi-snpservices/files/patch-graphs-mrtgcsv2mrtgcfg.php b/net-mgmt/guifi-snpservices/files/patch-graphs-mrtgcsv2mrtgcfg.php new file mode 100644 index 000000000000..a399bded50f7 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-graphs-mrtgcsv2mrtgcfg.php @@ -0,0 +1,24 @@ +--- graphs/mrtgcsv2mrtgcfg.php.orig 2014-02-21 15:53:13.000000000 +0000 ++++ graphs/mrtgcsv2mrtgcfg.php 2014-04-10 12:35:33.000000000 +0000 +@@ -1,9 +1,9 @@ + <?php + +-if (file_exists("../common/config.php")) { +- include_once("../common/config.php"); ++if (file_exists(dirname(__FILE__)."../common/config.php")) { ++ include_once(dirname(__FILE__)."../common/config.php"); + } else { +- include_once("../common/config.php.template"); ++ include_once(dirname(__FILE__)."/../common/config.php.template"); + } + + $now = time(); +@@ -57,7 +57,7 @@ + print date('Y/m/d H:i:s')."\n"; + + $hf = @fopen($MRTGConfigSource,"r") or die('Error reading MRTG csv input\n"'); +-$cf = @fopen('../data/mrtg.cfg','w+'); ++$cf = @fopen('/var/tmp/snpservices/data/mrtg.cfg','w+'); + + fputs($cf,sprintf($rrdtool_header,$rrdimg_path,$rrdimg_path,$rrddb_path,$rrddb_path)); + diff --git a/net-mgmt/guifi-snpservices/files/patch-index.php b/net-mgmt/guifi-snpservices/files/patch-index.php new file mode 100644 index 000000000000..8a7d01747c03 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/patch-index.php @@ -0,0 +1,17 @@ +--- ./index.php.orig 2012-05-11 16:46:51.000000000 -0500 ++++ ./index.php 2014-01-27 23:43:35.000000000 -0600 +@@ -5,6 +5,6 @@ + * Main call to CNML services + */ + + // Common Bootstrap + if (file_exists('common/config.php')) + include_once("common/config.php"); +@@ -91,6 +93,7 @@ + echo "Available services:\n"; + $fservices = glob('services/*.php'); + ++ $services = array(); + foreach ($fservices as $fservice) + $services[] .= basename($fservice,'.php'); + echo implode('|',$services); diff --git a/net-mgmt/guifi-snpservices/files/pkg-deinstall.in b/net-mgmt/guifi-snpservices/files/pkg-deinstall.in new file mode 100644 index 000000000000..cf15675b5631 --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/pkg-deinstall.in @@ -0,0 +1,2 @@ +#!/bin/sh +rm -rf %%SNPSERVICES_TMPDIR%% diff --git a/net-mgmt/guifi-snpservices/files/pkg-install.in b/net-mgmt/guifi-snpservices/files/pkg-install.in new file mode 100644 index 000000000000..67186d9c314e --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/pkg-install.in @@ -0,0 +1,26 @@ +#!/bin/sh +CHMOD="/bin/chmod" +MKDIR="/bin/mkdir -p" + +SNPSERVICES_TMPDIR=%%SNPSERVICES_TMPDIR%% + +case "$2" in + +POST-INSTALL) + if [ ! -d "${SNPSERVICES_TMPDIR}/images" ]; then + ${MKDIR} "${SNPSERVICES_TMPDIR}/images" + fi + if [ ! -d "${SNPSERVICES_TMPDIR}/logs" ]; then + ${MKDIR} "${SNPSERVICES_TMPDIR}/logs" + fi + if [ ! -d "${SNPSERVICES_TMPDIR}/data" ]; then + ${MKDIR} "${SNPSERVICES_TMPDIR}/data" + fi + if [ ! -d "${SNPSERVICES_TMPDIR}/tmp" ]; then + ${MKDIR} "$SNPSERVICES_TMPDIR" + ${MKDIR} "${SNPSERVICES_TMPDIR}/tmp" + ${CHMOD} -R a+rw ${SNPSERVICES_TMPDIR}/tmp + fi + ;; +esac +exit 0 diff --git a/net-mgmt/guifi-snpservices/files/pkg-message.in b/net-mgmt/guifi-snpservices/files/pkg-message.in new file mode 100644 index 000000000000..ececebcdce1d --- /dev/null +++ b/net-mgmt/guifi-snpservices/files/pkg-message.in @@ -0,0 +1,31 @@ + +POST-INSTALL CONFIGURATION FOR GUIFI SNPSERVICES +------------------------------------------------ + +1) Install and/or configure a webserver of your choice to serve + php files from %%WWWDIR%%/ (you also might have to + increase your webserver's upstream timeout for certain requests + +2) Edit %%WWWDIR%%/common/config.php.template and set + $SNPGraphServerId to your service's ID (note, it's the *service*, + NOT the "server" ID) + +3) setup a cronjob to keep your graphs and stats up to date; for + example: + +*/30 * * * * root if [ -x %%WWWDIR%%/graphs ]; then cd %%WWWDIR%%/graphs; fi; if [ -x %%PREFIX%%/bin/php ] && [ -r %%WWWDIR%%/graphs/mrtgcsv2mrtgcfg.php ]; then env LANG=C %%PREFIX%%/bin/php mrtgcsv2mrtgcfg.php >> /var/log/snpservices_mrtgcfg.log 2>&1; fi +*/5 * * * * root if [ -x %%PREFIX%%/bin/mrtg ] && [ -r /var/tmp/snpservices/data/mrtg.cfg ]; then env LANG=C %%PREFIX%%/bin/mrtg /var/tmp/snpservices/data/mrtg.cfg --lock-file /var/tmp/mrtg/lockfile_guifi >> /var/log/snpservices_mrtg.log 2>&1; fi + +4) consider logrotating /var/log/snpservices_*.log + +For more information, see various guifi.net doc pages, and related: + + http://es.wiki.guifi.net/wiki/Servidor_de_gr%C3%A1ficas + http://es.wiki.guifi.net/wiki/Servidor_de_gr%C3%A1ficas_1 + http://es.wiki.guifi.net/wiki/Servidor_de_gr%C3%A1ficas_2 + http://www3.uji.es/~vrubert/guifi_linux/graph.html#slide1 + http://es.wiki.guifi.net/wiki/Monitor + http://guifi.net/ca/node/9071 + +------------------------------------------------ + diff --git a/net-mgmt/guifi-snpservices/pkg-descr b/net-mgmt/guifi-snpservices/pkg-descr new file mode 100644 index 000000000000..b18af77adc92 --- /dev/null +++ b/net-mgmt/guifi-snpservices/pkg-descr @@ -0,0 +1,11 @@ +This is the guifi.net snpservices package. + +This software provides graph services in the context of the +Spontaneous Networklink Platform. + +Uses nodexchange/cnml as a input format, and provides traffic and +latency/availability graphs in image format by using mrtg/rrdtool +collected history by simple HTTP URLs, therefore is easily +plugable to any web application. + +WWW: http://es.wiki.guifi.net/wiki/SNPservices diff --git a/net-mgmt/guifi-snpservices/pkg-plist b/net-mgmt/guifi-snpservices/pkg-plist new file mode 100644 index 000000000000..f994d032ae0b --- /dev/null +++ b/net-mgmt/guifi-snpservices/pkg-plist @@ -0,0 +1,63 @@ +%%WWWDIR%%/README +%%WWWDIR%%/common/cnml2ov2.php +%%WWWDIR%%/common/config.php.template +%%WWWDIR%%/common/config.php.template.orig +%%WWWDIR%%/common/misc.php +%%WWWDIR%%/common/misc.php.orig +%%WWWDIR%%/common/mrtg.sh +%%WWWDIR%%/common/ping.sh +%%WWWDIR%%/common/ping.sh.orig +%%WWWDIR%%/common/qnodes.php +%%WWWDIR%%/common/qnodes.php.orig +%%WWWDIR%%/common/refresh.sh +%%WWWDIR%%/common/refresh_cnml.php +%%WWWDIR%%/common/refresh_cnml.php.orig +%%WWWDIR%%/common/refresh_mrtg.php +%%WWWDIR%%/common/refresh_mrtg.php.orig +%%WWWDIR%%/common/rrdtool.php +%%WWWDIR%%/debian/README.Debian +%%WWWDIR%%/debian/changelog +%%WWWDIR%%/debian/compat +%%WWWDIR%%/debian/control +%%WWWDIR%%/debian/copyright +%%WWWDIR%%/debian/cron.d +%%WWWDIR%%/debian/dirs +%%WWWDIR%%/debian/docs +%%WWWDIR%%/debian/rules +%%WWWDIR%%/debian/snpservices.1 +%%WWWDIR%%/debian/snpservices.config +%%WWWDIR%%/debian/snpservices.install +%%WWWDIR%%/debian/snpservices.logrotate +%%WWWDIR%%/debian/snpservices.manpages +%%WWWDIR%%/debian/snpservices.postinst +%%WWWDIR%%/debian/snpservices.postrm +%%WWWDIR%%/debian/snpservices.templates +%%WWWDIR%%/debian/watch.ex +%%WWWDIR%%/graphs/LICENSE.txt +%%WWWDIR%%/graphs/cnml2mrtgcsv.php +%%WWWDIR%%/graphs/cnml2mrtgcsv.php.orig +%%WWWDIR%%/graphs/config.php +%%WWWDIR%%/graphs/graphs.php +%%WWWDIR%%/graphs/mrtgcsv2mrtgcfg.php +%%WWWDIR%%/graphs/mrtgcsv2mrtgcfg.php.orig +%%WWWDIR%%/graphs/refresh.php +%%WWWDIR%%/index.php +%%WWWDIR%%/index.php.orig +%%WWWDIR%%/misc/xml2ov2.php +%%WWWDIR%%/services/availability.php +%%WWWDIR%%/services/example.php +%%WWWDIR%%/services/graph.php +%%WWWDIR%%/services/liveping.php +%%WWWDIR%%/services/livetraceroute.php +%%WWWDIR%%/services/stats.php +%%WWWDIR%%/tools/guinux/config.php.guinux +%%WWWDIR%%/tools/guinux/snpconfig.pl +%%WWWDIR%%/tools/guinux/snpservices.conf +@dirrmtry %%WWWDIR%%/tools/guinux +@dirrmtry %%WWWDIR%%/tools +@dirrmtry %%WWWDIR%%/services +@dirrmtry %%WWWDIR%%/misc +@dirrmtry %%WWWDIR%%/graphs +@dirrmtry %%WWWDIR%%/debian +@dirrmtry %%WWWDIR%%/common +@dirrmtry %%WWWDIR%% |