Tuesday, August 6, 2013

Vicidial, Goautodial Server IP showing 127.0.0.1:mask2

Vicidial - Goautodial Server IP in Phones, conference and server  Showing 127.0.0.1:mask2
Run the below command to change the IP from 127.0.0.1:mask2 to actual ip
update_server_ip.pl
old-server_ip=127.0.0.1:mask2 
new-server_ip=XX.XX.XX.XX
 
Put your Actual IP of Server instead of XX.
 
Done
 

conflicting types for ‘bool’ error while installing dahdi

Dahdi 2.6.1 conflicting types for bool

conflicting types for ‘bool’


include/linux/types.h:36: error: previous declaration of âboolâ was here


solution for the above error is to use the dahdi 2.6.2 rc1

#wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-2.6.2-rc1.tar.gz
#tar -xvzf dahdi-linux-2.6.2-rc1.tar.gz
#cd dahdi-linux-2.6.2-rc1
#make
#make install
#wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-2.6.1.tar.gz
#tar -xvzf dahdi-tools-2.6.1.tar.gz
#cd dahdi-tools-2.6.1
#./configure
#make
#make install
#make config

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

Automatic Block Hackers ip address who is try to hack from ssh

Automatically Blocking the hackers ip who access the server via ssh with wrong password
using IPtables


Dependencies
1.Iptables
2.postfix/sendmail ( for email alert)


step 1

1.login to your server via ssh
2. go to cd /usr/src/
3. vi scan-secure.sh
4. copy and paste the below script there

#!/bin/sh

# scan /var/log/secure for ssh attempts
# use iptables to block the bad guys

# Looking for attempts on existing and non-existing users. For example:
# Nov 2 22:44:07 pbxer sshd[28318]: Failed password for root from 74.143.42.70 port 52416 ssh2
# Nov 3 00:06:57 pbxer sshd[31767]: Failed password for invalid user mat3 from 192.203.145.200 port 35841 ssh2

tail -1000 /var/log/secure | awk '/sshd/ && /Failed password for/ { if (/invalid user/) try[$13]++; else try[$11]++; }
END { for (h in try) if (try[h] > 4) print h; }' |
while read ip
do
# note: check if IP is already blocked...
/sbin/iptables -L -n | grep $ip > /dev/null
if [ $? -eq 0 ] ; then
# echo "already denied ip: [$ip]" ;
true
else
echo "Subject: denying ip: $ip" | /usr/sbin/sendmail urmailid@gmail.com
logger -p authpriv.notice "*** Blocking SSH attempt from: $ip"
/sbin/iptables -I INPUT -s $ip -j DROP
fi
done

5. type chmod 755 /usr/src/scan-secure.sh
6. make entry in the cron to run in every one or two minutes
crontab -e
* * * * * /usr/src/scan-secure.sh
7. now start the iptables
/etc/init.d/iptables restart


to check for the blocked hackers ip
type iptables -L -n

Monday, August 5, 2013

Creating and Changing the Splash Image for Centos

The following information has been adapted from here
To create a Centos compatible splash image using Windows you will need to download and install the following (freeware) tools -
As previously stated in the guide the splash image must meet the following requirements -
  • Image must be 640x480 pixels in size.
  • Image must not contain more than 14 colours.
  • Image must use the .xpm file format, which can be compressed with gzip (.gz).
The first step is to create a Windows Bitmap Image (.bmp) of your chosen picture - the following examples will convert C:\splash.jpg (image is 1024x768). Start GIMP and open the file (or alternatively make your own image using GIMP).
To resize the image goto the Image Menu Scale Image... option.
GIMP will, by default, keep the same aspect ratio when resizing images. To disable this you will need to click on the icon next to the Width: and Height: boxes (see figure 1.) until it displays a broken link (see figure 2.).
figure 1.

figure 2.
Ensure that the Width: and Height: is set to 640 x 480, then click on the Scale button. Now goto the File Menu Save As... option, and save the image as a Windows Bitmap Image (.bmp file extension) - e.g. Save As C:\splash.bmp.
To set the maximum number of colours - goto the Image Menu —>Mode—>Indexed option. Change the maximum number of colors to 14 and click on the Convert button (although convert.exe (ImageMagick tool) can also be used to limit the maximum number of colours to 14 - the palette will not be optimised and the image is likely to be of poor quality. Using GIMP as outlined above will result in a much better image).
Although GIMP supports .xpm files, the Windows 32 port of the Gimp saves in an .xpm format that is not compatible with GRUB. Goto File Menu, and Save - retaining .bmp format. We have now finished with GIMP.
To convert the image to a Grub4dos compatible .xpm file, use the command line ImageMagick tool convert.exe with the syntax convert picture.bmp picture.xpm.gz. Open a command prompt in the ImageMagick install directory and enter the command convert.exe C:\splash.bmp C:\splash.xpm.gz.

Now Just upload this image to your server and copy it to the correct location  by following command

cp -f   yourspalshimage.xpm  /boot/grub/splash.xpm

Set the Permission

chmod 755 /boot/grub/splash.xpm

Reboot the server and Enjoy...

Convert all your Asterisk .wav recordings to .mp3

