Hacking digital systems

Category Archives: CentOS

FreePBX (CentOS 5.5) & A2Billing 1.9.4 (Stable) inside VirtualBox 4.0.8 Installation Notes

32-bit CentOS 5.5 Only

1. Download FreePBX from

Here’s a direct link to the version I downloaded:

2. Make a new VirtualBox virtual machine with these specs:

  • OS Type: Red Hat
  • Base Memory: 512MiB (Default)
  • Hard Disk Type: Dynamic
  • Hard Disk Size: 8.00GiB
  • Network: Bridged Adapter

NOTE: You will have to go into the settings and change the network adapter type after you create the virtual machine.

3. Start the virtual machine, VBox will then present the firstime run dialog.

This dialog will ask you to show it where the instllation media is located.
Please point it to where you saved FreePBX-Distro-Net-

4. FreePBX installation will now start.

Please follow the on-screen instruction for completeing the installation.
I reccoment at this point to setup a static IP for this server.

5. When you have rebooted and logged in, please update using YUM:

yum clean all
yum update
yum upgrade

Reboot using:

shutdown -r now

Then install the packeges nessesary to install VirtualBox Guest Additions:

yum install -y gcc
yum install -y kernel-devel

Reboot again:

shutdown -r now

NOTE: I have found you need to add the option ‘divider=10’ to you kernel boot options to reduce idle CPU load. On my machine, the idle load went from ~20% down to ~1% idle load.

6. We are now ready to install the Guest Additions.

Login as root and then from the Devices menu, choose Install Guest Additions… (or press [Hostkey]+D on your keyboard). This will insert then ISO into the virtual optical drive.

We will need to mount this ISO to use it:

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

7. Run the install script to install the guest additions:

cd /mnt/cdrom

Follow the standard procedure for installing the Guest Addtions documented in the VirtualBox User’s Manual. You will have to reboot when the installation has completed.

8. We must now manually upgrade PHP 5.1.x to 5.2.x

I will be using Jason Litka’s YUM Repo.

Instructions on installing this repo into your system can be found here:

9. Once you have added the repo following the instuction on Jason’s site, run the following commands:

yum clean all
yum update

YUM will ask you if it’s OK to upgrade the selected packages, type ‘y’ and hit [Enter].
Once YUM has finished updating, reboot the system:

shutdown -r now

10. Download the A2Billing tarball and extract:

cd /usr/local/src/
wget --no-check-certificate
tar xvf Star2Billing-a2billing-v1-current-0-g95789f5.tar.gz
ln -s ./Star2Billing-a2billing-d960375 ./a2billing

I made a symlink to /usr/local/src/Star2Billing-a2billing-d960375 called a2billing to make the directory access easier.

11. Before we can install A2Billing we need to make sure we have the required dependent packages installed:

ln -s /var/lib/asterisk /usr/share/asterisk
yum install -y php-mcrypt.i386

The symlink is for avoiding compatibility issues from .deb based distros. A2Billing setup scripts tend to assume a LOT of things.

12. Prepare the database:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1706
Server version: 5.1.52 MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> CREATE DATABASE a2billing;
 Query OK, 1 row affected (0.00 sec)
mysql> quit

NOTE: I had to change the MySQL root password becuase I had not set the password and I could not find the default password set by FreePBX. Also, FreePBX does not use the root user anyway for database access, it instead uses ‘freepbxuser’.

NOTE: If you need help changing the MySQL root user password without knowing the original password, please read the insructions here:

NOTE: You will have to change /etc/init.d/mysql to /etc/init.d/mysqld where applicable in the above tutorial.

13. Populate the database with new tables from script:

cd /usr/local/src/Star2Billing-a2billing-d960375/DataBase/mysql-5.x

When the script is executed, it will interactively ask for input to setup the database for you. Following the example below, you will need your A2Billing database name, hostname where the database is located, username to use to make the changes and the respective password.

