A2Billing 1.6.0 Stable install script for Elastix

Discussion in 'General' started by saleh, Feb 19, 2010.

  1. saleh

    Joined:
    Apr 18, 2007
    Messages:
    249
    Likes Received:
    0
    Here is my script to install A2Billing 1.6.0 in Elastix, this script can help you to quick install the latest A2Billing version in your Elastix System.

    script name: a2billing-1.6.0.sh


    #!/bin/sh

    echo "This is the Elastix A2Billing setup 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 -peLaStIx.2oo7


    # Step2: A2billing installation
    cd /usr/src
    mkdir a2billing
    cd a2billing
    wget http://www.asterisk2billing.org/downloa ... 6.0.tar.gz
    tar -xzf A2Billing_1.6.0.tar.gz
    chown -R root:root /usr/src/a2billing


    mysql -u root -peLaStIx.2oo7 < /usr/src/a2billing/DataBase/mysql-5.x/a2billing-createdb-user.sql
    mysql mya2billing -u root -peLaStIx.2oo7 < /usr/src/a2billing/DataBase/mysql-5.x/a2billing-schema-v1.4.0.sql

    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.0-to-v1.4.1.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.1-to-v1.4.2.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.2-to-v1.4.3.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.3-to-v1.4.4.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.4-to-v1.4.4.1.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.4.1-to-v1.4.5.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.4.5-to-v1.5.0.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.5.0-to-v1.5.1.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.5.1-to-v1.6.0.sql

    # Step3: A2billing web interfaces installation
    cp -rf /usr/src/a2billing/customer /var/www/html/a2customer
    chmod 777 /var/www/html/a2customer/templates_c
    cp -rf /usr/src/a2billing/agent /var/www/html
    chmod 777 /var/www/html/agent/templates_c
    cp -rf /usr/src/a2billing/admin /var/www/html/a2billing
    chmod 777 /var/www/html/a2billing/templates_c
    cp -Rf /usr/src/a2billing/common /var/www/html

    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

    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


    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/

    # A2billing Extra sounds
    cd /usr/src/a2billing/addons/sounds
    ./install_a2b_sounds.sh

    # 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.conf

    # 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/


    # Cronjobs

    echo "
    # Automatically added for A2Billing
    0 * * * * php /usr/src/a2billing/Cronjobs/a2billing_alarm.php
    0 12 * * * php /usr/src/a2billing/Cronjobs/a2billing_archive_data_cront.php
    0 10 21 * * php /usr/src/a2billing/Cronjobs/a2billing_autorefill.php
    #Batch process at 00:20 each day
    20 0 * * * php /usr/src/a2billing/Cronjobs/a2billing_batch_process.php
    #Bill DID usage at 00:00 each day
    0 0 * * * php /usr/src/a2billing/Cronjobs/a2billing_bill_diduse.php
    #Remind users of low balance every day at 06:00
    0 6 * * * php /usr/src/a2billing/Cronjobs/a2billing_check_account.php
    #Generate Invoices at 7am everyday
    #0 7 * * * php /usr/src/a2billing/Cronjobs/a2billing_invoice2_cront.php
    #0 7 * * * php /usr/src/a2billing/Cronjobs/a2billing_invoice_cront.php
    #Check if balance below preset value, and email user if so.
    1 * * * * php /usr/src/a2billing/Cronjobs/a2billing_notify_account.php
    #Charge subscriptions at 06:05 on the 1st of each month
    0 6 1 * * php /usr/src/a2billing/Cronjobs/a2billing_subscription_fee.php
    #Update currencies at 01:00 each day
    0 1 * * * php /usr/src/a2billing/Cronjobs/currencies_update_yahoo.php
    " >> /var/spool/cron/asterisk

    # Create Log Files
    # Log files and Permissions

    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

    Best Regards,

    Saleh
     
  2. tylerd

    Joined:
    Jul 14, 2007
    Messages:
    33
    Likes Received:
    0
    Thanks! I've been working on it; first trying to install the 1.5 version, and suddenly the 1.6 come out the light the 16th of this February! :) One question, Saleh: What about the callback daemon? i dont see that funcionality in your script (only in the last part of the script is mentioned..)Dont you consider this necessary?

    Regards,

    Ivanof M.G.
    Inteliredes Colombia
    www.inteliredes.com
     
  3. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    The scritp seems work well but at the login, I've this: (with php debug)

    Code:
    Warning: mysqli_real_connect() [function.mysqli-real-connect]: (28000/1045): Access denied for user 'a2billing_dbuser'@'localhost' (using password: YES) in /var/www/html/common/lib/adodb/drivers/adodb-mysqli.inc.php on line 109
    Connection failed

    Now I can't use A2b. :huh:

    Regards
     
  4. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Good Morning Franck.


    Don't know yet (I was going to try it tomorrow)

    but maybe

    sed -i "s/(port *= *)(.*)/13306/" /etc/asterisk/a2billing.conf

    is a perhaps a typo saleh?

    sed -i "s/(port *= *)(.*)/3306/" /etc/asterisk/a2billing.conf

    perchance?


    dicko
     
  5. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    If Y look at the config and the data base, there's some difference:
    /etc/asterisk/a2billing.conf

    [database]
    hostname = localhost
    ; port for postgres is 5432 by default
    port =
    user = a2billing_dbuser
    password = a2billing_dbpassword

    dbname = a2billing_dbname
    ; dbtype setting can either be mysql or postgres
    dbtype = mysql

    With this, it seems that ok, but the account admin is deleted.

    [database]
    hostname = localhost
    ; port for postgres is 5432 by default
    port =
    ; user = a2billing_dbuser
    user = root
    ;password = a2billing_dbpassword
    password = eLaStIx.2oo7

    ;dbname = a2billing_dbname
    dbname = mya2billing
    ; dbtype setting can either be mysql or postgres
    dbtype = mysql

    Now it seems that root instead of admin
    the root password is changepassword

    Lots of config problem after using your script.

    It's normal?

    Regards
     
  6. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    mysql here in Elastix world, which is 3306 not 13306, no?



    (I read the script, and I might add it is a delightful script, but haven't run it yet so maybe I should STFU till then :) )

    respectfully,

    dicko

    [edit]

    so the ( ) and 1 's in the sed scripts need escaping with a backslash , it's the stupid board code here un-escaping the escape characters unless you escape the escape characters them-selves either inside or outside a \
    Code:
     block how dumb is that!!
    
    
    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
     
  7. saleh

    Joined:
    Apr 18, 2007
    Messages:
    249
    Likes Received:
    0
    The script works without any problem tested in many Elastix System, the problem is in Joomla. To download the script

    wget http://www.linuxsolutions.ps/a2billing-1.6.0.sh
    chmod +x a2billing-1.6.0.sh
    ./a2billing-1.6.0.sh


    >> Now it seems that root instead of admin
    >> the root password is changepassword
    >> Lots of config problem after using your script.
    >> It's normal?

    Yes, it's normal, there is a difference between the A2Billing version 1.3 and A2Billing versions 1.4.x , 1.5.x and 1.6.x

    For A2Billing 1.6.0 default administration user is root and the password is changepassword and all configuration are in Data Base and you can configure it via the A2Billing web interface under the menu "SYSTEM SETTINGS"

    Best Regards,

    Saleh
     
  8. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    Yes. ok it's right since tomorrow.

    Good news, there's the French translation, I'm happy. :)

    So, good work Saleh. :)

    Best regards

    Hi Dicko. ;)

    Tonight, I'm very tired, I made a little garden shed.
    Arghhhh! I hurt my back. :side:
     
  9. tylerd

    Joined:
    Jul 14, 2007
    Messages:
    33
    Likes Received:
    0
    I have modified the original script made by Saleh, combined with the instructions contained in the helpfile Centos.Install included in the sources of the 1.6 version; and some additional features from an existing a2billing install script, posted by Johnatan Roper in the a2billing forum. The main differences between the original and this one are the callback-daemon init scrit, the installation of sqlalchemy with easy_install tool, plus some python stuffs. Also added some recommended macros and few changes in the custom_dest table in the asterisk db. Fully functional for my production server actually. Any feedback about will be well received. The credits must be to Saleh and Johnatan Roper. (Cited in the script too...)

    Regards;

    Ivanof M.G.
    InteliRedes Colombia S.A.S.
    www.inteliredes.com. http://forum.elastix.org/old_files/a2billing_1-5ca89fa2d6b2eac7b0754dde36eb9f15.txt
     
  10. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    And why not but, what happen if I already to run the first script? :huh:

    Regards
     
  11. saleh

    Joined:
    Apr 18, 2007
    Messages:
    249
    Likes Received:
    0
    Good work Ivanof, we can make together Ealstix porject as the best project in the sourceforge.

    Best Regards,

    Saleh
     
  12. saleh

    Joined:
    Apr 18, 2007
    Messages:
    249
    Likes Received:
    0
    >> And why not but, what happen if I already to run the first script

    As Ivanof said, the main differences between the original and this one are the callback-daemon init scrit, the installation of sqlalchemy with easy_install tool, plus some python stuffs. Also added some recommended macros and few changes in the custom_dest table in the asterisk db.

    You can run the new script, but you will have double entries in cron, sip_custom.conf, iax_custom.conf and extensions_custom.conf, you can remove the double entries after you run it or comment these sections in the script before you run it.

    Best Regards,

    Saleh
     
  13. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    Ok, I'll try it.

    thanks saleh

    regards
     
  14. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Thank you both tylerd and saleh:

    It works like a charm, In my case I had to do a

    mysql_fix_privilege_tables --password=eLaStIx.2oo7


    before I could add card/user accounts/rates however.

    Regards and kudos to both of you

    dicko
     
  15. tylerd

    Joined:
    Jul 14, 2007
    Messages:
    33
    Likes Received:
    0
    Thanks, Dicko..this is a strictly needed for a fully operational config. Without run this, cant generate customers properly...in my case too. ;-). But let's the script without the mod needed; so the lazy people have to read the entire post...agree?

    TylerD
     
  16. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Indeed ;)

    Now I have to get rid of all that VAT stuff in the invoices or confuse my non-euro clients to hell :):) Unfortunately here we do not have flat rate values added taxation but we DO have bizarre "tariffs and surcharges" that nobody questions.
     
  17. saleh

    Joined:
    Apr 18, 2007
    Messages:
    249
    Likes Received:
    0
    Thanks Dicko,

    I forgot to mentioned this and as TylerD said, this is a strictly needed for a fully operational config. Without run this, cant add rates or customer for more information please see this in A2Billing forum.

    Cant add rates or customer
    mysql fix privilege tables

    Best Regards,

    Saleh
     
  18. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Now you got my juices flowing, I have spent years doing an SQL extractions of the rather lame CDR from Asterisk, for re-rating and charging back my clients , as to rates and E164 destinations, I have "collected" about 350000 Worldwide Prefixes ("Most significant digits" ) destinations, e.g. +1805955 which will get you to NANP, US, ventura, simivalley, (better for the customer to read than the generic "1805, US") they go down to the "thousands" for +1 (NANP) to identify cellphone carriers over traditional wire-centers , or +441358 blah blah "national" number in the U.K never mind the +44845 crap. Some I paid for, and would not share without cutting in the provider (the LERG here in the US is about 35k a month for the full list and I certainly won't go there!!), but I am intrigued with the open ended Austrian and German dialplans etc. not to mention "really weird" places, We all come from different "locales", each has their own "intrinsic" cost and some need special attention, like the scammers in the Caribbean or the various cost of cell termination in Europe

    I'll STFU now and ask if anybody is interested in sharing, consolidating and verifying the veracity of such a database, each bringing their own local knowledge?

    Phone Numbers are in fact by definition "open source" but the hegemony in charge of where they go and what it will cost to go there, has us by the balls! The customer would be impressed by our "other than vanilla" verifiable CDR charges,

    regards

    dicko
     
  19. rafael

    Joined:
    May 14, 2007
    Messages:
    1,454
    Likes Received:
    1
    Hi Saleh and tylerd

    Good work :).

    How about if you two colaborate on and article for the Elastix Blog about this script. I see tylerd is from Colombia so we may have the article in both Spanish & English blogs. And ofcourse if our friend danardf has time we could soon lounch the blog in French :).

    Best regards,

    Rafael
     
  20. hamdy

    Joined:
    Feb 26, 2010
    Messages:
    3
    Likes Received:
    0
    HI every body

    very good work

    can i ask please if elastix could a2billing could be a good and practical solution as a softswitch for a large number of concurrent calls ?

    Thank you

    sorry for my bad english :)
     

Share This Page