I have had many jobs (consulting and Salary) that have involved using Asterisk in a “Call-Center” environment. Whenever an agent would make a sale, the call would need to be recorded for verification purposes.  Now I could talk about Asterisk and call-recording for pages upon pages, but I will be focusing on large .wav to .mp3 conversion jobs on the Linux/Asterisk server itself.  First off, Asterisk can record calls using several different methods.  The first method being that you setup a feature called Automon in /etc/asterisk/features.conf and use *1 (or whatever you specify) to record a call in progress.  The second method is recording every call that comes in through a specific DID or enters a specific queue.  Another method is to setup a ‘call genie’ that you conference your phone to and it records the entire call-bridge.  There are pros and cons to every type of recording method and format.  You can use GSM, wav, g729, etc. to record calls.  Not matter what method you use, the simple script I wrote will convert your .wav files to .mp3 and also retain the timestamp of when the file was initially created (recorded). The options I use for mlame are what makes this script retain its awesome-ness over time.  The options allow the final-result mp3 to be compressed and compatable with Asterisk.  This means that you can playback your .mp3 files that you converted over Asterisk.
Installation Instructions:
1. Copy the below script to your server and save it as convert_recordings.sh. 
 ========================================
#!/bin/bash
#Make sure to install Lame and copy mlame to your .wav dir
#If you specify your own filenames, use NO spaces.

recorddir="/var/spool/asterisk/monitor"
for i in `ls $recorddir/*.wav`; do
cd $recorddir   
$recorddir/mlame -f -o "-b 16 -m m -q 9 --resample 8" $i
date=`ls -l $i | awk '{print $7,$6,2008,$8}'`
mp3=`echo $i | sed 's/.wav/.mp3/g'`
touch -d "$date" $mp3

#Uncomment the below line if you want your .wavs moved to a different directory.
#This way you can review the timestamps and mp3 files before deleting the .wav
#mv $i /wav_recordings
done
============================
2. Put the script anywhere you wish, I tend to leave it in my home directory
3. chmod +x convert_recordings.sh
4. You need to install lame.  Get the file from the lame site.
5. Extract the tarball.  For Example…    tar -zxvf lame-398-2.tar.gz
6. cd lame-398-2
7.   ./configure
8. make
9. make install
10. Now copy the mlame file from lame-398-2/misc/mlame to your .wav directory /var/spool/asterisk/monitor (or wherever your .wavs are)
11. chmod +x mlame
12. Edit the convert_recordings.sh  recorddir variable to match your .wav directory path (no trailing ‘/’). The default directory is set to /var/spool/asterisk/monitor
13. Run the script by navigating to the directory and   ./recordings_convert.sh
You should see it take a few seconds for each file and go on.  I usually test it out by letting it convert a few files then Cntrl + C and ls -l the directory to check the filesizes and timestamps.  There is a commented out section at the bottom of recordings_convert.sh that moves the .wav files to a separate directory (easier to check if it worked) and in my case, I keep the old files for a month or so for job security reasons.  If you lose a bunch of verification recordings, you are going to have major problems.
Cron it, at it, and happy converting.
__________________________________
Code for .g729 to MP3 script.  Very dirty, but works, please test on a small group of test files first.


#!/bin/bash
#Author: Gregg Hansen  20080414
#Used to convert from .g729 -in and -out files to .mp3
#Run on Recordings server

for i in `ls /ramdiskunload/*.g729`;
do
#convert all .g729 to wav first, then soxmix
DST=`echo $i | sed 's/.g729/.wav/g'`
asterisk -rx "file convert $i $DST"
rm -f $i
mv $DST /recordings
done
#all files should now be in the /recordings directory
#use soxmix and mlame to convert them to one file => mp3
for j in `ls /recordings/*-in.wav`;
do
INFILE=`echo $j | sed 's/-in/-out/g'`
MIXED=`echo $j | sed 's/-in//g'`
soxmix $j $INFILE $MIXED
rm -f $j
rm -f $INFILE
/root/test/mlame -f -o "-b 16 -m m -q 9 --resample 8" $MIXED
done


-----------------------------------------------------------------

Code for .g729 to wav script.  Very dirty, but works, please test on a small group of test files first.
 
#!/bin/bash
#Author: Gregg Hansen  20080414
#Used to convert from .g729 -in and -out files to .mp3
#Run on Recordings server
for i in `ls /root/mix/*.gsm`;
do
#convert all .g729 to wav first, then soxmix
LDST=/root/mix/recordings
DST=`echo $i | sed 's/.gsm/.wav/g'`
asterisk -rx "file convert $i $DST"
rm -f $i
mv $DST $LDST
done
#all files should now be in the /recordings directory
#use soxmix and mlame to convert them to one file => mp3
for j in `ls /root/mix/recordings/*-in.wav`;
do
INFILE=`echo $j | sed 's/-in/-out/g'`
MIXED=`echo $j | sed 's/-in//g'`
soxmix $j $INFILE $MIXED
rm -f $j
rm -f $INFILE
#/root/lame/misc/mlame -f -o "-b 16 -m m -q 9 --resample 8" $MIXED
done
 

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