Install A2Billing DataBase
Enter Database Name :
Enter Hostname :
Enter UserName :
Enter Password :
mysql --user=root --password=mypass --host=localhost a2billing

NOTE: Make sure to replace ‘mypass‘ for the password you use for the MySQL root user.

The script will take a few seconds to process and then it will drop you back at the command prompt with no errors if everything went well.

14. Set permissions for the new database:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1706
Server version: 5.1.52 MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> CREATE USER 'a2buser'@'localhost' IDENTIFIED BY 'mypass';
 Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON a2billing.* TO 'a2buser'@'localhost';
 Query OK, 1 row affected (0.00 sec)
mysql> quit

Check for the new tables (should be 97 of them), and check the new users grants (should be all of them):

mysql -u a2buser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1706
Server version: 5.1.52 MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> USE a2billing
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
| Tables_in_a2billing       |
| cc_agent                  |
| cc_agent_commission       |
| cc_agent_signup           |
| cc_agent_tariffgroup      |
| cc_alarm                  |
| cc_alarm_report           |
| cc_autorefill_report      |
| cc_backup                 |
| cc_billing_customer       |
| cc_call                   |
| cc_call_archive           |
| cc_callback_spool         |
| cc_callerid               |
| cc_callplan_lcr           |
| cc_campaign               |
| cc_campaign_config        |
| cc_campaign_phonebook     |
| cc_campaign_phonestatus   |
| cc_campaignconf_cardgroup |
| cc_card                   |
| cc_card_archive           |
| cc_card_group             |
| cc_card_history           |
| cc_card_package_offer     |
| cc_card_seria             |
| cc_card_subscription      |
| cc_cardgroup_service      |
| cc_charge                 |
| cc_config                 |
| cc_config_group           |
| cc_configuration          |
| cc_country                |
| cc_currencies             |
| cc_did                    |
| cc_did_destination        |
| cc_did_use                |
| cc_didgroup               |
| cc_epayment_log           |
| cc_epayment_log_agent     |
| cc_iax_buddies            |
| cc_invoice                |
| cc_invoice_conf           |
| cc_invoice_item           |
| cc_invoice_payment        |
| cc_iso639                 |
| cc_logpayment             |
| cc_logpayment_agent       |
| cc_logrefill              |
| cc_logrefill_agent        |
| cc_message_agent          |
| cc_monitor                |
| cc_notification           |
| cc_notification_admin     |
| cc_outbound_cid_group     |
| cc_outbound_cid_list      |
| cc_package_group          |
| cc_package_offer          |
| cc_package_rate           |
| cc_packgroup_package      |
| cc_payment_methods        |
| cc_payments               |
| cc_payments_agent         |
| cc_payments_status        |
| cc_paypal                 |
| cc_phonebook              |
| cc_phonenumber            |
| cc_prefix                 |
| cc_provider               |
| cc_ratecard               |
| cc_receipt                |
| cc_receipt_item           |
| cc_remittance_request     |
| cc_restricted_phonenumber |
| cc_server_group           |
| cc_server_manager         |
| cc_service                |
| cc_service_report         |
| cc_sip_buddies            |
| cc_sip_buddies_empty      |
| cc_speeddial              |
| cc_status_log             |
| cc_subscription_service   |
| cc_subscription_signup    |
| cc_support                |
| cc_support_component      |
| cc_system_log             |
| cc_tariffgroup            |
| cc_tariffgroup_plan       |
| cc_tariffplan             |
| cc_templatemail           |
| cc_ticket                 |
| cc_ticket_comment         |
| cc_timezone               |
| cc_trunk                  |
| cc_ui_authen              |
| cc_version                |
| cc_voucher                |
97 rows in set (0.00 sec)
| Grants for a2buser@localhost                                                                                                                                                                                                 |
| GRANT USAGE ON *.* TO 'a2buser'@'localhost' IDENTIFIED BY PASSWORD '*C6A9E404EE2F46734320E4727B7A791BC483BEC1'                                                                                                               |
2 rows in set (0.00 sec)
mysql> quit

