Zeng Yang a.k.a H o w T o

Google

Tuesday, December 20, 2005

[HOWTO] Postfix + SMTP AUTH + MySQL

Tested on: Fedora Core 4 (2.6.11-1.1369_FC4), MySQL-5.0.16

1.0 Getting the needed resources

Before installing postfix make sure the following packages are installed:


  • openssl-0.9.7f-7
Both packages above was pre-installed in Fedora Core 4. If needed, run

# up2date openssl

Download and install cyrus-sasl from this site, the cyrus-sasl version used in this HOWTO is 2.1.20

# mkdir /usr/src/cyrus-sasl
# cd /usr/src/cyrus-sasl
# wget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.20.tar.gz
# tar zxvf cyrus-sasl-2.1.20.tar.gz
# cd cyrus-sasl-2.1.20
# ./configure --disable-krb4 --disable-gssapi --disable-otp
# make
# make install
# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2

During the ./configure;make process, an error will occur like below:

client.c:64: error: static declaration of 'global_callbacks' follows non-static declaration

Locate the client.c file at /usr/src/cyrus-sasl-2.1.20/lib/ . Edit the file with your favourite editor find the statement "static sasl_global_callbacks_t global_callbacks;" and subsitute it as below:

# nano /usr/src/cyrus-sasl-2.1.20/lib/client.c

...
# Comment this line, remove the static keyword
#static sasl_global_callbacks_t global_callbacks;

sasl_global_callbacks_t global_callbacks;
...

Save the file, client.c. Re-run the command above.


Next, Postfix installation. Get the Postfix package and execute the following command:

# mkdir /usr/src/postfix/
# cd /usr/src/postfix/
# wget ftp://ftp.planetmirror.com/pub/postfix/official/postfix-2.2.7.tar.gz
# tar zxvf postfix-2.2.7.tar.gz
# cd postfix-2.2.7

The following command is to clean left over files from the previous build

# make tidy

#make makefiles CCARGS="-DUSE_TLS -DUSE_SASL_AUTH -I/usr/local/include/sasl -DHAS_MYSQL -I/usr/include/mysql" AUXLIBS="-lssl -lcrypto -L/usr/local/lib -lsasl2 -L/usr/lib/mysql -lmysqlclient -lz -lm"

Compile and install them

# make
# make install


Upon successful installation, you will be prompted to input some values. Just press 'enter' key to accept the default values.


[HOWTO] A2Billing

Note: Tested on Fedora Core 2( 2.6.5-1.358), MySQL-4.1.16, Asterisk-1.2

1.0 Download A2Billing
Be sure you have successfully installed Asterisk and MySQL before proceeding. This HOWTO will not cover the installation guide for Asterisk and MySQL.
# cd /usr/src
# mkdir a2bill
# cd a2bill
# wget http://www.areski.net/Open_A2Billing_version_Raccoon.tar.gz

Uncompress the package


# pwd
/usr/sr/a2bill/
# tar zxvf Open_A2Billing_version_Raccoon.tar.gz

2.0 Setting up A2Billing's MySQL database
Create the database for A2Billing, the database name is up to your own preference.
In this example the author will use 'a2bill'
( You might want to consider adding a mysql user, this exampleis done using the root user )

# mysql -p
enter password:
mysql> create database a2bill;
mysql> quit

If you database is not protect by password simply ignore the -p parameter. Next, dump the SQL
syntax into MySQL database.

# cd /usr/src/a2bill/
# mysql -p a2bill <>

To verify if database is AOK.

#mysql -p a2bill
password:
mysqlconsole> SELECT * FROM ui_authen;

This table ui_authen, stores the user information for the webUI users. The above command shall
return with two (2) records.

3.0 Installing php-pcntl module
php-pcntl is a php module that controls UNIX process creation, execution, signaling and
termination.This module is used to detect calls termination so asterisk will close
a2billing.php. If this module is not installed, you have have card in-use even though you have
hang up the call

The version might defer, depending on Fedora Version. For more information check
click here. Current version of php-pcntl is 4.3.10 (FC2), there will be dependency
problem if your php version differs.
Do an up2date (The command will download the latest php and assist you in dependencies issues.)
to grab the latest version of php:

# up2date php

