#!/bin/sh # file: a2billing-1.7.1_elastix.sh # Updated by A.Lang on 2010-08-09 # Make sure only root can run our script if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" 1>&2 exit 1 fi clear echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "This script assumes you have not changed the default root username For MySQL" echo "If you have, e.g. if you use PBX-Management, press CTRL-C to exit" echo "Then change the MySQL root password in the script to suit your installation." echo " " echo "If an earlier copy of A2Billing is already installed, then you should inspect" echo "this script and modify it, or modify your installation before executing it." echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" read -p "Press any key to continue or ctrl-C to exit" #Change passw0rd below for your MySQL root password if you have changed it from the default. DBPASS='eLaStIx.2oo7' #DATETAG=`date +%Y%m%d%H%k%M%S` echo "*************************************************************" echo " Installing A2Billing - Downloading files from the internet" echo "" echo " Please be patient" echo "" 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/ rm -f -R /var/log/a2billing/ # Remove the old cron jobs that included the path name '.../libs_a2billing/crontjob/...'. sed -i "/\/libs_a2billing\/crontjob/d" /var/spool/cron/asterisk # Drop the old database (if it exists) mysqladmin drop mya2billing -u root -p$DBPASS # Step2: A2billing installation 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 mysql -u root -p$DBPASS>/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 # for Predictive Call(Campaigns) mkdir /var/run/a2billing chown asterisk:asterisk /var/run/a2billing echo "" echo "" echo "" echo "" echo "" echo "*******************************************************************" echo "A2Billing is installed" echo "-------------------------------------------------" echo "" echo "Please Reboot as soon as you are able" echo "" echo "*******************************************************************" echo "" echo "The default username is root" echo "The default password is changepassword" echo "*******************************************************************" #EOF