Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Tuesday, August 6, 2013

How to Upgrade GOautodial CE 2.1 to the latest version (3.0)



 Upgrade GOautodial CE 2.1 to the latest version (3.0)

1. Make sure to BACKUP your data first!!!
2. Check if you are running GOautodial CE 2.1 and your MySQL password is set to "vicidialnow".
# cat /etc/vicidialnow-release
GoAutoDial CE 2.1
Skip command below if your MySQL password is "vicidialnow"

# mysqladmin password vicidialnow -p
Enter password:
3. Install the GOautodial yum repository
# cd /etc/yum.repos.d/
# wget http://downloads2.goautodial.org/centos/5/goautodial.repo
4. Remove conflicting old packages
# rpm -e dahdi-linux dahdi-linux-devel dahdi-linux-kmdl-2.6.18-238.9.1.el5.goPAE dahdi-tools munin munin-node --nodeps
5. Update system, install GOautodial specific configuration and reboot
# yum update
Total size: 290 M
Is this ok [y/N]: y
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
updates/gpgkey                                                                                                                                                                                                                                          | 1.5 kB     00:00    
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Is this ok [y/N]: y
# yum install goautodial-ce goautodial-ce-config
# reboot
6. Edit PHP configuration file:
# nano /etc/php.ini
Make sure the entries below have the same value:
memory_limit = 128M
short_open_tag = On
max_execution_time = 360
max_input_time = 360
post_max_size = 64M
upload_max_filesize = 64M
default_socket_timeout = 360
7. Optional:
Install Sangoma Wanpipe drivers
Remove conflicting packages
# rpm -e wanpipe-util wanpipe-modules-2.6.18-238.9.1.el5.goPAE --nodeps --noscripts
Install updated Sangoma drivers
# yum install wanpipe
That's it folks! You're now running the latest and greatest open source GOautodial CE 3.0 system.
CentOS 5.9 base
DAHDI 2.6
DKMS DAHDI
DKMS Wanpipe
GOadmin
GOreports
GOagent
PHP 5.3
PHP-eAccelerator
Vicidial 2.4rc2

Monday, August 5, 2013

Convert audio files for use in Asterisk

Convert files from the CLI

You just recorded a fabulous audio file to use as you main voice menu. Then you realize that Asterisk does not use WAV format audio for the Playback or Background applications. So what do you do? How can you convert your WAV files into GSM files that still have good sound quality? (This is partially false, Asterisk can play anything it has a format and codec for, including some wav files. See below.)

Note the differences!

gsm: raw gsm encoding, good for VoIP
wav: MS wav format, 16 bit linear
WAV: MS wav format, gsm encoded (wav49)


Converting to sln format

Starting from Asterisk 1.2.0, the .sln (SLINEAR) format seems to be the preferred format.
To convert wav file to sln, use the following command:

sox foo-in.wav -t raw -r 8000 -s -w -c 1 foo-out.sln

Note that sox v14.3.0 and above (installed in Ubuntu 9.10), the -w option has changed to -2

sox foo-in.wav -t raw -r 8000 -s -2 -c 1 foo-out.sln

If you have a directory full of .wav files to convert, try this command. It uses sed to automatically rename the files with the .sln extension (assuming incoming wav files at a sample rate other than 8khz.)

for a in *.wav; do sox "$a" -t raw -r 8000 -s -w -c 1 `echo $a|sed "s/.wav/.sln/"` resample -ql; done

Converting your WAV files to good GSM files is easier than you might think if you have the program Sox installed (on Debian systems the libsox-fmt-gsm package is required in addition to sox). From the shell prompt, enter this command:

sox foo.wav -r 8000 foo.gsm resample -ql

and hit the <ENTER> key. Note that the sox option '-ql' (lower case L) modifies the resample option. It is not a number one (1). In a few moments you will have a new GSM format file in the same directory as the original WAV file. In this example "foo.wav" is your main voice menu audio file in WAV format, and "foo.gsm" is the same file converted to GSM format. If you wanted to, you could use "main-voice-menu.gsm" as the name in place of "foo.gsm": what matters here is the second file name you use in this command ends in ".gsm".

If your WAV file was in stereo, add the -c1 option to convert to mono, or the output will sound very strange.

sox foo.wav -r 8000 -c1 foo.gsm resample -ql

You may get better results if you record your WAV file in 16 bit 8000 Hz mono and then run

sox foo.wav foo.gsm

If you have multiple WAV files in one directory and you want to convert them all, use this command:

for a in *.wav; do sox "$a" -r 8000 -c1 "`echo $a|sed -e s/wav//`gsm" resample -ql; done

You can also put a bash script in /usr/bin and name it wav-gsm-convert. The content can be like this

  1. !/bin/bash
s=`echo $1| sed -e's/\.wav//'|xargs -i{} echo {}.gsm`
sox -t wav $1 -r 8000 -c1 -t gsm $s resample -ql


Next, move your new foo.gsm file to the directory: /var/lib/asterisk/sounds

