
====================================================================
			A2Billing : QUICK INSTALLATION GUIDE FOR AGI
====================================================================



1. Edit common/lib/Class.A2Billing.php and set AST_CONFIG_DIR 
	
	mkdir /usr/local/a2billing
	cp * /usr/local/a2billing/
	ls /usr/local/a2billing/
	you might see this :
	*	a2billing.conf    admin    AGI    CallBack   common    customer  LICENSE	 addons    agent  CHANGELOG  Cronjobs  DataBase  

   Link the agi for asterisk in your agi-bin directory.
	 ln -s /usr/local/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/a2billing.php


2. Make sure the script is runnable 
     chmod +x a2billing.php


4. Copy the sounds files
	cp -r addons/sounds/en/* /var/lib/asterisk/sounds/.

	 	 
5. Create a Database use  a2billing-pgsql-schema.psql for postgres


6. Setup your Database into the application

	cp a2billing.conf /etc/asterisk/a2billing.conf
	
	vim /etc/asterisk/a2billing.conf
	
	see section [database]
	
    * hostname : This is the Database host name (ie: localhost)
    
    * port: Database port (ie: 5432)
    
    * user: Username to access to the database (ie: username)
    
    * password: Database password of the user (ie: mypassword)
    
    * dbname: Name of the Database (ie: a2billing)
    
    * dbtype: Database type, support postgres or mysql (ie: mysql)

		

7. Connect calls from Asterisk to A2Billing
	
	copy extensions_a2billing.conf into /etc/astersik
	
	Edit extensions.conf (/etc/asterisk/extensions.conf)
	Add the following include :
	
	#include extensions_a2billing.conf
	
	( or if you use Asterisk 1.6 )
	
	#include extensions_a2billing_1_6.conf
	
	
	Call is connected using DeadAgi(a2billing.php|1)
	when calling the a2billing script different parameters can be use
	DeadAgi(a2billing.php|%AGI_CONF%|%MODE%|%AREA_CODE%|%GROUP_ID_AUTOCREATION%|%$CID_ALEG_TARIFF_ID%)
	
	a parameter can be left empty, so a call as
	DeadAgi(a2billing.php|1|||3)
	This will define the GROUP_ID_AUTOCREATION to 3
	
	DeadAgi(a2billing.php|1|cid-callback|||4)
	
	This will define the CID_ALEG_TARIFF_ID to 4
	
	
	With Asterisk 1.6, replace all of the pipes "|" with commas ","


8. Edit sip.conf and add :
	
	#include additional_a2billing_sip.conf 
	
	This is to include the sip friends


9. Edit iax.conf and add :
	
	#include additional_a2billing_iax.conf 
	
	This is to include the iax friends


10. Set the rigth permissions ( apache in debian is www-data ).

	chown -R asterisk:apache /etc/asterisk
	chmod -R 774 /etc/asterisk


11. Configure the Asterisk manager...

	[general]
	enabled = yes
	port = 5038
	bindaddr = 127.0.0.1 


	Add an entry to allow a manager connection, like
	
	[myasterisk]
	secret = mycode						
	read = system,call,log,verbose,command,agent,user
	write = system,call,log,verbose,command,agent,user 


12. RELOAD ASTERISK



