Forum Asterisk
Welcome Guest   [Register]  Autenticação
 Subject :Script instalar o A2Billing em português.. 2011-07-26 13:13:24 
gouveia
Joined: 2008-11-16 13:40:47
Posts: 45
Location: Vila Nova de Gaia, Portugal
 

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, o
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# GNU Affero General Public License for more details.

# along with this program. If not, see <http://www.gnu.org/licenses/>.


clear
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~"
echo "PERIGO PERIGO PERIGO PERIGO PERIGO PERIGO PERIGO PERIGO PERIGO PERIGO PERIGO"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~"
echo "Este script assume que não mudou o nome de utilizaodor root padrao para o MySQL"
echo "Se voce alterou a sua password, pressione CTRL-C para sair"
echo "Em seguida, altere a password de root do MySQL no script para se adequar a esta instalação."
echo " "
echo "Se uma cópia anterior do A2Billing já esttiver instalada, então deve desinstalar antes"
echo "Este script ira modifica-lo, ou modifique a sua instalação antes de executa-lo."
echo "+++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ ++++++++++++++++++++"
read -p "Pressione enter para continuar ou ctrl-C para sair"

#Change passw0rd below for your MySQL root password if you have changed it from the default.
MYSQLROOTPASSWORD=password


echo "***************************** ****************************** **"
echo "Instalar A2Billing - Download de ficheiros pela Internet"
echo ""
echo " Por Favor, seja paciente"
echo ""
echo "CUIDADO, execute este script uma unica vez - caso contrario voce tera"
echo "entradas duplas na cron e extensoes-a2billing.conf"
echo "***************************** ****************************** **"

mkdir /usr/src/a2billing
mkdir /var/www/html/a2billing

wget http://www.asterisk2billing.org/down...g_1.4.1.tar.gz

cd /usr/src/a2billing/DataBase/mysql-5.x/

echo "GRANT ALL PRIVILEGES ON *.* TO 'a2billinguser'@'localhost' IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | mysql -p$MYSQLROOTPASSWORD


echo ""
echo "Instalar Banco de Dados A2Billing"
echo "Answer the questions appropriately with reference to /etc/a2billing.conf"
echo "-----------------------------"
echo ""

echo "Digite abaixo o nome do banco de dados que esta dentro do parentese (mya2billing):"
read dbname

echo "Digite o nome do Hostname de seu servidor, ou coloque (localhost):"
read hostname

echo "Digite o nome do utilizador do Banco de Dados (a2billinguser):"
read username

echo "Digite a password de utilizador do Banco de Dados (a2billing):"
read password

echo mysql --user=$username --password=$password --host=$hostname $dbname

cat a2billing-schema-v1.4.0.sql UPDATE-a2billing-v1.4.0-to-v1.4.1.sql | mysql --user=$username --password=$password --host=$hostname $dbname

# cat a2billing-mysql-schema-v1.3.0.sql UPDATE-a2billing-v1.3.0-to-v1.3.1.sql UPDATE-a2billing-v1.3.3-to-v1.3.4.sql UPDATE-a2billing-v1.3.4-to-v1.4.0.sql a2billing-prefix-table-v1.4.0.sql UPDATE-a2billing-v1.4.0-to-v1.4.1.sql | mysql --user=$username --password=$password --host=$hostname $dbname

#Install some dependencies
yum -y install perl-DBD-Pg

cd /usr/src/a2billing

mv AGI/a2billing.php /var/lib/asterisk/agi-bin/.
cp -r common/lib /var/lib/asterisk/agi-bin

mv ./admin/ /var/www/html/a2billing/admin
mv ./customer/ /var/www/html/a2billing/customer
mv ./agent/ /var/www/html/a2billing/agent
mv ./common/ /var/www/html/a2billing/common
mv ./Cronjobs/ /var/lib/asterisk/agi-bin/lib/Cronjobs
mv a2billing.conf /etc/a2billing.conf