Download and install php-pcntl

# cd /usr/src
# mkdir php-pcntl
# cd php-pcntl
# wget http://optusnet.dl.sourceforge.net/sourceforge/phprpms/php-pcntl-4.3.10-2.4.2.i386.rpm
# rpm -iUvh php-pcntl-4.3.10-2.4.2.i386.rpm


4.0 Installing A2Billing

Installing A2Billing is pretty simple, all you need to do is copy files to designated
directories. First copy the main configuration file, a2billing.conf (located at /usr/src/a2bill/)
to /etc/asterisk/.

# cd /usr/src/a2bill/
# cp a2billing.conf /etc/asterisk/.

This config, a2billing.conf, consist of several main sections:

[database]
~Mainly specifies database connection

[webUI]
~Web Interface customization

[recprocess]
~configuration for the recurring process(cront job) *i've not used it*

[agi-confX]
~Define the behaviour of AGI script (a2billing.php). This section can be customize according
to end-customer's preferences.
*Note: X is replace with numbers you can have multiple agi-conf eg: agi-conf1, agi-conf2


Next, copy the 'rate.inc' file to /etc/asterisk. The file contains the currency rates of most countries

# pwd
/usr/src/a2bill/
# cp rates.inc /etc/asterisk/.

Now, we shall copy the web interface files to httpd document root. There are types of web
user interface, one for admin the other for customers, copy both to httpd document root. httpd
document root for fedora is located at /var/www/html/ may vary depending on operating system.

Copy the admin web interface to /var/www/html/ and rename the directory to a2bill/

# pwd
/usr/src/a2bill/
# cp -rf A2Billing_UI /var/www/html/.
# mv /var/www/html/A2Billing_UI/ /var/www/html/a2bill/

Copy the customer web interface to /var/www/html/ and rename the directory to a2billcust/

# pwd
/usr/src/a2bill/
# cp -rf A2BCustomer_UI /var/www/html/
# mv /var/www/html/A2BCustomer/ /var/www/html/a2billcust/

Lastly, copy the content in A2Billing_AGI/ directory to /var/lib/asterisk/agi-bin/

# cd /usr/src/a2bill/A2Billing_AGI
# cp a2billing.php /var/lib/asterisk/agi-bin/.
# cp -rf libs_a2billing/ /var/lib/asterisk/agi-bin/.
# chmod +x /var/lib/asterisk/agi-bin/a2billing.php

Copy the required sound files to /var/lib/asterisk/sounds/

# cp sound/* /var/lib/asterisk/sounds/.
# cp sound/en/* /var/lib/asterisk/sounds/.

5.0 Configuring A2Billing


Thursday, December 15, 2005

[HOWTO] FreeRadius

NOTE: Tested on Fedora Core 2(2.6.5-1.358), MySQL 4.1.14 and FreeRadius-1.0.4

1. Download FreeRadius and MySQL


You need to first obtain radius and MySQL


# mkdir /usr/src/freeradius
# cd /usr/src/
# wget ftp://ftp.freeradius.org/pub/radius/old/freeradius-1.0.4.tar.gz


For mysql you need to download the following packages:
  • MySQL-server
  • MySQL-client
  • MySQL-devel
  • MySQL-shared-compat
2. Install MySQL

To install MySQL, execute the command below according to sequence:
# rpm -iUvh MySQL-shared-compat-4.1.14-0.i386.rpm
# rpm -iUvh MySQL-server-4.1.14-0.i386.rpm
# rpm -iUvh MySQL-client-4.1.14-0.i386.rpm
# rpm -iUvh MySQL-devil-4.1.14-0.i386.rpm

3. Install FreeRadius

Go to the directory where you downloaded FreeRadius-1.0.X.tar.gz

# cd /usr/src/freeradius
# tar zxvf freeradius-1.0.4.tar.gz
# cd freeradius-1.0.4
# ./configure --with-experimental-modules
# make
# make install

The options --with-experimental-modules is to load rlm_sqlcounter module which enable you to use 'Session-Timeout' attribute for prepaid system.

Once accomplished, the configuration files can be found at /usr/local/etc/raddb/ the main config file will be radiusd.conf, clients.conf and sqlcounter.conf (for prepaid system)