# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	./asterisk-stat
#	./asterisk-stat/files
#	./asterisk-stat/files/cdr_pgsql.tbl
#	./asterisk-stat/files/patch-export_pdf.php
#	./asterisk-stat/files/cdr_mysql.tbl
#	./asterisk-stat/files/mysql::patch-cdr.php
#	./asterisk-stat/files/pgsql::patch-cdr.php
#	./asterisk-stat/files/mysql::patch-defines.php
#	./asterisk-stat/files/pgsql::patch-defines.php
#	./asterisk-stat/Makefile
#	./asterisk-stat/distinfo
#	./asterisk-stat/pkg-descr
#	./asterisk-stat/pkg-message
#
echo c - ./asterisk-stat
mkdir -p ./asterisk-stat > /dev/null 2>&1
echo c - ./asterisk-stat/files
mkdir -p ./asterisk-stat/files > /dev/null 2>&1
echo x - ./asterisk-stat/files/cdr_pgsql.tbl
sed 's/^X//' >./asterisk-stat/files/cdr_pgsql.tbl << 'END-of-./asterisk-stat/files/cdr_pgsql.tbl'
X
XCREATE TABLE cdr (
X  calldate timestamp with time zone DEFAULT now() NOT NULL,
X  clid varchar(80) NOT NULL default '',
X  src varchar(80) NOT NULL default '',
X  dst varchar(80) NOT NULL default '',
X  dcontext varchar(80) NOT NULL default '',
X  channel varchar(80) NOT NULL default '',
X  dstchannel varchar(80) NOT NULL default '',
X  lastapp varchar(80) NOT NULL default '',
X  lastdata varchar(80) NOT NULL default '',
X  duration int(11) NOT NULL default '0',
X  billsec int(11) NOT NULL default '0',
X  disposition varchar(45) NOT NULL default '',
X  amaflags int(11) NOT NULL default '0',
X  accountcode varchar(20) NOT NULL default '',
X  uniqueid varchar(32) NOT NULL default '',
X  userfield varchar(255) NOT NULL default ''
X);
X
XCREATE INDEX calldate_ind ON cdr USING btree (calldate);
XCREATE INDEX dst_ind ON cdr USING btree (dst);
XCREATE INDEX accountcode_ind ON cdr USING btree (accountcode);
END-of-./asterisk-stat/files/cdr_pgsql.tbl
echo x - ./asterisk-stat/files/patch-export_pdf.php
sed 's/^X//' >./asterisk-stat/files/patch-export_pdf.php << 'END-of-./asterisk-stat/files/patch-export_pdf.php'
X--- export_pdf.php.orig	Thu Mar  3 00:11:32 2005
X+++ export_pdf.php	Thu Jul 20 23:50:45 2006
X@@ -2,7 +2,7 @@
X include_once(dirname(__FILE__) . "/lib/defines.php");
X include_once(dirname(__FILE__) . "/lib/Class.Table.php");
X define(FPDF_FONTPATH,dirname(__FILE__).'/lib/font/');
X-include_once(dirname(__FILE__) . "/lib/fpdf.php');
X+include_once(dirname(__FILE__) . "/lib/fpdf.php");
X 
X session_start();
X 
END-of-./asterisk-stat/files/patch-export_pdf.php
echo x - ./asterisk-stat/files/cdr_mysql.tbl
sed 's/^X//' >./asterisk-stat/files/cdr_mysql.tbl << 'END-of-./asterisk-stat/files/cdr_mysql.tbl'
XUSE asterisk;
X
XCREATE TABLE cdr (
X  calldate datetime NOT NULL default '0000-00-00 00:00:00',
X  clid varchar(80) NOT NULL default '',
X  src varchar(80) NOT NULL default '',
X  dst varchar(80) NOT NULL default '',
X  dcontext varchar(80) NOT NULL default '',
X  channel varchar(80) NOT NULL default '',
X  dstchannel varchar(80) NOT NULL default '',
X  lastapp varchar(80) NOT NULL default '',
X  lastdata varchar(80) NOT NULL default '',
X  duration int(11) NOT NULL default '0',
X  billsec int(11) NOT NULL default '0',
X  disposition varchar(45) NOT NULL default '',
X  amaflags int(11) NOT NULL default '0',
X  accountcode varchar(20) NOT NULL default '',
X  uniqueid varchar(32) NOT NULL default '',
X  userfield varchar(255) NOT NULL default ''
X);
X
XALTER TABLE `cdr` ADD INDEX ( `calldate` );
XALTER TABLE `cdr` ADD INDEX ( `dst` );
XALTER TABLE `cdr` ADD INDEX ( `accountcode` );
END-of-./asterisk-stat/files/cdr_mysql.tbl
echo x - ./asterisk-stat/files/mysql::patch-cdr.php
sed 's/^X//' >./asterisk-stat/files/mysql::patch-cdr.php << 'END-of-./asterisk-stat/files/mysql::patch-cdr.php'
X--- cdr.php.orig	Mon Mar  7 19:20:48 2005
X+++ cdr.php	Thu Jul 20 23:47:46 2006
X@@ -36,7 +36,7 @@
X 	<head>		
X 		<title>Asterisk CDR</title>
X 		<meta http-equiv="Content-Type" content="text/html">
X-		<link rel="stylesheet" type="text/css" media="print" href="/css/print.css">
X+		<link rel="stylesheet" type="text/css" media="print" href="css/print.css">
X 		<SCRIPT LANGUAGE="JavaScript" SRC="./encrypt.js"></SCRIPT>
X 		<style type="text/css" media="screen">
X 			@import url("css/layout.css");
END-of-./asterisk-stat/files/mysql::patch-cdr.php
echo x - ./asterisk-stat/files/pgsql::patch-cdr.php
sed 's/^X//' >./asterisk-stat/files/pgsql::patch-cdr.php << 'END-of-./asterisk-stat/files/pgsql::patch-cdr.php'
X--- cdr.php.orig	Mon Mar  7 19:20:48 2005
X+++ cdr.php	Thu Jul 20 23:47:46 2006
X@@ -36,7 +36,7 @@
X 	<head>		
X 		<title>Asterisk CDR</title>
X 		<meta http-equiv="Content-Type" content="text/html">
X-		<link rel="stylesheet" type="text/css" media="print" href="/css/print.css">
X+		<link rel="stylesheet" type="text/css" media="print" href="css/print.css">
X 		<SCRIPT LANGUAGE="JavaScript" SRC="./encrypt.js"></SCRIPT>
X 		<style type="text/css" media="screen">
X 			@import url("css/layout.css");
END-of-./asterisk-stat/files/pgsql::patch-cdr.php
echo x - ./asterisk-stat/files/mysql::patch-defines.php
sed 's/^X//' >./asterisk-stat/files/mysql::patch-defines.php << 'END-of-./asterisk-stat/files/mysql::patch-defines.php'
X--- lib/defines.php.orig	Tue Mar  8 04:07:23 2005
X+++ lib/defines.php	Thu Jul 20 21:51:35 2006
X@@ -1,7 +1,7 @@
X <?php
X 
X define ("WEBROOT", "http://domainname.com/asterisk-stat/");
X-define ("FSROOT", "/var/www/html/HTTP2/Asterisk/asterisk-stat-v2/");
X+define ("FSROOT", "/usr/local/www/asterisk-stat/");
X 
X 
X 
X@@ -9,11 +9,11 @@
X 
X 
X define ("HOST", "localhost");
X-define ("PORT", "5432");
X-define ("USER", "postgres");
X+define ("PORT", "3306");
X+define ("USER", "asterisk");
X define ("PASS", "");
X-define ("DBNAME", "cdrasterisk");
X-define ("DB_TYPE", "postgres"); // mysql or postgres
X+define ("DBNAME", "asterisk");
X+define ("DB_TYPE", "mysql"); // mysql or postgres
X 
X 
X define ("DB_TABLENAME", "cdr");
END-of-./asterisk-stat/files/mysql::patch-defines.php
echo x - ./asterisk-stat/files/pgsql::patch-defines.php
sed 's/^X//' >./asterisk-stat/files/pgsql::patch-defines.php << 'END-of-./asterisk-stat/files/pgsql::patch-defines.php'
X--- lib/defines.php.orig	Tue Mar  8 04:07:23 2005
X+++ lib/defines.php	Sat Jun 23 07:26:44 2007
X@@ -1,7 +1,7 @@
X <?php
X 
X define ("WEBROOT", "http://domainname.com/asterisk-stat/");
X-define ("FSROOT", "/var/www/html/HTTP2/Asterisk/asterisk-stat-v2/");
X+define ("FSROOT", "/usr/local/www/asterisk-stat/");
X 
X 
X 
X@@ -10,9 +10,9 @@
X 
X define ("HOST", "localhost");
X define ("PORT", "5432");
X-define ("USER", "postgres");
X+define ("USER", "asterisk");
X define ("PASS", "");
X-define ("DBNAME", "cdrasterisk");
X+define ("DBNAME", "asterisk");
X define ("DB_TYPE", "postgres"); // mysql or postgres
X 
X 
END-of-./asterisk-stat/files/pgsql::patch-defines.php
echo x - ./asterisk-stat/Makefile
sed 's/^X//' >./asterisk-stat/Makefile << 'END-of-./asterisk-stat/Makefile'
X# New ports collection makefile for:	www/asterisk-stat
X# Date created:				16 June 2007
X# Whom:	      				Fumihiko Kimura <jfkimura@yahoo.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	asterisk-stat
XPORTVERSION=	2.0.1
XPORTREVISION=	1
XCATEGORIES=	www
XMASTER_SITES=	http://www.areski.net/${SITE_SUBDIR}/
XDISTNAME=	${PORTNAME}-v${PORTVERSION:S/./_/g}
X
XMAINTAINER=	jfkimura@yahoo.com
XCOMMENT=	ASTERISK Call Detail Records Analizer
X
XLIB_DEPENDS=	gd.4:${PORTSDIR}/graphics/gd
X
XNO_BUILD=	yes
XUSE_PHP=	session gd pcre
X#USE_APACHE=	20+
XUSE_APACHE=	yes
XWANT_PHP_WEB=	yes
XASTERISKDIR?=	www/asterisk-stat
XSITE_SUBDIR=	asterisk-stat-v2
XWRKSRC=		${WRKDIR}/${SITE_SUBDIR}
X
XOPTIONS=	PGSQL "Use PostgreSQL instead of MySQL (not funtional)" off
X
X.include <bsd.port.pre.mk>
X
X.if defined(WITH_PGSQL)
XASTERISKSTATDB=	pgsql
X.else
XASTERISKSTATDB=	mysql
X# net/asterisk12-addons
X#RUN_DEPENDS=	${LOCALBASE}/lib/asterisk/modules/cdr_addon_mysql.so:${PORTSDIR}/net/asterisk12-addons
X# net/asterisk-addons
XRUN_DEPENDS=	${LOCALBASE}/lib/asterisk/modules/cdr_addon_mysql.so:${PORTSDIR}/net/asterisk-addons
X.endif
X
XUSE_PHP+=	${ASTERISKSTATDB}
X
Xpost-patch:
XEXTRA_PATCHES+=	${FILESDIR}/${ASTERISKSTATDB}::patch-cdr.php
XEXTRA_PATCHES+=	${FILESDIR}/${ASTERISKSTATDB}::patch-defines.php
X
Xpost-patch:
X	@${MV} ${WRKSRC}/images/print.css ${WRKSRC}/css
X	@${CP} ${WRKSRC}/images/spacer.gif ${WRKSRC}/images/clear.gif
X	@${CP} ${WRKSRC}/css/images/*png ${WRKSRC}/images
X	@${RM} ${WRKSRC}/about.php \
X		${WRKSRC}/lib/defines.php.orig \
X		${WRKSRC}/cdr.php.orig \
X		${WRKSRC}/export_pdf.php.orig
X
Xdo-install:
X	@${MKDIR} ${PREFIX}/${ASTERISKDIR}
X	@${MV} ${WRKSRC}/lib/defines.php ${WRKSRC}/lib/defines.php-dist
X	${CP} -r ${WRKSRC}/ ${PREFIX}/${ASTERISKDIR}
X	${CP} ${FILESDIR}/cdr_${ASTERISKSTATDB}.tbl ${PREFIX}/etc/asterisk
X	${CHOWN} -R ${WWWOWN}:${WWWGRP} ${PREFIX}/${ASTERISKDIR}
X
Xpost-install:
X	@${FIND} ${WRKSRC}/${file} -not -type d \
X		| ${SED} -ne 's,^${WRKSRC},${ASTERISKDIR},p' >> ${TMPPLIST}
X	@${FIND} -d ${WRKSRC}/${file} -type d \
X		| ${SED} -ne 's,^${WRKSRC},@dirrm ${ASTERISKDIR},p' >> ${TMPPLIST}
X	@${ECHO} etc/asterisk/cdr_${ASTERISKSTATDB}.tbl >> ${TMPPLIST}
X	@${CAT} ${PKGMESSAGE}
X
X.include <bsd.port.post.mk>
END-of-./asterisk-stat/Makefile
echo x - ./asterisk-stat/distinfo
sed 's/^X//' >./asterisk-stat/distinfo << 'END-of-./asterisk-stat/distinfo'
XMD5 (asterisk-stat-v2_0_1.tar.gz) = aad3fe2f9826e8d63dfc9bdea2315d4a
XSHA256 (asterisk-stat-v2_0_1.tar.gz) = a7c17742a4b84b2a90f278009a538d25a8c493a4333d9dd13cdd47ed308a19af
XSIZE (asterisk-stat-v2_0_1.tar.gz) = 390475
END-of-./asterisk-stat/distinfo
echo x - ./asterisk-stat/pkg-descr
sed 's/^X//' >./asterisk-stat/pkg-descr << 'END-of-./asterisk-stat/pkg-descr'
XAsterisk-Stat is providing different reports & Graph to allow 
Xthe Asterisk-admin to analyse quickly
Xand easily the traffic on their Asterisk server.
XAll the graphic & reports are based over the CDR database. 
X
XWWW: http://www.areski.net/asterisk-stat-v2/about.php
END-of-./asterisk-stat/pkg-descr
echo x - ./asterisk-stat/pkg-message
sed 's/^X//' >./asterisk-stat/pkg-message << 'END-of-./asterisk-stat/pkg-message'
X===>  asterisk-stat:
X
X		**** NOTE ****
X	Before the first use of Asterisk-stat, copy defines.php-dist to defines.php
X        in ${PREFIX}/${ASTERISKDIR}.
END-of-./asterisk-stat/pkg-message
exit