15. Setup the a2billing.conf file:

ln -s /usr/local/src/a2billing/a2billing.conf /etc/a2billing.conf
nano /etc/a2billing.conf

Make sure the parameters in the file match these below:

hostname = localhost
port = 3306
user = a2buser
password = mypass
dbname = a2billing
dbtype = mysql

Type [Ctrl]+O and then [Enter] to save. Press [Ctrl]+X to exit to the command line.

NOTE: Don’t forget to replace ‘mypass‘ with the one you selected earlier.

16. Fix permissions, files and folders:

chmod 777 /etc/asterisk
touch /etc/asterisk/additional_a2billing_iax.conf
touch /etc/asterisk/additional_a2billing_sip.conf
echo '#include additional_a2billing_sip.conf' >> /etc/asterisk/sip.conf
echo '#include additional_a2billing_iax.conf' >> /etc/asterisk/iax.conf
chown -Rf apache:apache /etc/asterisk/additional_a2billing_iax.conf
chown -Rf apache:apache /etc/asterisk/additional_a2billing_sip.conf
chmod 777 /etc/asterisk/additional_a2billing_iax.conf
chmod 777 /etc/asterisk/additional_a2billing_iax.conf

17. Install sound files

cd /usr/local/src/a2billing/addons/sounds
chown -R asterisk:asterisk /usr/share/asterisk/sounds/

18. Configure Asterisk Manager

nano /etc/asterisk/manager.conf

Notice that we are using the default values (myasterisk, mycode) in this section. The configuration should look like this

enabled = yes
port = 5038
bindaddr =

19. Install The AGI components

Create a symbolic link of the entire content of the AGI directory into asterisk agi-bin directory:

ln -s /usr/local/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/a2billing.php
ln -s /usr/local/src/a2billing/AGI/a2billing_monitoring.php /var/lib/asterisk/agi-bin/a2billing_monitoring.php
ln -s /usr/local/src/a2billing/common/lib /var/lib/asterisk/agi-bin/lib
chmod 0774 /usr/local/src/a2billing/AGI/a2billing.php
chmod 0774 /usr/local/src/a2billing/AGI/a2billing-monitoring.php
chmod -Rf 0774 /usr/local/src/a2billing/common/lib
chown asterisk:asterisk /usr/local/src/a2billing/AGI/a2billing.php
chown asterisk:asterisk /usr/local/src/a2billing/AGI/a2billing-monitoring.php
chown -Rf asterisk:asterisk /usr/local/src/a2billing/common/lib

20. Install web-based Graphical interfaces

mkdir /var/www/html/a2billing
chown asterisk:asterisk /var/www/html/a2billing
mkdir -p /var/lib/a2billing/script
mkdir -p /var/run/a2billing
ln -s /usr/local/src/a2billing/admin /var/www/html/a2billing/admin
ln -s /usr/local/src/a2billing/agent /var/www/html/a2billing/agent
ln -s /usr/local/src/a2billing/customer /var/www/html/a2billing/customer
ln -s /usr/local/src/a2billing/common /var/www/html/a2billing/common
chmod -R 755 /usr/local/src/a2billing/admin/templates_c
chmod -R 755 /usr/local/src/a2billing/customer/templates_c
chmod -R 755 /usr/local/src/a2billing/agent/templates_c
chown -Rf asterisk:asterisk /usr/local/src/a2billing/admin/templates_c
chown -Rf asterisk:asterisk /usr/local/src/a2billing/customer/templates_c
chown -Rf asterisk:asterisk /usr/local/src/a2billing/agent/templates_c

You should be able to login to the A2Billing Admin site located at:

Username: root
Password: changepassword

NOTE: You should test this to make sure A2Billing works.