#Set up sounds
cd /usr/src/a2billing/addons/sounds


#Use this line for RPM based systems as Fedora, CentOS, etc
ast_sound=/var/lib/asterisk/sounds

#Use this line for Debian based systems
#ast_sound=/usr/share/asterisk/sounds

lang=en
echo
echo Instalar ficheiros de audio do A2Billing : "$lang"
echo --------------------------------------------------
echo creating relevant folders : $ast_sound/$lang
echo creating relevant folders : $ast_sound/$lang/digits

mkdir $ast_sound/$lang
mkdir $ast_sound/$lang/digits
echo Copy $lang files in the right folder ...

cp ./$lang/* $ast_sound/$lang/
cp ./global/* $ast_sound/$lang/


lang=es
echo
echo Instalar ficheiros de audio do A2Billing : "$lang"
echo ---------------------------------------------------
echo creating relevant folders : $ast_sound/$lang
echo creating relevant folders : $ast_sound/$lang/digits

mkdir $ast_sound/$lang
mkdir $ast_sound/$lang/digits
echo Copy $lang files in the right folder ...

cp ./$lang/* $ast_sound/$lang/
cp ./global/* $ast_sound/$lang/


lang=fr
echo
echo Instalar ficheiros de audio do A2Billing : "$lang"
echo ---------------------------------------------------
echo creating relevant folders : $ast_sound/$lang
echo creating relevant folders : $ast_sound/$lang/digits

mkdir $ast_sound/$lang
mkdir $ast_sound/$lang/digits
echo Copy $lang files in the right folder ..

cp ./$lang/* $ast_sound/$lang/
cp ./global/* $ast_sound/$lang/

lang=br
echo
echo Instalar ficheiros de audio do A2Billing : "$lang"
echo ---------------------------------------------------
echo creating relevant folders : $ast_sound/$lang
echo creating relevant folders : $ast_sound/$lang/digits

mkdir $ast_sound/$lang
mkdir $ast_sound/$lang/digits
echo Copy $lang files in the right folder ...

cp ./$lang/* $ast_sound/$lang/
cp ./global/* $ast_sound/$lang/

lang=ru
echo
echo Instalar ficheiros de audio do A2Billing : "$lang"
echo ---------------------------------------------------
echo creating relevant folders : $ast_sound/$lang
echo creating relevant folders : $ast_sound/$lang/digits

mkdir $ast_sound/$lang
mkdir $ast_sound/$lang/digits
echo Copy $lang files in the right folder ...

cp ./$lang/* $ast_sound/$lang/
echo Copy $lang digits files in the right folder ...
cp ./$lang/digits/* $ast_sound/$lang/digits/

cd /etc/asterisk/
touch additional_a2billing_iax.conf
touch additional_a2billing_sip.conf
touch extensions_a2billing.conf
touch iax_custom.conf

#set ownership and permissions

chown -R asterisk:asterisk /var/www/html
chown -R asterisk:asterisk /etc/asterisk
chown -R asterisk:asterisk /var/lib/asterisk/
chown -R asterisk:asterisk /var/www/html/a2billing/
chown -R asterisk:asterisk /var/lib/asterisk/sounds/
chown asterisk:asterisk /var/lib/asterisk/agi-bin/a2billing.php
chmod +x /var/lib/asterisk/agi-bin/a2billing.php


chmod 666 /etc/asterisk/additional_a2billing_iax.conf
chmod 666 /etc/asterisk/additional_a2billing_sip.conf
chmod 666 /etc/asterisk/extensions_a2billing.conf
chmod 666 /etc/a2billing.conf

#Fix the permissions of the templates_c folder in each of the UI

chmod 755 /var/www/html/a2billing/admin/templates_c
chmod 755 /var/www/html/a2billing/customer/templates_c
chmod 755 /var/www/html/a2billing/agent/templates_c
chown -R asterisk:asterisk /var/www/html/a2billing/admin/templates_c
chown -R asterisk:asterisk /var/www/html/a2billing/customer/templates_c
chown -R asterisk:asterisk /var/www/html/a2billing/agent/templates_c


#ensure all log files exist so we can set their permissions accordingly
touch /var/log/asterisk/a2billing-daemon-callback.log
touch /var/log/a2billing-daemon-callback.log
touch /var/log/cront_a2b_alarm.log
touch /var/log/cront_a2b_autorefill.log
touch /var/log/cront_a2b_batch_process.log
touch /var/log/cront_a2b_bill_diduse.log
touch /var/log/cront_a2b_subscription_fee.log
touch /var/log/cront_a2b_currency_update.log
touch /var/log/cront_a2b_invoice.log
touch /var/log/cront_a2b_check_account.log
touch /var/log/a2billing_paypal.log
touch /var/log/a2billing_epayment.log
touch /var/log/api_ecommerce_request.log
touch /var/log/api_callback_request.log
touch /var/log/a2billing_agi.log


echo "
#include additional_a2billing_sip.conf
" >> /etc/asterisk/sip_custom.conf
echo "
#include additional_a2billing_iax.conf
" >> /etc/asterisk/iax_custom.conf
echo "
#include extensions_a2billing.conf
" >> /etc/asterisk/extensions_custom.conf

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

#Create manager_custom.conf
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,comman d,agent,user
write = system,call,log,verbose,comman d,agent,user
" >> /etc/asterisk/manager_custom.conf
#Adicionar entrada de contexto para uso do A2Billing

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

#Add some custom destinations to FreePBX
RESULT=`/usr/bin/mysql -uroot -p$MYSQLROOTPASSWORD <<SQL

use asterisk
INSERT INTO custom_destinations
(custom_dest, description, notes)
VALUES ('custom-a2billing,${EXTEN},1', 'A2Billing', '');
INSERT INTO custom_destinations
(custom_dest, description, notes)
VALUES ('custom-a2billing-did,${EXTEN},1', 'A2Billing-DID', '');
quit
SQL`


#set up crontabs for currency updates invoices and billing.
echo '0 1 * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/currencies_update_yahoo.php
0 6 1 * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_subscription_fee.php
0 12 * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_archive_data_cront.p hp
1 * * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_notify_account.php
0 6 * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_check_account.php
0 0 * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_bill_diduse.php
20 0 * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_batch_process.php
0 10 21 * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_autorefill.php
0 7 * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_invoice_cront.php
*/5 * * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_batch_autodialer.php
0 * * * * php /var/lib/asterisk/agi-bin/lib/Cronjobs/a2billing_alarm.php
' >> /var/spool/cron/asterisk

#Not required for PIAF, port already open
#Create fw rule to allow paypal to work
#iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

#save them
#service iptables save


#Set up callback
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~"
echo "Now Installing Callback"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~"

echo "Pressione enter para continuar"
read any

LOAD_LOC=/usr/src/a2billing


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

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

chkconfig --add a2b-callback-daemon
service a2b-callback-daemon start
chkconfig a2b-callback-daemon on


echo ""
echo ""
echo ""
echo ""
echo ""
echo "***************************** ****************************** ********"
echo "A2Billing Instalado com Sucesso"
echo "-------------------------------------------------"
echo ""
echo "Por Favor agora Reboot no seu Servidor"
echo ""
echo "***************************** ****************************** ********"
echo ""
echo "Utilizador padrao admin : root"
echo "A password padrao de root no admin :changepassword"
echo "Não se esqueça de configurar /etc/a2billing.conf"
echo "***************************** ****************************** ********"

IP Logged
Anderson Gouveia
Asterisk Portugal Community Manager
http://www.asteirk.pt
Elastix in the Web / Elastix en la web
http://twitter.com/asterisk_pt
http://identi.ca/asteriskportugal
Página # 


Powered by ccBoard