Discussion in 'General' started by anthonyfr, Mar 24, 2011.

  1. anthonyfr

    Nov 9, 2010
    Likes Received:
    yum update
    yum install nano

    installation php php-5.2

    yum install yum-priorities
    cd /etc/yum.repos.d/
    wget dev.centos.org/centos/5/CentOS-Testing.repo
    yum --enablerepo=c5-testing install php

    yum update

    rpm -qa |grep php


    # php -v

    PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
    Copyright (c) 1997-2008 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies


    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 www.asterisk2billing.org/downloads/A2Bi ... 7.1.tar.gz
    tar -xzf A2Billing_1.7.1.tar.gz
    chown -R root:root /usr/src/a2billing

    echo "GRANT ALL PRIVILEGES ON *.* TO 'a2billinguser'@'localhost' IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | mysql -peLaStIx.2oo7

    mysqladmin create mya2billing -u a2billinguser -pa2billing

    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
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.6.0-to-v1.6.1.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.6.1-to-v1.6.2.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.6.2-to-v1.7.0.sql
    mysql mya2billing -u root -peLaStIx.2oo7 </usr/src/a2billing/DataBase/mysql-5.x/UPDATE-a2billing-v1.7.0-to-v1.7.1.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

    echo " Add some custom destinations to FreePBX. Check it out later too.."
    #Agrega algunos custom destinations a FreePBX
    RESULT=`/usr/bin/mysql -uroot -peLaStIx.2oo7 <<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', '');

    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

    cp /usr/src/a2billing/a2billing.conf /etc/

    sed -i "s/\(port *= *\)\(.*\)/\13306/" /etc/a2billing.conf
    sed -i "s/\(user *= *\)\(.*\)/\1a2billinguser/" /etc/a2billing.conf
    sed -i "s/\(password *= *\)\(.*\)/\1a2billing/" /etc/a2billing.conf
    sed -i "s/\(dbname *= *\)\(.*\)/\1mya2billing/" /etc/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

    # 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

    chmod 755 /var/spool/asterisk/monitor/


    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

    mysql_fix_privilege_tables --password=eLaStIx.2oo7


    ; config file for the A2Billing Callingcard platform

    ; Global Database Setup - select the database type and authentication as required.

    hostname = localhost
    port = 5432
    user = a2billinguser
    password = a2billing
    dbname = mya2billing
    ;dbtype = postgres
    dbtype = mysql

    ; len_cardnumber is removed
    ; interval for the length of the cardnumber (number of digits), minimum lenght is 4
    ; ie: 10-15 (cardnumber authorised 10, 11, 12, 13, 14, 15) ; 10,12,14 (cardnumber authorised 10, 12, 14)
    interval_len_cardnumber = 10-15

    ; Alias-Card length
    len_aliasnumber = 15

    ; Voucher length
    len_voucher = 15

    ;base currency define the default currency that you want to use to setup your system (see the currency table to know the currency code)
    base_currency = usd

    ; filename of the image that will be display at the top of the invoice (if not defined no image will appear ; path to place the image templates/default/images/)
    ; the type of file have to be a jpeg/jpg
    invoice_image = asterisk01.jpg

    ; DID Billing - amount of day before the end of the monthly reservation to bill the customer to for the DID use
    ; if the user dont have enough credit he will get an email asking him to refill
    didbilling_daytopay = 5

    ;webiste administrator email address
    admin_email = areski@gmail.com

    manager_host = localhost
    manager_username = a2billinguser
    manager_secret = a2billing

    ; When web call-back is enabled this is the context to sent the call.
    context_callback = a2billing-callback

    ; this is the Extension to redirect the call when the web callback is returned
    extension = 1000

    ; this is the number of seconds to wait before initiating the call back.
    sec_wait_before_callback = 10

    ;Number of seconds before the call-back can be re-initiated from the web page
    ; to prevent repeated and unwanted calls.
    sec_avoid_repeate = 30

    ; if the callback doesnt succeed within the value below, then the call is deemed to have failed.
    timeout = 20

    ; if we want to manage the answer on the call
    answer_call = yes

    ; number of calls an agent will do when the call button is clicked
    nb_predictive_call = 10

    ; Number of days to wait before the number becomes available to call again.
    nb_day_wait_before_retry = 1

    ; The context to redirect the call for the predictive dialer
    context_preditctivedialer = a2billing-predictivedialer

    ; When a call is made we need to limit the call duration : amount in seconds
    predictivedialer_maxtime_tocall = 5400

    ; set the callerID for the predictive dialer and call-back
    callerid = 123456

    ; ID Call Plan to use when you use the all-callback mode, check the ID in the "list Call Plan" - WebUI
    all_callback_tariff = 1

    ; Define the group of servers that are going to be used by the callback
    id_server_group = 1

    ; Audio intro message when the callback is initiate
    callback_audio_intro = prepaid-callback_intro


    ; url of the signup page to show up on the sign in page (if empty no link will show up)
    signup_page_url =

    ;Enable or disable the payment methods; yes for multi-payment or no for single payment method option
    paymentmethod = yes

    ;Enable or disable the page which allow customer to modify its personal information
    personalinfo = yes

    ; Enable display of the payment interface - yes or no
    customerinfo = yes

    ; Enable display of the sip/iax info - yes or no
    sipiaxinfo = yes

    ; Enable the Call history - yes or no
    cdr = yes

    ; Enable invoices - yes or no
    invoice = yes

    ; Enable the voucher screen - yes or no
    voucher = yes

    ; Enable the paypal payment buttons - yes or no
    paypal = yes

    ; Allow Speed Dial capabilities - yes or no
    speeddial = yes

    ; Enable the DID (Direct Inwards Dialling) interface - yes or no
    did = yes

    ; Show the ratecards - yes or no
    ratecard = yes

    ; Offer simulator option on the customer interface - yes or no
    simulator = yes

    ; Enable the callback option on the customer interface - yes or no
    callback = yes

    ; Enable the predictivedialer option on the customer interface - yes or no
    predictivedialer = yes

    ; Let users use SIP/IAX Webphone (Options : yes/no)
    webphone = yes

    ;IP address or domain name of asterisk server that would be used by the web-phone
    webphoneserver = localhost

    ; Let the users add new callerid
    callerid = yes

    ; Let the user change the webui password
    password = yes

    ; The total number of callerIDs for CLI Recognition that can be add by the customer
    limit_callerid = 5

    ; Email address to send the notification and error report - new DIDs assigned will also be emailed.
    error_email = root@localhost

    ;SIP & IAX client configuration information.

    ;Trunk Name to show in sip/iax info
    sip_iax_info_trunkname = call-labs

    ;Allowed Codec, ulaw, gsm, g729
    sip_iax_info_allowcodec = g729

    ;host information
    sip_iax_info_host = call-labs.com

    ;IAX Additional Parameters
    iax_additional_parameters = "canreinvite = no"

    ;SIP Additional Parameters
    sip_additional_parameters = "trustrpid = yes | sendrpid = yes | canreinvite = no"

    enable = yes
    ; eg, http://localhost - should not be empty for productive servers
    http_server = "http://www.call-labs.com"
    ; eg, https://localhost - Enter here your Secure Server Address, should not be empty for productive servers
    https_server = "http://www.call-labs.com"
    ; Enter your Domain Name or IP Address, eg,
    http_cookie_domain =
    ; Enter your Secure server Domain Name or IP Address, eg,
    https_cookie_domain =
    ; Enter the Physical path of your Application on your server
    http_cookie_path = "/A2BCustomer_UI/"
    ; Enter the Physical path of your Application on your Secure Server
    https_cookie_path = "/A2BCustomer_UI/"
    ; Enter the Physical path of your Application on your server
    dir_ws_http_catalog = "/A2BCustomer_UI/"
    ; Enter the Physical path of your Application on your Secure Server
    dir_ws_https_catalog = "/A2BCustomer_UI/"
    ; secure webserver for checkout procedure?
    enable_ssl = yes

    http_domain =

    dir_ws_http = "/~areski/svn/a2billing/payment/A2BCustomer_UI/"

    ; maybe try with :
    ; Define here the URL to notify the payment
    ; payment_notify_url=...

    ;define the different amount of purchase that would be available - 5 amount maximum (5:10:15)
    purchase_amount = 1:2:5:10:20

    ; Item name that would be display to the user when he will buy credit
    item_name = "Credit Purchase"

    ; Currency for the Credit purchase, only one can be define here
    currency_code = USD

    ; Define here the URL of paypal gateway the payment (to test with paypal sandbox)
    ;paypal_payment_url = "https://secure.paypal.com/cgi-bin/webscr"
    paypal_payment_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"

    ;paypal transaction verification url
    ;paypal_verify_url = www.paypal.com
    paypal_verify_url = www.sandbox.paypal.com

    ; Define here the URL of Authorize gateway
    ;authorize_payment_url = "https://secure.authorize.net/gateway/transact.dll"
    authorize_payment_url = "https://test.authorize.net/gateway/transact.dll"

    ;paypal store name to show in the paypal site when customer will go to pay
    store_name = Asterisk2Billing

    ;Transaction Key for security of Epayment Max length of 60 Characters.
    transaction_key = asdf1212fasd121554sd4f5s45sdf

    ;Moneybookers secret word
    moneybookers_secretword = areski

    ; enable the signup module
    enable_signup = 1

    ; enable Captcha on the signup module (value : YES or NO)
    enable_captcha = YES

    ; amount of credit applied to a new user.
    credit = 0

    ; the list of id of call plans which will be shown in signup.
    callplan_id_list = 1, 2

    ; Specify whether the card is created as active or pending
    activated = no

    ; Simultaneous or non concurrent access with the card - 0 = INDIVIDUAL ACCESS or 1 = SIMULTANEOUS ACCESS
    simultaccess = 0

    typepaid = 0

    ; Define credit limit, which is only used for a POSTPAY card.
    creditlimit = 0

    ; Authorise the recurring service to apply on this card - Yes 1 - No 0
    runservice = 0

    ; Enable the expiry of the card - Yes 1 - No 0
    enableexpire = 0

    ; Expiry Date format YYYY-MM-DD HH:MM:SS. For instance, '2004-12-31 00:00:00'
    expirationdate =

    ; The number of days after which the card will expire
    expiredays = 0

    ; Create a sip account from signup ( default : yes )
    sip_account = yes

    ; Create an iax account from signup ( default : yes )
    iax_account = yes

    ; active card after the new signup. if No, the Signup confirmation is needed and an email will be sent
    ; to the user with a link for activation (need to put the link into the Signup mail template)
    activatedbyuser = no

    ; url of the customer interface to display after activation
    urlcustomerinterface = http://localhost/A2BCustomer_UI/

    ; Define if you want to reload Asterisk when a SIP / IAX Friend is created at signup time
    reload_asterisk_if_sipiax_created = no

    ; configuration for backup and restore

    ; Path to store backup of database
    backup_path = /tmp

    ; path for gzip
    gzip_exe = /bin/gzip

    ; path for gunzip
    gunzip_exe = /bin/gunzip

    ; path for mysqldump
    mysqldump = /usr/bin/mysqldump

    ; path for pg_dump
    pg_dump = /usr/bin/pg_dump

    ; path for mysql
    mysql = /usr/bin/mysql

    ;path for psql
    psql = /usr/bin/psql


    ; Path to store the asterisk configuration files SIP & IAX
    buddy_sip_file = /etc/asterisk/additional_a2billing_sip.conf
    buddy_iax_file = /etc/asterisk/additional_a2billing_iax.conf

    ; API have a security key to validate the http request, the key has to be sent after applying md5
    ; Valid characters are [a-z,A-Z,0-9]
    api_security_key = Ae87v56zzl34v

    ; API to restrict the IP's authorised to make a request.
    ; Define The the list of ips separated by ;
    api_ip_auth =

    ; Administative Email(not used yet)
    email_admin = root@localhost

    ; MOH (Music on Hold) base directory
    dir_store_mohmp3 = /var/lib/asterisk/mohmp3

    ; Number of MOH classes you have created in musiconhold.conf : acc_1, acc_2... acc_10 class etc...
    num_musiconhold_class = 10

    ; Display the help section inside the admin interface (YES - NO)
    show_help = YES

    ; File Upload parameters
    my_max_file_size_import = 1024000 ; 1 MG

    ; Not used yet, The goal is to upload files and use them in the IVR
    dir_store_audio = /var/lib/asterisk/sounds/a2billing

    ; upload maximum file size
    my_max_file_size_audio=3072000 ; in bytes

    ; File type extensions permitted to be uploaded such as "gsm, mp3, wav" (separated by ,)
    file_ext_allow = gsm, mp3, wav

    ; File type extensions permitted to be uploaded for the musiconhold such as "gsm, mp3, wav" (separate by ,)
    file_ext_allow_musiconhold = mp3


    ; Enable link on the CDR viewer to the recordings. (YES - NO)
    link_audio_file = NO

    ; Path to link the recorded monitor files
    monitor_path = /var/spool/asterisk/monitor
    ; grant access to apache user on read mode for the directory

    monitor_formatfile = gsm

    ; Display the icon in the invoice
    show_icon_invoice = YES


    ; Display the top frame (useful if you want to save space on your little tiny screen )
    show_top_frame = NO

    ; Allow the customer to chose the most appropriate currency ("all" can be used)
    currency_choose = usd, eur, cad, hkd

    ; field to export in csv format from cc_card table
    card_export_field_list = creationdate, username, credit, lastname, firstname

    ; field to export in csv format from cc_voucher table
    voucher_export_field_list = id, voucher, credit, tag, activated, usedcardnumber, usedate, currency

    ; Advanced mode - Display additional configuration options on the ratecard (progressive rates, musiconhold, ...)
    advanced_mode = NO

    ; Delete the SIP/IAX Friend & callerid when a card is deleted
    delete_fk_card = yes

    ; This section is basically used when we create a new friend
    ; when you create a SIP IAX friend for a card the following parameters will define the default value for the peer creation
    ; Refer to sip.conf & iax.conf documentation for the meaning of those parameters
    ; sip.conf -> http://www.voip-info.org/wiki-Asterisk+config+sip.conf
    ; iax.conf -> http://www.voip-info.org/wiki-Asterisk+config+iax.conf
    type = friend
    allow = ulaw, alaw, gsm, g729
    context = a2billing
    ; use "no" or "yes" with quote otherwise the value will be converted to 1 or 0
    nat = "yes"
    amaflag = billing
    ; use "no" or "yes" with quote otherwise the value will be converted to 1 or 0
    qualify = "yes"
    host = dynamic
    dtmfmode = RFC2833

    ; To disable application logging, remove/comment the log file name aside service

    ; cront - recurring process
    cront_alarm = /tmp/cront_a2b_alarm.log
    cront_autorefill = /tmp/cront_a2b_autorefill.log
    cront_batch_process = /tmp/cront_a2b_batch_process.log
    cront_bill_diduse = /tmp/cront_a2b_bill_diduse.log
    cront_subscriptionfee = /tmp/cront_a2b_subscription_fee.log
    cront_currency_update = /tmp/cront_a2b_currency_update.log
    cront_invoice = /tmp/cront_a2b_invoice.log
    cront_check_account = /tmp/cront_a2b_check_account.log

    ; paypal log file, to log all the transaction & error
    paypal = /tmp/a2billing_paypal.log

    ; epayment log file, to log all the transaction & error
    epayment = /tmp/a2billing_epayment.log

    ; Log file to store the ecommerce API requests
    api_ecommerce = /tmp/api_ecommerce_request.log

    ; Log file to store the CallBack API requests
    api_callback = /tmp/api_callback_request.log

    ; File to log
    agi = /tmp/a2billing_agi.log

    ; configuration for the AGI, different configuration can be defined, ie "agi-conf1", "agi-conf2", etc...
    ; the groupid parameter will define which process_sections to use. Usage : DeadAGI(a2billing.php|%groupid%)
    ; by default agi-conf1 is used

    ; the debug level
    ; 0=none, 1=low, 2=normal, 3=all
    debug = 1

    ; Asterisk Version Information
    ; 1_1,1_2,1_4 By Default it will take 1_2 or higher
    asterisk_version = 1_2

    ; Manage the answer on the call
    answer_call = YES

    ; Play audio - this will disable all stream file but not the Get Data
    ; for wholesale ensure that the authentication works and than number_try = 1
    play_audio = YES

    ; play the goodbye message when the user has finished.
    say_goodbye = NO

    ; enable the menu to choose the language
    ; press 1 for English, pulsa 2 para el español, Pressez 3 pour Français
    play_menulanguage = NO

    ; force the use of a language, if you dont want to use it leave the option empty
    ; Values : ES, EN, FR, etc... (according to the audio you have installed)
    force_language =

    ; Introduction prompt : to specify an additional prompt to play at the beginning of the application
    intro_prompt =

    ; Minimum amount of credit to use the application
    min_credit_2call = 0

    ; this is the minimum duration in seconds of a call in order to be billed
    ; any call with a length less than min_duration_2bill will have a 0 cost
    ; useful not to charge callers for system errors when a call was answered but it actually didn't connect
    min_duration_2bill = 0

    ; if user doesn't have enough credit to call a destination, prompt him to enter another cardnumber
    notenoughcredit_cardnumber = YES

    ; if notenoughcredit_cardnumber = YES then assign the CallerID to the new cardnumber
    notenoughcredit_assign_newcardnumber_cid = YES

    ; if YES it will use the DNID and try to dial out, without asking for the phonenumber to call
    ; value : YES, NO
    use_dnid = NO

    ; list the dnid on which you want to avoid the use of the previous option "use_dnid"
    no_auth_dnid = 2400,2300

    ; number of times the user can dial different number
    number_try = 3

    ; this will force to select a specific call plan by the Rate Engine
    force_callplan_id =

    ; Play the balance to the user after the authentication (values : yes - no)
    say_balance_after_auth = YES

    ; Play the balance to the user after the call (values : yes - no)
    say_balance_after_call = NO

    ; Play the initial cost of the route (values : yes - no)
    say_rateinitial = NO

    ; Play the amount of time that the user can call (values : yes - no)
    say_timetocall = YES

    ; enable the setup of the callerID number before the outbound is made, by default the user callerID value will be use
    auto_setcallerid = YES

    ; If auto_setcallerid is enabled, the value of force_callerid will be set as CallerID
    force_callerid =

    ; If force_callerid is not set, then the following option ensures that CID is set to one of the card's configured caller IDs or blank if none available.
    ; NO - disable this feature, caller ID can be anything.
    ; CID - Caller ID must be one of the customers caller IDs
    ; DID - Caller ID must be one of the customers DID nos.
    ; BOTH - Caller ID must be one of the above two items.
    cid_sanitize = NO

    ; enable the callerid authentication
    ; if this option is active the CC system will check the CID of caller
    cid_enable = NO

    ; if the CID does not exist, then the caller will be prompt to enter his cardnumber
    cid_askpincode_ifnot_callerid = YES

    ; if the callerID authentication is enable and the authentication fails then the user will be prompt to enter his cardnumber
    ; this option will bound the cardnumber entered to the current callerID so that next call will be directly authenticate
    cid_auto_assign_card_to_cid = YES

    ; if the callerID is captured on a2billing, this option will create automatically a new card and add the callerID to it
    cid_auto_create_card = NO

    ; set the length of the card that will be auto create (ie, 10)
    cid_auto_create_card_len = 10

    ; If cid_auto_create_card has been set to YES, the following options will define with which configuration we will create the card
    ; billing type of the new card
    ; ( value : POSTPAY or PREPAY)
    cid_auto_create_card_typepaid = POSTPAY

    ; amount of credit of the new card
    cid_auto_create_card_credit = 0

    ; if postpay, define the credit limit for the card
    cid_auto_create_card_credit_limit = 1000

    ; the tariffgroup to use for the new card (this is the ID that you can find on the admin web interface)
    cid_auto_create_card_tariffgroup = 6

    ; to check callerID over the cardnumber authentication (to guard against spoofing)
    callerid_authentication_over_cardnumber = NO

    ; enable the option to call sip/iax friend for free (values : YES - NO)
    sip_iax_friends = NO

    ; if SIP_IAX_FRIENDS is active, you can define a prefix for the dialed digits to call a pstn number
    ; values : number
    sip_iax_pstn_direct_call_prefix = 555

    ; this will enable a prompt to enter your destination number.
    ; if number start by sip_iax_pstn_direct_call_prefix we do directly a sip iax call, if not we do a normal call
    sip_iax_pstn_direct_call = NO

    ; enable the option to refill card with voucher in IVR (values : YES - NO)
    ivr_voucher = NO

    ; if ivr_voucher is active, you can define a prefix for the voucher number to refill your card
    ; values : number - don't forget to change prepaid-refill_card_with_voucher audio accordingly
    ivr_voucher_prefix = 8

    ; When the user credit are below the minimum credit to call min_credit
    ; jump directly to the voucher IVR menu (values: YES - NO)
    jump_voucher_if_min_credit = NO

    ; Extracharge DIDs, multiple numbers and fees must be separated by comma
    ; extracharge_did = 1800XXXXXXX,1888XXXXXXX
    extracharge_did =
    ;extracharge_fee = 0.02,0.03
    extracharge_fee =

    ; More information about the Dial : http://voip-info.org/wiki-Asterisk+cmd+dial
    ; 30 : The timeout parameter is optional. If not specifed, the Dial command will wait indefinitely, exiting only when the originating channel hangs up, or all the dialed channels return a busy or error condition. Otherwise it specifies a maximum time, in seconds, that the Dial command is to wait for a channel to answer.
    ; H: Allow the caller to hang up by dialing *
    ; r: Generate a ringing tone for the calling party
    ; R: Indicate ringing to the calling party when the called party indicates ringing, pass no audio until answered.
    ; m: Provide Music on Hold to the calling party until the called channel answers.
    ; L(x[:y][:z]): Limit the call to 'x' ms, warning when 'y' ms are left, repeated every 'z' ms)
    ; %timeout% tag is replaced by the calculated timeout according the credit & destination rate!

    dialcommand_param = "|60|HRrL(%timeout%:61000:30000)"

    ; by default (3600000 = 1HOUR MAX CALL)
    dialcommand_param_sipiax_friend = "|60|HL(3600000:61000:30000)"

    ; Define the order to make the outbound call
    ; YES -> SIP/dialedphonenumber@gateway_ip - NO SIP/gateway_ip/dialedphonenumber
    ; Both should work exactly the same but i experimented one case when gateway was supporting dialedphonenumber@gateway_ip
    ; So in case of trouble, try it out
    switchdialcommand = NO

    ; failover recursive search - define how many time we want to authorize the research of the failover trunk when a call fails (value : 0 - 20)
    failover_recursive_limit = 2

    ; For free calls, limit the duration: amount in seconds
    maxtime_tocall_negatif_free_route = 5400

    ; Send a reminder email to the user when they are under min_credit_2call
    send_reminder = NO

    ; enable to monitor the call (to record all the conversations)
    ; value : YES - NO
    record_call = NO

    ; format of the recorded monitor file
    monitor_formatfile = gsm

    ; Force to play the balance to the caller in a predefined currency, to use the currency set for by the customer leave this field empty
    agi_force_currency =

    ; Define all the audio (without file extensions) that you want to play according to currency (use , to separate, ie "usd:prepaid-dollar,mxn:pesos,eur:Euro,all:credit")
    currency_association = usd:dollars,mxn:pesos,eur:euros,all:credit

    ; Please enter the file name you want to play when we prompt the calling party to enter the destination number
    ; file_conf_enter_destination = prepaid-enter-number-u-calling-1-or-011
    file_conf_enter_destination = prepaid-enter-dest

    ; Please enter the file name you want to play when we prompt the calling party to choose the prefered language
    ; file_conf_enter_menulang = prepaid-menulang
    file_conf_enter_menulang = prepaid-menulang2

    ; Define if you want to bill the 1st leg on callback even if the call is not connected to the destination
    callback_bill_1stleg_ifcall_notconnected = YES

    nano /etc/asterisk/extensions_custom.conf

    #include extensions_a2billing.conf


    ;1234,1,Playback(demo-congrats) ; extensions can dial 1234
    ;include => custom-recordme ; extensions can also dial 5678

    ; custom-count2four,s,1 can be used as a custom target for
    ; a Digital Receptionist menu or a Call Group

    ; custom-recordme,5678,1 can be used as a custom target for
    ; a Digital Receptionist menu or a Call Group
    ;exten => 5678,1,Wait(2)
    ;exten => 5678,2,Record(/tmp/asterisk-recording:gsm)
    ;exten => 5678,3,Wait(2)
    ;exten => 5678,4,Playback(/tmp/asterisk-recording)
    ;exten => 5678,5,Wait(2)
    ;exten => 5678,6,Hangup

    exten => s,1,Answer
    exten => s,n,Wait(3)
    exten => s,n,CBMysql()
    exten => s,n,Hangup

    exten => _X.,1,Answer
    exten => _X.,n,Wait(1)
    exten => _X.,n,DeadAGI(a2billing.php|1)
    exten => _X.,n,Hangup

    exten => _X.,1,DeadAGI(a2billing.php|2|callback)
    exten => _X.,n,Hangup

    exten => _X.,1,DeadAGI(a2billing.php|2|callback|27)
    exten => _X.,n,Hangup

    exten => _X.,1,DeadAGI(a2billing.php|2|cid-callback|27)
    exten => _X.,n,Hangup

    [custom-a2billing-allcallback];this is now used
    exten => _X.,1,DeadAGI(a2billing.php|2|callback|27)
    exten => _X.,n,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|did)
    exten => _X.,2,Hangup

    nano /etc/asterisk/extensions_a2billing.conf

    exten => _X.,1,Answer
    exten => _X.,n,Wait(1)
    exten => _X.,n,deadAGI(a2billing.php|1)
    exten => _X.,n,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|callback)
    exten => _X.,n,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|cid-callback|34) ;last #parameter is the callback area code
    exten => _X.,n,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|all-callback|34) ;last #parameter is the callback area code
    exten => _X.,n,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|did)
    exten => _X.,2,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|voucher)
    exten => _X.,n,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1|did)
    exten => _X.,2,Hangup

    exten => _X.,1,deadAGI(a2billing.php|1)
    exten => _X.,n,Hangup

    nano /etc/asterisk/manager_custom.conf

    secret = mycode
    read = system,call,log,verbose,command,agent,user
    write = system,call,log,verbose,command,agent,user

    nano /etc/asterisk/extensions.conf
    ; CallingCard application
    exten => _X.,1,Answer
    exten => _X.,2,Wait,2
    exten => _X.,3,DeadAGI,a2billing.php
    exten => _X.,4,Wait,2
    exten => _X.,5,Hangup

    ; CallingCard application
    exten => _X.,1,DeadAGI(a2billing.php|1|did)


    user root
    password changepassword

    voire si le database connecter

    mysql mya2billing -u a2billinguser -pa2billing

    SELECT * FROM cc_ui_authen;

    sip realtime


    nano /etc/asterisk/res_mysql.conf

    dbhost =
    dbname = mya2billing
    dbuser = a2billinguser
    dbpass = a2billing
    dbport = 3306
    dbsock = /tmp/mysql.sock

    nano /etc/asterisk/extconfig.conf

    ;#include a2billing realtime
    iaxusers => mysql,mya2billing,cc_iax_buddies
    iaxpeers => mysql,mya2billing,cc_iax_buddies
    sipusers => mysql,mya2billing,cc_sip_buddies
    sippeers => mysql,mya2billing,cc_sip_buddies
    extensions => mysql,mya2billing,cc_sip_buddies

    asterisk -r

    core show config mapping

    Config Engine: mysql
    ===> iaxpeers (db=mya2billing,table=cc_iax_buddies)
    ===> iaxusers (db=mya2billing,table=cc_iax_buddies)
    ===> sippeers (db=mya2billing,table=cc_sip_buddies)
    ===> sipusers (db=mya2billing,table=cc_sip_buddies)

    realtime mysql status

    Connected to mya2billing@localhost, port 3306 with username a2billinguser for 7 minutes, 37 seconds

    realtime load sipuser name 28553615555


    nano /etc/asterisk/extensions.conf

    switch => Realtime/@cc_sip_buddies
    include => parkedcalls

    mysql mya2billing -u a2billinguser -pa2billing

    mysql> select * from dialplan;
    | id | context | exten | priority | app | appdata | descr | flags |
    | 1 | a2billing | _X. | 1 | Answer | | | 0 |
    | 3 | a2billing | _X. | 3 | DeadAGI | a2billing.php | | 2 |
    | 2 | a2billing | _X. | 2 | Wait | | | 0 |
    | 5 | a2billing | _X. | 5 | Hangup | | | 0 |


    CLI> sip show users

Share This Page