NOTE: I also had to set permissions on the /var/lib/php/sessions folder otherwise after logging into the Admin panel, clicking on any of the links would kick me off and force me to log in again. Here are the commands I used to fix this problem:

chmod -R 777 /var/lib/php/session
chown -R asterisk:asterisk /var/lib/php/session

21. Integrating FreePBX with A2Billing

I followed instructions for integrating A2Billing into FreePBX from this web site:

NOTE: Make sure to change the pipe symbols ‘|’ to commas ‘,’ in the examples in that site as you are using Asterisk The pipe opertator was changed to commas in version 1.6 of Asterisk.

As a final note, A2Billing does not officially support Asterisk versions 1.6.x and 1.8.x; if you have problems, you will need to get help on the A2Billing forum located at:

Good luck with getting all of this working the way you want!


Installing Asterisk With Yum

This tutorial tells you how to install Asterisk 1.6x on CentOS 5 and RHEL 5 using yum.I will be testing this on my production server to see if it is a better method for installing Asterisk than by compiling from source wi\hich is what I normally do.

Installing a binary distribution of Asterisk makes it easier to maintain your system. Using the package management tools that are included with your Linux distribution, you can install and update software without manually managing dependencies (libraries and utilities on which applications rely). Currently Asterisk is available for automated binary installation using the ‘yum’ utility on CentOS 5 Linux and for RedHat Enterprise Linux 5.

See link:

Where it first says to install using yum, there are a few package names cut off bauce of the advertisement. You need to enter the following command into your terminal:
yum install asterisk16 asterisk16-configs asterisk16-voicemail dahdi-linux dahdi-tools libpri

Installing D-Link DWA-552 on CentOS 5.5 (i386)

Installing D-Link DWA-552 on CentOS 5.5 (i386)

NOTE: You must be logged in as root to perform these operations.

* Configure RPMforge in yum
* Install madwifi drivers
* Enable NetworkManager
* Install Priorities

>>> Configure RPMforge in yum <<<
You need to install RPMforge in order to add madwifi to the yum repositories.

1. Make sure you have wget:
# yum -y install wget*
> Loaded plugins: fastestmirror, priorities
> Loading mirror speeds from cached hostfile
>  * addons:
>  * base:
>  * centosplus:
>  * contrib:
>  * extras:
>  * rpmforge:
>  * updates:
> Excluding Packages from CentOS-5 – Base
> Finished
> Reducing CentOS-5 – Plus to included packages only
> Finished
> Excluding Packages from CentOS-5 – Updates
> Finished
> 436 packages excluded due to repository priority protections
> Setting up Install Process
> Resolving Dependencies
> –> Running transaction check
> —> Package wget.i386 0:1.11.4-2.el5_4.1 set to be updated
> –> Finished Dependency Resolution
> Dependencies Resolved
> ================================================================================
>  Package        Arch           Version                     Repository      Size
> ================================================================================
> Installing:
>  wget           i386           1.11.4-2.el5_4.1            base           582 k
> Transaction Summary
> ================================================================================
> Install       1 Package(s)
> Upgrade       0 Package(s)
> Total download size: 582 k
> Downloading Packages:
> wget-1.11.4-2.el5_4.1.i386.rpm                           | 582 kB     00:00
> Running rpm_check_debug
> Running Transaction Test
> Finished Transaction Test
> Transaction Test Succeeded
> Running Transaction
>   Installing     : wget                                                     1/1
> Installed:
>   wget.i386 0:1.11.4-2.el5_4.1
> Complete!

2. Make sure you are in the root home folder:
# cd ~

