A2billing Install
A2billing Install
A2billing Install
/bin/sh
DATETAG=`date +%Y%m%d%H%k%M%S`
echo "This is the PIAF A2Billing 1.7.1 setup/update script. YOU NEED TO HAVE AST
ERISK 1.6 FOR
THIS SCRIPT. "
echo ""
# Step1: Removing A2billing Old files
rm -f -R /var/www/html/a2billing/
rm -f -R /var/www/html/a2customer/
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/asterisk/additional_a2billing_iax.conf
rm -f -R /etc/asterisk/additional_a2billing_sip.conf
rm -f /etc/asterisk/a2billing.conf
rm -f /etc/a2billing.conf
rm -f -R /var/www/html/agent/
rm -f -R /var/www/html/common/
rm -f -R /usr/src/a2billing/
# Drop the old database (if it exists)
mysqladmin drop mya2billing -u root -ppassw0rd
echo "*************************************************************"
echo " Installing A2Billing 1.7.1 - Downloading files from the internet"
echo ""
echo " Please be patient"
echo ""
echo "CAUTION, run this script only once - otherwise you will have"
echo "double entries in cron and extensions-a2billing.conf"
echo "*************************************************************"
# Step2: A2billing installation
echo " Creating work spaces.."
cd /usr/src
mkdir a2billing
cd a2billing
wget http://www.asterisk2billing.org/downloads/A2Billing_1.7.1.tar.gz
tar -xzf A2Billing_1.7.1.tar.gz
chown -R root:root /usr/src/a2billing
echo " Building the new database and loading new schemas into it.."
mysql -u root -ppassw0rd </usr/src/a2billing/DataBase/mysql-5.x/a2billing-create
db-user.sql
mysql mya2billing -u root -ppassw0rd </usr/src/a2billing/DataBase/mysql-5.x/a2bi
lling-mysql-schema-v1.7.0.sql
mysql mya2billing -u root -ppassw0rd </usr/src/a2billing/DataBase/mysql-5.x/UPDA
TE-a2billing-v1.7.0-to-v1.7.1.sql
cp /usr/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/
cp -rf /usr/src/a2billing/common/lib /var/lib/asterisk/agi-bin/
chmod +x /var/lib/asterisk/agi-bin/a2billing.php
chown -R asterisk:asterisk /var/lib/asterisk/agi-bin
# Step4: A2billing configuration files
cp /usr/src/a2billing/a2billing.conf /etc/asterisk
chown asterisk:asterisk /etc/asterisk/a2billing.conf
ln -sf /etc/asterisk/a2billing.conf /etc/a2billing.conf
echo "Building the new a2billing.conf.."
sed -i "s/\(port *= *\)\(.*\)/\13306/" /etc/asterisk/a2billing.conf
sed -i "s/\(user *= *\)\(.*\)/\1a2billinguser/" /etc/asterisk/a2billing.conf
sed -i "s/\(password *= *\)\(.*\)/\1a2billing/" /etc/asterisk/a2billing.conf
sed -i "s/\(dbname *= *\)\(.*\)/\1mya2billing/" /etc/asterisk/a2billing.conf
echo "Building some Music On Hold mp3 directories and setting privileges.."
mkdir -p /var/lib/asterisk/mohmp3/acc_1
mkdir -p /var/lib/asterisk/mohmp3/acc_2
mkdir -p /var/lib/asterisk/mohmp3/acc_3
mkdir -p /var/lib/asterisk/mohmp3/acc_4
mkdir -p /var/lib/asterisk/mohmp3/acc_5
mkdir -p /var/lib/asterisk/mohmp3/acc_6
mkdir -p /var/lib/asterisk/mohmp3/acc_7
mkdir -p /var/lib/asterisk/mohmp3/acc_8
mkdir -p /var/lib/asterisk/mohmp3/acc_9
mkdir -p /var/lib/asterisk/mohmp3/acc_10
chmod 777 /var/lib/asterisk/mohmp3/acc_*
chown -R asterisk:asterisk /var/lib/asterisk/mohmp3/
echo "Installing extra sounds..."
# A2billing Extra sounds
cd /usr/src/a2billing/addons/sounds
./install_a2b_sounds.sh
echo "Creating additionals_a2billing files.."
# Step6: Asterisk files
cd /etc/asterisk/
touch additional_a2billing_iax.conf
touch additional_a2billing_sip.conf
touch extensions_a2billing.conf
echo "#include additional_a2billing_sip.conf" >> /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.con
f
echo "Settings the rights ..."
# Step7: A2billing file permissions
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/
echo "Some changes in extensions_custom.conf..please check it out later.."
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
echo "Add some custom destinations to FreePBX. Check it out later too.."
RESULT=`/usr/bin/mysql -u root -ppassw0rd <<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 Callback
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~"
echo "Now installing callback"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~"
echo "Press any key to continue (presione cualquier tecla para continuar)"
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