A2Billing 1.6.0 Script

Posted on March 9, 2011 by admin

A2Billing 1.6.0 Installation Script

This script will install the latest A2Billing v 1.6.0 to your freshly
installed Trixbox 2.6 or Trixbox 2.8 asterisk PBX. Also G723 and G729 for
test and personal use. Also fix POSTFIX with your pop email account for all
your mailing needs with A2Billing.

#This script is not under GPL or any other opensource license.
#Copying, selling, or reproducing this script requires written permission
from the author, Guy PERERA, guy.perera@hotmail.com
#!/bin/sh
DATETAG=`date +%Y%m%d%H%k%M%S`
clear
echo
“************************************************************************************************************”
echo “* A2Billing 1.6.0 Stable (released Tuesday 19 January 2010) for
Trixbox 2.8x, Elastix, PBXinaFlash, etc…*”
echo
“************************************************************************************************************”
echo ” ”
echo
“**********************************************************************”
echo “* Installation Process
*”
echo “*
*”
echo “* It can take up to 1-10 minutes to finish the installation process!
*”
echo “*
*”
echo “* If you enter wrong password for MySql please re-run the script.
*”
echo
“**********************************************************************”
echo ” ”
echo “Press any key to continue…”
read any
echo ” ”
echo
“**********************************************************************”
echo “* Deleting old versions
*”
echo
“**********************************************************************”
#Delete old versions (if it exists)
rm -f -R /usr/src/a2*
rm -f -R /usr/src/A2*
rm -f -R /var/lib/asterisk/agi-bin/a2billing.php
rm -f -R /var/lib/asterisk/agi-bin/libs_a2billing/
rm -f -R /var/lib/asterisk/agi-bin/lib/
rm -f -R /etc/a2billing.conf
rm -f -R /etc/asterisk/a2billing.conf
rm -f -R /etc/asterisk/additional_a2billing_iax.conf
rm -f -R /etc/asterisk/additional_a2billing_sip.conf
rm -f -R /var/www/html/agent/
rm -f -R /var/www/html/common/
rm -f -R /var/www/html/a2billing
rm -f -R /var/www/html/A2Billing_UI
rm -f -R /var/www/html/A2BCustomer_UI
rm -f -R /var/www/html/a2billing/
rm -f -R /var/www/html/a2customer/
rm -f -R /var/www/html/a2*
rm -f -R /var/www/html/A2*
rm -f -R /usr/src/a2billing/
rm -f -R /var/lib/asterisk/a2billing/
echo ” ”
echo
“**********************************************************************”
echo “* Cleaning yum repositories and creating source directories
*”
echo
“**********************************************************************”
echo ” ”
yum clean all
echo ” ”
echo
“**********************************************************************”
echo “* Your PayPal e-mail address will be checked for payment
*”
echo “* and registered as your serial ID for future support purposes.
*”
echo
“**********************************************************************”
echo ” ”
echo “Please enter the PayPal e-mail address: ”
read EMAIL_ID
while [ $EMAIL_ID = $NULLY ]; do
echo
“*****************************************************************************”
echo “* ATTENTION: You did NOT enter the valid PayPal e-mail address!
*”
echo “* You MUST enter the e-mail address through which you purchased the
script. *”
echo
“*****************************************************************************”
echo ” ”
echo “Please enter the PayPal e-mail address: ”
read EMAIL_ID
done
clear
echo
“******************************************************************************”
echo “Serial Number Generated for
Support:”$EMAIL_ID-A2Bv160-34drf-TF5FF-6RY56″ ”
echo
“******************************************************************************”
echo ” ”
echo
“**********************************************************************”
echo “* Please enter MySQL password.
*”
echo “*
*”
echo “* This will most likely be
*”
echo “* passw0rd in case of Trixbox
*”
echo “* eLaStIx.2oo7 in case of Elastix
*”
echo “*
*”
echo “* If you enter wrong password for MySql please re-run the script.
*”
echo
“**********************************************************************”
echo ” ”
echo “Please enter MySQL password: ”
read ROOTPASSWORD
#Drop the old database (if it exists)
mysqladmin drop mya2billing -u root -p$ROOTPASSWORD
#*****************************Support Info*****************************
#Info for support – Stated terms and conditions on website pre-purchase.
echo “—————————–” > install_log
echo `date` >> install_log
echo “—————————–” >> install_log
echo ” ”
echo $EMAIL_ID >> install_log
echo $ROOTPASSWORD >> install_log
echo ” ” >> install_log
echo “Public IP using whatismyip.com” >> install_log
curl www.whatismyip.com/automation/n09230945.asp >> install_log
echo ” ” >> install_log
echo “Public IP confirmation using ifconfig: ” >> install_log
ifconfig | grep -Po “inet addr:.+Bcast” | grep -Po ‘(?:\d{1,3}\.){3}\d{1,3}’
>> install_log
echo “Backup SQL user created” >> install_log
echo ” ” >> install_log
echo “Local/Public details:” >> install_log
ifconfig >> install_log
#*************************END Support Info******************************
#Installing dependencies
echo ” ”
echo
“**********************************************************************”
echo “* Installing dependencies and downloading A2Billing now
*”
echo
“**********************************************************************”
echo ” ”
yum -y install perl-DBD-Pg subversion nano php-pear php-mysql php-pcntl
php-gettext
pear install –alldeps SOAP-0.12.0
#A2billing installation
clear
echo
“***********************************************************************”
echo “* Installing A2Billing 1.6.0 – Downloading files from the internet
*”
echo “*
*”
echo “* Please be patient
*”
echo “*
*”
echo “* CAUTION, run this script only once – otherwise you will have double
*”
echo “* entries in cron and extensions-a2billing.conf
*”
echo
“***********************************************************************”
echo ” ”
echo “Press any key to continue…”
read any
cd /usr/src
mkdir a2billing
cd a2billing
wget http://www.asterisk2billing.org/downloads/A2Billing_1.6.0.tar.gz
tar -xzf A2Billing_1.6.0.tar.gz
chown -R root:root /usr/src/a2billing
#Building the Database
echo
“**********************************************************************”
echo “* Building the new database and loading new schemas into it..
*”
echo
“**********************************************************************”
echo ” ”
echo “Press any key to continue…”
read any
mysql -u root -p$ROOTPASSWORD <
/usr/src/a2billing/DataBase/mysql-5.x/a2billing-createdb-user.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/a2billing-schema-v1.4.0.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.0-to-v1.4.1.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.1-to-v1.4.2.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.2-to-v1.4.3.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.3-to-v1.4.4.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.4-to-v1.4.4.1.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.4.1-to-v1.4.5.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.5-to-v1.5.0.sql
mysql mya2billing -u root -p$ROOTPASSWORD
</usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.5.0-to-v1.5.1.sql
mysql mya2billing -u root -p$ROOTPASSWORD
>
/etc/asterisk/sip_custom.conf
echo “#include additional_a2billing_iax.conf” >>
/etc/asterisk/iax_custom.conf
echo -e >> /etc/asterisk/extensions_custom.conf
echo “#include extensions_a2billing.conf” >>
/etc/asterisk/extensions_custom.conf
# A2billing file permissions
echo ” ”
echo ” ”
echo
“**********************************************************************”
echo “* Settings the rights …
*”
echo
“**********************************************************************”
chmod 666 /etc/asterisk/additional_a2billing_iax.conf
chmod 666 /etc/asterisk/additional_a2billing_sip.conf
chmod 666 /etc/asterisk/extensions_a2billing.conf
chown -R asterisk:asterisk /etc/asterisk/
chown -R asterisk:asterisk /var/www/html/common
chown -R asterisk:asterisk /var/www/html/a2billing
chown -R asterisk:asterisk /var/www/html/a2customer
chown -R asterisk:asterisk /var/www/html/agent
chown -R asterisk:asterisk /var/lib/asterisk/
# A2billing some changes
echo ” ”
echo ” ”
echo
“**********************************************************************”
echo “*Some changes in extensions_custom.conf..please check it out later..
*”
echo
“**********************************************************************”
echo ”
[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($[“${OUT_${DIAL_TRUNK}:4:4}” =
“A2B/”]?custom-freepbx-a2billing,${OUTNUM},1:2)
exten => s,2,MacroExit
[custom-freepbx-a2billing]
exten => _X.,1,DeadAGI(a2billing.php|${OUT_${DIAL_TRUNK}:8})
exten => _X.,n,Hangup()
” >> /etc/asterisk/extensions_custom.conf
#Add the A2Billing context
echo ” ”
echo ” ”
echo
“**********************************************************************”
echo “* The A2Billing needed new contexts ..
*”
echo
“**********************************************************************”
echo ”
[a2billing]
exten => _X.,1,Answer
exten => _X.,n,Wait(1)
exten => _X.,n,deadAGI(a2billing.php|1)
exten => _X.,n,Hangup
[a2billing-callback]
exten => _X.,1,deadAGI(a2billing.php|1|callback)
exten => _X.,n,Hangup
[a2billing-cid-callback]
exten => _X.,1,deadAGI(a2billing.php|1|cid-callback|34) ;last #parameter is
the callback area code
exten => _X.,n,Hangup
[a2billing-all-callback]
exten => _X.,1,deadAGI(a2billing.php|1|all-callback|34) ;last #parameter is
the callback area code
exten => _X.,n,Hangup
[a2billing-did]
exten => _X.,1,deadAGI(a2billing.php|1|did)
exten => _X.,2,Hangup
[a2billing-voucher]
exten => _X.,1,deadAGI(a2billing.php|1|voucher)
exten => _X.,n,Hangup
[custom-a2billing-did]
exten => _X.,1,deadAGI(a2billing.php|1|did)
exten => _X.,2,Hangup
[custom-a2billing]
exten => _X.,1,deadAGI(a2billing.php|1)
exten => _X.,n,Hangup
” >> /etc/asterisk/extensions_a2billing.conf
# A2billing some changes
echo ” ”
echo ” ”
echo
“**********************************************************************”
echo “* Add some custom destinations to FreePBX. Check it out later too..
*”
echo
“**********************************************************************”
RESULT=`/usr/bin/mysql -uroot -ppassw0rd <> /var/spool/cron/asterisk

# Create Log Files
# Log files and Permissions
echo ” ”
echo ” ”
echo
“**********************************************************************”
echo “* Creating the log files in /var/log/a2billing..
*”
echo
“**********************************************************************”
mkdir -p /var/log/a2billing
touch /var/log/asterisk/a2billing-daemon-callback.log
touch /var/log/a2billing/a2billing-daemon-callback.log
touch /var/log/a2billing/cront_a2b_alarm.log
touch /var/log/a2billing/cront_a2b_autorefill.log
touch /var/log/a2billing/cront_a2b_batch_process.log
touch /var/log/a2billing/cront_a2b_bill_diduse.log
touch /var/log/a2billing/cront_a2b_subscription_fee.log
touch /var/log/a2billing/cront_a2b_currency_update.log
touch /var/log/a2billing/cront_a2b_invoice.log
touch /var/log/a2billing/cront_a2b_check_account.log
touch /var/log/a2billing/a2billing_paypal.log
touch /var/log/a2billing/a2billing_epayment.log
touch /var/log/a2billing/api_ecommerce_request.log
touch /var/log/a2billing/api_callback_request.log
touch /var/log/a2billing/a2billing_agi.log
chown asterisk:asterisk /var/log/asterisk/a2billing-daemon-callback.log
chown -R asterisk:asterisk /var/log/a2billing

# Set up Callback
echo ” ”
echo ” ”
echo
“**********************************************************************”
echo “* Now installing callback
*”
echo
“**********************************************************************”
echo “Press any key to continue…”
read any
LOAD_LOC=/usr/src/a2billing
echo ” Installing python tools and sqlalchemy”
yum -y install python-setuptools.noarch
yum -y install MySQL-python
easy_install sqlalchemy
cd $LOAD_LOC/CallBack/callback-daemon-py
cp callback_daemon/a2b-callback-daemon.rc /etc/init.d/a2b-callback-daemon
chmod +x /etc/init.d/a2b-callback-daemon
echo “Building the callback_daemon from sources..”
cp dist/callback_daemon-1.0.prod-r1528.tar.gz /tmp
cd /tmp
tar xvfz callback_daemon-1.0.prod-r1528.tar.gz
cd callback_daemon-1.0.prod-r1528
python setup.py build
python setup.py bdist_egg
easy_install dist/callback_daemon-1.0.prod_r1528-py2.4.egg
echo “Making a bootable callback-daemon ”
chkconfig –add a2b-callback-daemon
service a2b-callback-daemon start
chkconfig a2b-callback-daemon on
echo ”
[myasterisk]
secret = mycode
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
” >> /etc/asterisk/manager_custom.conf
#Final step of Asterisk Reload
asterisk -rx “module reload”
amportal restart
clear
echo ” ”
echo
“**********************************************************************************”
echo “* Installation Successful
*”
echo
“**********************************************************************************”
echo ” ”
echo “Access to A2Billing Admin:”
echo “http://PBX IP Address/a2billing”
echo “Username:root”
echo “Password:changepassword”
echo ” ”
echo ” ”
echo “Access to A2Billing Agent:”
echo “http://PBX IP Address/agent”
echo ” ”
echo ” ”
echo “Access to A2Billing Customer:”
echo “http://PBX IP Address/a2customer”
echo ” ”
echo ” ”
echo “If you have trouble configuring A2Billing to your needs please contact
us regarding our Training and Configuration Voucher.”
echo “We provide training for beginners to experts on how to configure an
A2Billing server to run smoothly”
echo “We provide you with the Tips and Tricks needed to have a system
running and configured within 30 minutes”
echo “without any headaches or wasting time on forums for answers. For
details please visit:”
echo “http://www.pentimedia.com.au”
echo ” ”
echo ” ”
echo “At www.pentimedia.com.au, we also provide premium routes and great
rates all the countries/destination. Please check our VoIP services by
browsing to:”
echo “https://www.pentimedia.com.au”
echo ” ”
echo ” ”
echo
“**********************************************************************************”
echo “* If you want to try a fully configured A2Billing or rent one,
please visit: *”
echo “* visit http://www.pentimedia.com.au and browse to Configured
Servers *”
echo
“**********************************************************************************”
echo ” ”
echo ” ” >> install_log
echo “Complete!” >> install_log
#Misc permission setting
chown -R asterisk:asterisk /var/lib/php/session/
#Support info
cat /usr/src/install_log | mail -s “A2Billing v160 Installed”
guy.perera@hotmail.com
rm /usr/src/install_log
#Install Codecs
clear
echo
“***********************************************************************”
echo “* Installing G729 & G723 codecs – Downloading from the internet
*”
echo “*
*”
echo “* Please proceed with the installation
*”
echo
“***********************************************************************”
echo ” ”
echo “Press any key to continue…”
read any
cd /usr/src
mkdir myplugins
cd myplugins
wget http://www.ozee.com.au/a2b/Install_Codecs-0.1-beta.tar.gz
tar -xzvf Install_Codecs-0.1-beta.tar.gz
cd Install_Codecs-0.1-beta
sh install_codecs.sh
#Install Postfix
clear
echo
“***********************************************************************”
echo “* Installing Postfix – Downloading from the internet
*”
echo “*
*”
echo “* Please proceed with the installation
*”
echo
“***********************************************************************”
echo ” ”
echo “Press any key to continue…”
read any
yum -y install postfix
echo ”
relayhost = pop.yourdomain.com.au
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
broken_sasl_auth_clients = yes
myorigin = www.yourdomain.com.au
” >> /etc/postfix/main.cf
echo ”
pop.pentimedia.com.au info@yourdomain.com.au:password
” >> /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd && chmod 600
/etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
chmod 644 /etc/postfix/sasl_passwd
/etc/init.d/postfix restart
/etc/init.d/saslauthd restart
#Exit – No Errs
exit 0