Sunday, 8 March 2015

Configuring Exim on IncrediblePBX

Configuring Exim to use Gmail Step by Step
Run: 

#root/email-setup
As you go through the wizard select the following entries:
Mail Sent by SmartHost

System Mail Name:
localhost



 Listen on:
127.0.0.1

Other Domains:
blank
Other Machines:
blank
IP of Outgoing SmartHost: 
smtp.gmail.com::587
Hide Local Mail Name:
No

Dial on Demand:
No
Delivery Method: 
mbox
 Split Config:
No
Create app specific password in Google to be used for the gmail credentials in passwd.client :
pico /etc/exim4/passwd.client
 Entry should look like this:
 *.google.com:yourname@gmail.com:yourpassword
 Update Exim by running this command: 
update-exim4.conf
 Restart your mail gateway: 

service sendmail restart


Thursday, 11 December 2014

Installing FreePBX on rPi

Setup And Run Asterisk and FreeBPX on A Raspberry PI

Finally recieved the Raspberry PI on Friday (25th May 2012) after a two and half year wait! My plan, which I had all that time to think about, discuss with others and have ready is still not concrete but initially, I have order 3 devices to play with.

As a Asterisk Engineer, one of the first things I wanted to tackle was to install the latest Asterisk and FreePBX on it. I build Asterisk based PBX systems for a living, so this shouldn't be that difficult. I responded on http://www.raspberry-asterisk.org/ to say I was going to attempt this and report back but so far the Admin has not got back to me on how I can add there so I have written this up here.



This guide is for complete newbies in getting the Raspberry PI to get set-up and run as a IP PBX using Asterisk and FreePBX
 

I intended to install Asterisk and FreePBX 2.9 (this is a matter of choice as I am accustomed to the layout before 2.10). I purchased a 8GB SD card instead of 2GB, which is sufficient for just Asterisk 1.8 but not enough for FreePBX. Here's the install process....

Install Squeeze - Get The PI Ready
Anyone with a Raspberry PI in their hands should first go though the following process and set up Debian Squeeze. For my setup, I had an 8GB SD Card. I downloaded Debian Squeeze for the PI from here and the Win32DiskImager from here, Stuck my SD card in to my windows laptop and fired up Win32 Disk Imager. Next, Unzipped the debian file and browsed to it in Win32 Disk Imager, select the correct drive letter in the drop down and let the imaging start. This is by far the quickest and dirtiest way to get Squeeze on to the SD.

After completion, I launched a Live CD of GParted, which is an amazing tool to partition disks. I increased the swap partition to 300Mb and moved it to the end of the drive. I then rezised the rootfs partition to used all the unallocated space on the drive.

Alternatively, you can follow the information on this great guide to go through and set up the drive properly and learn how to do the GParted stuff I mentioned above. 

Internet Access on the Raspberry PI

If you connect the PI to your local network which has a ADSL/CABLE router or mode, then it should have DHCP on. DHCP will provide it an IP address and this will be displayed on-screen when the PI boots up before the log in screen. If it doesnt, you need to get an IP and add this in manually. To do this, log in to the PI using the default username: pi and password: Raspberry and type the following command:

sudo vi /etc/network/interfaces


Using VI : Edit the file using by pressing 'a' to insert text. Once editied, press escape to come out of editing mode.

The IP parameters should be as follows with your specific IP address information:

iface eth0 inet static
address 192.168.1.100
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255


NOTE: Dont forget to comment/remove line stating:  

iface eth0 inet dhcp

Additionally you will need to set up DNS in order to get out on the internet. This setting should be done in the resolve.conf file as follows:

sudo vim /etc/resolv.conf

This should say something like:

nameserver 8.8.8.8
nameserver 192.168.1.1

to test network connectivity, at the command line, type in

ping <your favourite serach engine.com>

Press CTRL+C to stop pinging.



Update Asterisk Install Pre-requisites

To start with, update the system and install the required componants by copying the command below:

sudo apt-get update

sudo apt-get -y install make gcc g++ libxml2 libxml2-dev ssh libncurses5 libncursesw5 libncurses5-dev libncursesw5-dev linux-libc-dev sqlite libnewt-dev libusb-dev zlib1g-dev libmysqlclient15-dev libsqlite0 libsqlite0-dev bison openssl libssl-dev libeditline0 libeditline-dev libedit-dev mc sox libedit2 libedit-dev curl libcurl4-gnutls-dev apache2 libapache2-mod-php5 php-pear openssh-server build-essential openssh-client zlib1g zlib1g-dev libtiff4 libtiff4-dev libnet-telnet-perl mime-construct libipc-signal-perl libmime-types-perl libproc-waitstat-perl mpg123 libiksemel-dev php5 php5-cli mysql-server php5-mysql php-db libapache2-mod-php5 php5-gd php5-curl mysql-client vim