3. Download the rpmforge-release package:
# wget
> –2010-06-24 01:29:41–
> Resolving…
> Connecting to||:80… connected.
> HTTP request sent, awaiting response… 302 Found
> Location: [following]
> –2010-06-24 01:29:41–
> Resolving…
> Connecting to||:80… connected.
> HTTP request sent, awaiting response… 200 OK
> Length: 16600 (16K) [application/x-rpm]
> Saving to: `rpmforge-release-0.5.1-1.el5.rf.i386.rpm’
> 100%[======================================>] 16,600      81.5K/s   in 0.2s
> 2010-06-24 01:29:42 (81.5 KB/s) – `rpmforge-release-0.5.1-1.el5.rf.i386.rpm’ saved [16600/16600]

4. Install DAG’s GPG key:
# rpm –import
5. Verify the package you have downloaded
# rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm
> rpmforge-release-0.5.1-1.el5.rf.i386.rpm: (sha1) dsa sha1 md5 gpg OK

6. Install the package:
# rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm
This will add a yum repository config file and import the appropriate GPG keys. At this point, you can set the priority of the RPMForge repository, and also of the CentOS repositories if you have not done so yet.

7. Test with this command:
# yum check-update
It should output these two lines:
> Loading “priorities” plugin
> …
> 76 packages excluded due to repository priority protections

The number above may differ, but there should be several packages shown as being excluded.

>>> Install madwifi drivers <<<

1. Install madwifi:
# yum -y install madwifi
This will pull in dkms and a bunch of other dependencies required to build the madwifi kernel module. (So this is not just the firmware, but a complete driver). If this worked out fine, you need to load the modules.

2. Load kernel modules:
# modprobe ath_pci

>>> Enable NetworkManager <<<

1. First we are going to configure your CentOS system to automatically start the NetworkManager on startup. You can do this by running:
# chkconfig NetworkManager on

2. Then we are going to start it so we can use it right away without needing to reboot:
# service NetworkManager start

If you have done that in your graphical environment (Gnome), your Notification Area (usually in the Gnome panel on the top-right) will show a new icon. If you left-click on this icon, you will see a list of possible Wireless networks to connect to.

3. You may also want to disable the network and wpa_supplicant services at boot time, as NetworkManager will now handle these. For this, simply do:
# chkconfig network off
# chkconfig wpa_supplicant off

>>> Install Priorities <<<

After installing RPMforge, you *must* install Priorities! If you don’t install this package, you’re going to have a< hell of a time updating you’re system with yum. >This is because there are a lot of packages provided by RPMforge that are also on the CentOS Repos. This causes dependency conflicts for yum, which in turn causes yum to fail updating some packages.

To install priorities, follow the instructions found on the CentOS Wiki for CentOS 5:

When you edit you’re *.repo files to add the new ‘priorities’ variable, don’t forget to add a ‘priorities’ level for every Repo section in every file.

Here’s what my .repo files look like:
# CentOS-Base.repo
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.

name=CentOS-$releasever – Base

#released updates
name=CentOS-$releasever – Updates

#packages used/produced in the build but not released
name=CentOS-$releasever – Addons

#additional packages that may be useful
name=CentOS-$releasever – Extras

#additional packages that extend functionality of existing packages
name=CentOS-$releasever – Plus

#contrib – packages by Centos Users
name=CentOS-$releasever – Contrib

# CentOS-Media.repo
# This repo is used to mount the default locations for a CDROM / DVD on
#  CentOS-5.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
# To use this repo, put in your DVD and use it with the other repos too:
#  yum –enablerepo=c5-media [command]
# or for ONLY the media repo, do this:
#  yum –disablerepo=\* –enablerepo=c5-media [command]

name=CentOS-$releasever – Media

### Name: RPMforge RPM Repository for Red Hat Enterprise 5 – dag
### URL:
name = Red Hat Enterprise $releasever – – dag
baseurl =$basearch/rpmforge
mirrorlist =
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

### Name: RPMforge RPM Repository for Red Hat Enterprise 5 – dag
### URL:
name = Red Hat Enterprise $releasever – – test
baseurl =$basearch/test
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 0

name=Webtatic Repository $releasever – $basearch

name=Webtatic Repository $releasever – $basearch

Hope this helps!!!