Now you can easily use the applications Playback and Background in your extensions.conf file to play your fabulous main voice menu. For example:
exten => s,1,Background(foo)
or
exten => s,1,Background(main-voice-menu)
or
exten => s,1,Playback(foo)
or
exten => s,1,Playback(main-voice-menu)

Playing .sln files from the command line

You can play sln files using sox from the command line (play is part of sox):

play -t raw -r 8000 -s -w -c 1 file.sln

Using WAV files

Asterisk has codecs for wav (pcm), gsm, g729, g726, and wav49, all of which can be used for Playback and Background. However, Asterisk does not understand ADPCM WAV files. To convert your WAV files to a format which Asterisk can understand, use the following command:

sox foo-in.wav -r 8000 -c 1 -s -w foo-out.wav resample -ql

Note that sox v14.3.0 and above (installed in Ubuntu 9.10), resample is no longer used, remix is used or leave it as:

sox foo-in.wav -r 8k -c 1 -s -w foo-out.wav

All so if your using sox v14.3.foo and above and you are getting check_header errors with play back try this:

sox foo-in.wav -r 8k -c 1 -e gsm foo-out.wav

This also works converting mp3, just make sure you have libsox-fmt-mp3 installed.

Normalizing volume and reducing volume fluxuations

Using the sox command's "compand" filter, you can reduce or eliminate flutters in volume level, and you can normalize the volume of your sound files. This is called dynamic range compression. The effect is desirable for a PBX system where changes in volume, or voices that are too quiet to understand would be considered unprofessional. It is important to perform the compand effect BEFORE you resample it as to preserve as much quality as possible.

An example command to perform some appropriate dynamic range compression and normalization is shown below:

sox "foo-in.wav" -r 8000 -c1 "foo-out.gsm" lowpass 4000 compand 0.02,0.05 -60,-60,-30,-10,-20,-8,-5,-8,-2,-8 -8 -7 0.05 resample -ql

In this example, foo-in.wav is a 16-bit mono 44khz uncompressed pcm WAV file.

Converting to a CD writable format

So, you've decided to do your call recording in GSM format as you don't care about quality and you don't want to stuff your disks full, but how do you write that file to an audio CD to send to somebody who wants to listen to the call?

sox infile.gsm -r 44100 -a outfile.wav

Friday, July 12, 2013

Install Fail2ban in Asterisk (Centos)

Installing Fail2ban in centos
1.yum install fail2ban
If your CentOS doesn't find the package, please execute the following command and then try again.
2.rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
3.yum install python iptables
or
wget http://downloads.sourceforge.net/project/fail2ban/fail2ban-stable/fail2ban-0.8.4/fail2ban-0.8.4.tar.bz2?use_mirror=transact

tar -xf fail2ban-0.8.4.tar.bz2
cd fail2ban-0.8.4
python setup.py install
cp files/redhat-initd /etc/init.d/fail2ban
chkconfig --add fail2ban
chkconfig fail2ban on

Once installing the Fail2ban  create asteirsk.conf file under the fail2ban directory

4.  vi /etc/fail2ban/filter.d/asterisk.conf

and copy and paste the below

# ===================
# /etc/fail2ban/filter.d/asterisk.conf
# Fail2Ban configuration file
#
#
# $Revision: 250 $
#
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
#before = common.conf
[Definition]
#_daemon = asterisk
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile.
#The
# host must be matched by a group named "host". The tag "" can
# be used for standard IP/hostname matching and is only an alias
#for
# (?:::f{4,6}:)?(?PS+)
# Values: TEXT
#

failregex = Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Wrong password
            Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - No matching peer found
            Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Device does not match ACL
            Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Username/auth name mismatch
            Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Peer is not supposed to register
            NOTICE.* <HOST> failed to authenticate as '.*'$
            NOTICE.* .*: No registration for peer '.*' (from <HOST>)
            NOTICE.* .*: Host <HOST> failed MD5 authentication for '.*' (.*)
            VERBOSE.* logger.c: -- .*IP/<HOST>-.* Playing 'ss-noservice' (language '.*')


# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
# ===================
Add the [asterisk-iptables] section to your /etc/fail2ban/jail.conf file :
# /etc/fail2ban/jail.conf
#====================



5 .  Save and exit the file
6.   vi /etc/fail2ban/jail.conf
      go to the last line of theis file and paste the below lines there

[asterisk-iptables]
enabled = true
filter = asterisk
action = iptables-allports[name=ASTERISK, protocol=all]
sendmail-whois[name=ASTERISK,
dest=youremailaddress@somewhere.com, sender=fail2ban@somewhere.com]
logpath = /var/log/asterisk/full
maxretry = 5
bantime = 600
#====================


7. Also in /etc/fail2ban/jail.conf file you want to add your own IP address range ( ours is192.168.1.0 ) :
ignoreip = 127.0.0.1 192.168.1.0/24

8.  make the fail2ban to start at startup
     chkconfig fail2ban on
9.  start the fail2ban now
    /etc/init.d/fail2ban start
10 . now check whether the fail2ban is installed properly to detect the attacks
       iptables -L –v
      You should see "fail2ban-ASTERISK" in your iptables output.

11. now try to register a extension from outside with wrong password or worng extension and run the iptables command to see the blocked ip addresses