Dowload and Extract Asterisk

To Download and Extract asterisk, enter the commands as below:

cd /usr/src 
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz 
sudo tar xvfz asterisk-1.8-current.tar.gz 
cd asterisk-1.8*

Set Up Correct Compilation For ARM Platform
Using your favorite editor, make the change below. I prefer VIM, an enhanced version of the popular VI command line editor:

sudo vim makeopts.in

Search for the word "proc=" in the file and change this to read "proc=arm". For those new to VIM, move to the end of this line using the arrow keys and press 'a', then remove all the chractors before the = sign using back space and type in 'arm'. Finally press escape to come out of editing mode. Then press SHIFT+Z+Z to save and exit the file.

Compile and Install Asterisk
Using the following commands:

sudo ./configure
sudo make
sudo make install
sudo make samples
sudo make config


Finally, restart the PI by typing the fillowing command:

sudo init 6

Congratulations - Asterisk installed is now installed



To test the install, log in to the PI and type the following command:

sudo asterisk -r



If this all works, great...lets move on to installing FreePBX.

Create And Setup Asterisk Users And Groups Permissions

sudo useradd -c "Asterisk PBX" -d /var/lib/asterisk asterisksudo chown -R asterisk:asterisk /var/run/asterisksudo chown -R asterisk:asterisk /var/log/asterisksudo chown -R asterisk:asterisk /var/lib/php/session/


Install Pear and DB
FreePBX uses the php pear repository and specifically requires the database repositor. Enter the commands below to install them:

sudo apt-get install php-pear
sudo pear install db


Download And Extract FreePBX

To Download and Extract FreePBX, enter the commands as below:

cd /usr/src/
sudo wget http://mirror.freepbx.org/freepbx-2.9.0.tar.gz
tar zxvf freepbx*



Start The MySQL Server And Import In The FreePBX Data
Lets start the database server and import in the tables FreePBX will require using th following commands:

sudo service mysql start
cd /usr/src/freepbx*

sudo mysqladmin create asterisk
sudo mysqladmin create asteriskcdrdb
sudo mysql asterisk < SQL/newinstall.sql
sudo mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
sudo mysql





Lets add the mysql user and give it the correct permissions under the MySQL prompt:

GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '******';
GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '******';

flush privileges;

exit
NOTE where I have put '******', replace with your own password. Please keep a log of this as it will be required later. The password should secure (aplhanumeric with symbols) and in single speech marks as seen above

Now lets secure MySQL with a root password of your choice (See note above).

sudo mysqladmin -u root password '******'


Restart Asterisk With Correct Permissions

cd /use/src/freepbx*
sudo service asterisk stop
sudo ./start_asterisk start


Set The Correct Timezone for PHP
Open the PHP Configuration file:

sudo vim /etc/php5/apache2/php.ini

Under Module Settings, change the timezone accordingly:

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;


[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone


Uncomment date.timezone and set to the correct setting according to the link above. In my case, this was as follows:


date.timezone = Europe/London


To do this, move over the first charactor in the line, press 'a' the backspace to uncomment the line. Then move to the end of the line and type in your timezone after the '='. Press escape to come out of editing mode and save the file using the SHIFT+Z+Z combination.


Setup Apache For FreePBX and Asterisk
Apache user and group will need to be set to asterisk. To do this, run the following command to open the Apache configuration file:

sudo vim /etc/apache2/apache.conf

Find the line that states:

User www-data
Group www-data 



Change these to read:

User asterisk
Group asterisk

For those new to VIM, move to the end of this line using the arrow keys and press 'a', then remove all the charactors before the user or group using back space and type in 'asterisk'. Finally press escape to come out of editing mode. Then press SHIFT+Z+Z to save and exit the file.

Additionally, change the default sites settings by:

sudo vim /etc/apache2/sites-available/default

Under tags "<Directory />" and "<Directory /var/www/>" change the following settings:



Options FollowSymLinks
AllowOverride All



For those new to VIM, follow the origional instuction on editing above using the 'a' to go in to editing mode and escape key to come out of editing mode. Remember to save the file using SHIF+Z+Z.

Finally restart apache using the following command:

sudo service apache2 restart



Install FreePBX
To install FreePBX, you will need to specify the username and password to the database we setup earlier, start by typing in the following command:

sudo ./install_amp --username=asteriskuser --password=******

For each of the prompts, just hit enter except when prompted for

Enter the path to use for your AMP web root:
 [/var/www/html]


in this case type the following:

/var/www

Then hit enter. You should see something like this :

Checking for PEAR DB..OK
Checking for PEAR Console::Getopt..OK
Checking user..OK
Checking if Asterisk is running..running with PID: 2591..OK
Checking for /etc/amportal.conf../etc/amportal.conf does not exist, copying default
Creating new /etc/amportal.conf

Enter the hostname of the 'asterisk' database:
 [localhost]

Enter a USERNAME to connect to the Asterisk Manager interface:
 [admin]
Enter a PASSWORD to connect to the Asterisk Manager interface:
 [amp111]
Enter the path to use for your AMP web root:
 [/var/www/html] /var/www

Enter the IP ADDRESS or hostname used to access the AMP web-admin:
 [xx.xx.xx.xx]
Enter a PASSWORD to perform call transfers with the Flash Operator Panel:
 [passw0rd]
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]?
 [extensions]
Enter directory in which to store AMP executable scripts:
 [/var/lib/asterisk/bin]
Created /var/lib/asterisk/bin
Enter directory in which to store super-user scripts:
 [/usr/local/sbin]


One this is complete, lets set the file permissions for FreePBX to be accessable to apache users:

sudo chmod 777 /var/www/* -R

Finally Restart all services
Although in a lot of the cases, service restart is not required, I have had issues in previous versions of FreePBX, therefore as a final step, restart all the service to ensure they start with the correct permissions:

sudo amportal stop
sudo service apache2 stop
sudo service mysql stop

sudo service apache2 start
sudo service mysql start
sudo amportal start

Congratulations - Free PBX is now installed.
Ref:http://moishtech.blogspot.co.uk/2012/06/setup-and-run-asterisk-and-freebpx-on.html

Wednesday, 2 July 2014

Blinking annoying LED Ubuntu 14.10

If you happen to install Ubuntu 14.10 you will get the wi-fi LED constantly blinking.

I found this really annoying, so after a bit of Googling  this is what I did to change the LED behavior.

Open up terminal


$ sudo gedit  /etc/modprobe.d/iwlwifi.conf
Added the last line below to the end of the file:

# /etc/modprobe.d/iwlwifi.conf
# iwlwifi will dyamically load either iwldvm or iwlmvm depending on the
# microcode file installed on the system.  When removing iwlwifi, first
# remove the iwl?vm module and then iwlwifi.
remove iwlwifi \
(/sbin/lsmod | grep -o -e ^iwlmvm -e ^iwldvm -e ^iwlwifi | xargs /sbin/rmmod) \
&& /sbin/modprobe -r mac80211
options iwlwifi led_mode=1



and saved the file..

After a reboot the LED is still there to show that Wi-Fi is on, but the blinking has stopped.

~~~sigh~~~

Sunday, 6 April 2014

Raspbian Wheezy

Wheezy armel image
Features include:
  • minimal Raspbian Wheezy installation (similar to a netinstall)
  • Hard Float binaries: floating point operations are done in hardware instead of software emulation, that means higher performances
  • Disabled incremental updates, means apt-get update is much faster
  • Workaround for a kernel bug which hangs the Raspberry Pi under heavy network/disk loads
  • 3.6.11+ hardfp kernel with latest raspberry pi patches
  • Latest version of the firmwares
  • Fits 1GB SD cards
  • A very tiny 118MB image: even with a 2GB SD there is a lot of free space
  • ssh starts by default
  • The clock is automatically updated using ntp
  • IPv6 support
  • Just 14MB of ram usage after the boot
Here is the link to download my custom image:
Checksum MD5: e5b0d40f47a1fc2e4c2b80c99af538be

dd bs=1M if=raspbian_wheezy_20130923.img of=/dev/sdX
Finally, if you have an sd larger than 1GB, grow the partition with gparted (first move the swap partition at the end).
The root password is raspberry.

You will have to reconfigure your timezone after the first boot:
dpkg-reconfigure tzdata
The keyboard layout:
dpkg-reconfigure console-data
And the localization:
dpkg-reconfigure locales

Original Post:







Saturday, 5 April 2014

Recover Raspberry Pi Image

Back Up/Restore Raspberry Pi Image 

Once you have spend some time installing and customizing your image and your happy that everything works as you want it to , it's time to create a back up of your image before you start messing about with the Pi.

Step1 

- To create the back up run the Discks utility on Ubuntu laptop
- Select the first partition on the SD card and create an image of the boot partition
- Next do the same for the root partition and keep them in the same back up folder as the original image



Step 2


Now if you happen to break your image simply insert the SD card back in your laptop
and execute the following command in your terminal
- # sudo dd bs=1M if=raspbian.img of=/dev/mmcblk0
- This will create brand new image on you SD card

Step 3
- Open the Discs utility on your Ubuntu laptop and select the SD card
- Repeat the steps above but instead of selecting Create image select your root partition and run Restore Image

You are ready to go again!!

Saturday, 28 September 2013

PPPT VPN


Please bear in mind that PPTP vpn is less secure than openvpn. If you want to know why please ask Goolgle.
If you don't mind and you think PPPT is secure enough for you go ahead and run the following commands and you'll be ready in less than five.
# sudo apt-get update
# sudo apt-get upgrade
# sudo modprobe ppp-compress-18 - this command should return no errors used for mppe support
# sudo apt-get install pptpd
sudo pico /etc/pptpd.conf
Uncomment the following lines
localip 192.168.1.10
remoteip 192.168.0.25-27,192.168.0.30

"localip" - the IP is the device that is going to be running the VPN 
"remoteip" - is the t
he IP addresses that will be handed out to the clients connecting to you VPN.
Cntrl+o Cntrl+x
# sudo pico /etc/ppp/pptpd-options
Add the follow text on the bottom
ms-dns 192.168.1.1
noipxmtu 1490
mru 1490
Where the IP used for the ms-dns directive is the DNS server for the local network 

Cntrl+o Cntrl+x

# sudo pico /etc/ppp/chap-secrets
myusername[TAB]*[TAB]mypa55w0rd[TAB]*

Cntrl+o Cntrl+x
# sudo service pptpd restart
[ENTER]
To enable forwarding if you wish to have access to your entire home network while away. Edit the ‘sysctl’ file.
# sudo pico  /etc/sysctl.confFind “net.ipv4.ip_forward=1” and uncomment it (or change =0 to =1) 

Cntrl+o Cntrl+x.
# sudo sysctl -p
Last step: Adding iptables rule:
# sudo pico /etc/rc.local

Add this line just above “exit 0”

sudo iptables -t nat -A POSTROUTING -s 192.168.0.25/24 -o eth0 -j SNAT --to 192.168.1.10
Cntrl+o Cntrl+x

Now forward port 1723 in your router/modem 


Done

Saturday, 29 June 2013

My Raspbx

Pre-requisites:

-Connectivity to your Raspbx. Im connecting to the box over SSH

-A couple of soft phones (I'm using SFLphone and Ekiga) for testing and calling internally and externally.
All configuration information for the raspbx is located in /etc/asterisk.
All information for SIP users is stored in sip.conf Numbers are read from extensions.conf. Voicemails are stored in voicemail.conf etc.


To place a call through Asterisk, registration to Asterisk is not required. However, you do need a username and password which will allow you to call someone who is registered.

To receive a call, you must be a registered user and have an extension.

To Register SIP Users:

First of all all users must be registered in sip.conf and have a valid extension  declared in extensions.conf

Follow these steps for:


-Lets first register some users in sip.conf


1. Go to the /etc/asterisk directory on your Asterisk server. Open sip.conf and register the following test user.

Note that ALL lines beginning with ‘;’ (semi-colomn) are interpreted by Asterisk as a comment. 



[1000]

This means we are registering user '1000'

type=friend

This means the user can place or receive calls. For INBOUND calls only, use ‘peer’ as type. For outbound calls only use ‘user’ as type.

username=1000

This declares that our user will be named '1000'

secret=S3cretPa55w0rd

This creates the password for the user to login/authenticate on Asterisk

host=dynamic

This sets dynamic IP for the host. You may also define this as a static IP

context=test

This defines the dial context for the user which in this case is testing. In Asterisk, outgoing numbers are divided in groups called contexts in order to separate/define different needs for different user types. For example, a context for local calls, local area, international calls etc.


This completes the user registration process on Asterisk. Now let us register an extension for the users we created earlier.


-Registering a number in extensions.conf


2. Go to /etc/asterisk and open extensions.conf


[tutorial]

This registers the context ‘tutorial’

exten => 1000,1,Dial(SIP/1000)

when dialing number 1000, Asterisk will first Dial the user SFLphone through SIP protocol. The command is : exten => number, priority, Dial(protocol/user). The priority determines the sequence in which the extensions will be executed.
exten => 2000,1,Dial(SIP/2000)

when dialing number 2000, Asterisk will first Dial the user with SFLphone through SIP protocol. The command is : exten => number, priority, Dial(protocol/user). The priority determines the sequence in which the extensions will be executed.


We now have a registered SIP user and extension on Asterisk. Follow this same process to register another SIP user and extension in order to place test calls.

Start by registering the second user in the same way in /etc/asterisk/sip.conf



Register the extension(1000) in /etc/asterisk/extensions.conf in the same context = test.



Now when user '1000' or any other user from the test context dials 1000, the user '1000' will be called.

3. The final step is to register the user to a compatible softphones. However, softphones will be reviewed later. For now, just make sure you have registered the users and extensions