Created
March 11, 2025 18:30
-
-
Save razametal/866a97c3e70c0c65d9f893f1470db6de to your computer and use it in GitHub Desktop.
Instalar a2billing en Asterisk 22 / FreePBX 16 / Debian 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Requisitos: | |
| # Debian 11 | |
| # Asterisk 22 | |
| # FreePBX 16 | |
| # Instalar dependencias | |
| apt install git php7.4-sqlite3 php7.4-soap libapache2-mod-php7.4 php7.4-common php7.4-gd php7.4-cli php7.4-mysql mariadb-server php-pear php-raphf libmcrypt-dev | |
| # Descargar a2billing | |
| cd /usr/share | |
| https://github.com/radiusone/a2billing | |
| cd a2billing | |
| # Instalar composer | |
| curl -sS https://getcomposer.org/installer | php | |
| php composer.phar update | |
| php composer.phar install | |
| # Mover archivo de configuración e interfaz para admin/customer/agent | |
| mv /usr/share/a2billing/a2billing.conf /etc/ | |
| mkdir /var/www/html/billing | |
| mv /usr/share/a2billing/admin /var/www/html/billing/ | |
| mv /usr/share/a2billing/customer /var/www/html/billing/ | |
| mv /usr/share/a2billing/agent /var/www/html/billing/ | |
| mv /usr/share/a2billing/common /var/www/html/billing/ | |
| mv /usr/share/a2billing/vendor /var/www/html/billing/ | |
| mv /usr/share/a2billing/src /var/www/html/billing/ | |
| chmod u+xwr /var/www/html/billing/admin/templates | |
| chmod a+w /var/www/html/billing/admin/templates | |
| chmod u+xwr /var/www/html/billing/agent/templates_c | |
| chmod a+w /var/www/html/billing/agent/templates_c | |
| chmod u+xwr /var/www/html/billing/customer/templates | |
| chmod a+w /var/www/html/billing/customer/templates | |
| # Instalar AGI | |
| ln -s /usr/share/a2billing/AGI/a2billing.php /usr/share/asterisk/agi-bin/a2billing.php | |
| ln -s /usr/share/a2billing/AGI/a2billing_monitoring.php /usr/share/asterisk/agi-bin/a2billing_monitoring.php | |
| chown asterisk:asterisk /usr/share/asterisk/agi-bin/a2billing.php | |
| chown asterisk:asterisk /usr/share/asterisk/agi-bin/a2billing_monitoring.php | |
| chmod +x /usr/share/asterisk/agi-bin/a2billing.php | |
| chmod +x /usr/share/asterisk/agi-bin/a2billing_monitoring.php | |
| # Instalar sonidos | |
| cd /usr/share/a2billing/addons/sounds | |
| ./install_a2b_sounds.sh en es | |
| chown -R asterisk:asterisk /var/lib/asterisk/sounds | |
| # Instalar dialplan de a2billing | |
| cat /usr/share/a2billing/addons/asterisk-conf/extensions_a2billing.conf >> /etc/asterisk/extensions_custom.conf | |
| touch /etc/asterisk/sip_additional_a2billing.conf | |
| touch /etc/asterisk/iax_additional_a2billing.conf | |
| echo \#include sip_additional_a2billing.conf >> /etc/asterisk/sip_custom.conf | |
| echo \#include iax_additional_a2billing.conf >> /etc/asterisk/iax_custom.conf | |
| # Configurar manager para a2billing | |
| cat <<EOF > /etc/asterisk/manager_custom.conf | |
| [general] | |
| enabled = yes | |
| port = 5038 | |
| bindaddr = 0.0.0.0 | |
| [myasterisk] | |
| secret=mycode | |
| read=system,call,log,verbose,command,agent,user | |
| write=system,call,log,verbose,command,agent,user | |
| EOF | |
| Reiniciar asterisk | |
| asterisk -rx "core restart" | |
| # Configurar base de datos mariadb | |
| mysql -u root -e "create DATABASE if not exists mya2billing;" | |
| mysql -u root -e "FLUSH PRIVILEGES;" | |
| mysql -u root -e "GRANT ALL PRIVILEGES ON mya2billing.* TO 'a2billinguser'@'%' IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | |
| mysql -u root -e "GRANT ALL PRIVILEGES ON mya2billing.* TO 'a2billinguser'@'localhost' IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | |
| mysql -u root -e "GRANT ALL PRIVILEGES ON mya2billing.* TO 'a2billinguser'@'localhost.localdomain' IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | |
| /usr/share/a2billing/DataBase/mysql-5.x/install-db.sh | |
| sed -i "s/a2billing_dbuser/a2billinguser/g" /etc/a2billing.conf | |
| sed -i "s/a2billing_dbpassword/a2billing/g" /etc/a2billing.conf | |
| sed -i "s/a2billing_dbname/mya2billing/g" /etc/a2billing.conf | |
| # Configurar .htacces para la interfaz web de a2billing | |
| rm /var/www/html/billing/common/lib/.htaccess | |
| cat <<EOF > /var/www/html/billing/common/lib/.htaccess | |
| SetEnv HTACCESS on | |
| # Apache 2.2 | |
| <IfModule !mod_authz_core.c> | |
| # Disallow all . files, such as .htaccess or .git | |
| <FilesMatch "\..*$"> | |
| Deny from all | |
| </FilesMatch> | |
| # Allow index, config, and ajax.php, as well as all our image types. | |
| <FilesMatch "(^$|index\.html|index\.php|config\.php|ajax\.php|\.(map|gif|GIF|jpg|jpeg|png|css|js|swf|txt|ico|ttf|svg|eot|woff|woff2|wav|mp3|aac|ogg|webm|gz)$)"> | |
| Allow from all | |
| </FilesMatch> | |
| </IfModule> | |
| # Apache 2.4 | |
| <IfModule mod_authz_core.c> | |
| # Disallow all . files, such as .htaccess or .git | |
| <FilesMatch "\..*$"> | |
| Require all denied | |
| </FilesMatch> | |
| # Allow index, config, and ajax.php, as well as all our image types. | |
| <FilesMatch "(^$|index\.html|index\.php|config\.php|ajax\.php|\.(map|gif|GIF|jpg|jpeg|png|css|js|swf|txt|ico|ttf|svg|eot|woff|woff2|wav|mp3|aac|ogg|webm|gz|js)$)"> | |
| Require all granted | |
| </FilesMatch> | |
| </IfModule> | |
| <IfModule php7_module> | |
| php_value max_input_vars 5000 | |
| </IfModule> | |
| RewriteEngine on | |
| #RewriteCond %{ENV:REDIRECT_STATUS} 200 | |
| #RewriteRule ^ - [L] | |
| #RewriteRule ^config.php - [L,QSA] | |
| #RewriteRule ^ajax.php - [L,QSA] | |
| RewriteRule \.git/ - [F] | |
| RewriteRule libraries - [F] | |
| RewriteRule helpers - [F] | |
| RewriteRule i18n - [F] | |
| RewriteRule node - [F] | |
| RewriteRule views/.+php$ - [F] | |
| EOF | |
| # Instalar tareas programadas | |
| touch /etc/cron.d/a2billing | |
| cat <<EOF > /etc/cron.d/a2billing | |
| # update the currency table | |
| 0 6 * * * php /usr/share/a2billing/Cronjobs/currencies_update_yahoo.php | |
| # manage the monthly services subscription | |
| 0 6 1 * * php /usr/share/a2billing/Cronjobs/a2billing_subscription_fee.php | |
| # To check account of each Users and send an email if the balance is | |
| #less than the user have choice. | |
| 0 * * * * php /usr/share/a2billing/Cronjobs/a2billing_notify_account.php | |
| # this script will browse all the DID that are reserve and check if | |
| #the customer need to pay for it | |
| # bill them or warn them per email to know if they want to pay in | |
| #order to keep their DIDs | |
| 0 2 * * * php /usr/share/a2billing/Cronjobs/a2billing_bill_diduse.php | |
| # This script will take care of the recurring service. | |
| 0 12 * * * php /usr/share/a2billing/Cronjobs/a2billing_batch_process.php | |
| # To generate invoices and for each user. | |
| 0 6 * * * php /usr/share/a2billing/Cronjobs/a2billing_batch_billing.php | |
| # to proceed the autodialer | |
| #*/5 * * * * php /usr/share/a2billing/Cronjobs/a2billing_batch_autodialer.php | |
| # manage alarms | |
| 0 * * * * php /usr/share/a2billing/Cronjobs/a2billing_alarm.php | |
| # Archive data of older calls | |
| 0 12 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_archive_data_cront.php | |
| # Recharge customer credit automatic mode | |
| 0 6 1 * * php /usr/local/src/a2billing/Cronjobs/a2billing_autorefill.php | |
| EOF | |
| # Reiniciar servicio cron | |
| systemctl restart cron | |
| # Crear directorio para log | |
| mkdir /var/log/a2billing | |
| touch /var/log/a2billing/a2billing_agi.log | |
| chown -R asterisk:asterisk /var/log/a2billing | |
| chown -R asterisk:asterisk /var/www/html/billing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment