Asterisk for Raspberry Pi on ArchLinux: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
Line 111: Line 111:
<pre>
<pre>


Edit hostname and network settings
= Hostname =
  #  vi /etc/hostname
<pre>
  #  vi /etc/hosts
vi /etc/hostname
vi /etc/hosts


  #  vi /etc/dhcpcd.conf
vi /etc/dhcpcd.conf
           add line: nohook resolv.conf
           add line: nohook resolv.conf
         remove line: nohook lookup-hostname
         remove line: nohook lookup-hostname
</pre>


= Network =
<pre>
vi /etc/conf.d/network
<pre>
add the lines
<pre>
interface=eth0
address=192.168.1.1
netmask=255.255.255.0
broadcast=192.168.0.255
gateway=192.168.1.254
<pre>


change IP address details
<pre>
  # vi /etc/conf.d/network
vi /etc/systemd/system/network.service
</pre>
add the lines
<pre>
[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target


interface=eth0
[Service]
address=192.168.1.1
Type=oneshot
netmask=255.255.255.0
RemainAfterExit=yes
broadcast=192.168.0.255
EnvironmentFile=/etc/conf.d/network
gateway=192.168.0.254
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down


  # vi /etc/systemd/system/network.service
[Install]
WantedBy=multi-user.target
</pre>


[Unit]
<pre>
Description=Network Connectivity
systemctl disable dhcpcd@eth0.service
Wants=network.target
systemctl enable network.service
Before=network.target


[Service]
reboot
Type=oneshot
</pre>
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down


[Install]
<pre>
WantedBy=multi-user.target
vi /etc/resolv.conf
</pre>
add the lines
<pre>
domain mydomain.com
search mydomain.com
nameserver 192.168.1.254
</pre>


= Asterisk Pacgages =
<pre>
pacman -S gcc make hgsvn libxml2 libnewt sqlite subversion mysql spandsp speex
systemctl enable mysqld.service
systemctl start mysqld.service
<pre>


  # systemctl disable dhcpcd@eth0.service
== Secure mysql ==
  # systemctl enable network.service
<pre>
/usr/bin/mysql_secure_installation
</pre>


  # reboot
= Free Memory =
So Asterisk will compile we need to free as amny applictions as possible from memory
<pre>
systemctl stop ntpd.service
systemctl stop mysqld.service
</pre>


  #  vi /etc/resolv.conf
= Install Asterisk =
domain klaverstyn.com
Download and install Asterisk. you can refer to [Asterik Install] if required, but only Asterisk is required.
search klaverstyn.com
nameserver 192.168.13.1




install required packages for asterisk
== Set Asterisk to Automatic ==
  # pacman -S gcc make hgsvn libxml2 libnewt sqlite subversion mysql spandsp speex
<pre>
  # systemctl enable mysqld.service
vi /etc/rc.conf
  # systemctl start mysqld.service
</pre>
and add asterisk to DEAMONS


= Sendmail =
<pre>
pacman -R heirloom-mailx
rm /etc/mail.rc.pacsave
pacman -S ssmtp
</pre>


secure mysql
<pre>
  # /usr/bin/mysql_secure_installation
vi /etc/ssmtp/ssmtp.conf
</pre>
and add the lines
<pre>
mailhub=192.168.13.3
hostname=rpi.klaverstyn.com
FromLineOverride=yes
</pre>


stop services to free memory
= Install Apache =
ensure correct time
<pre>
  # systemctl stop ntpd.service
pacman -S apache php-apache php php-gd
  # systemctl stop mysqld.service
</pre>


install asterisk
<pre>
vi /etc/httpd/conf/httpd.conf
</pre>
and modify the following
<pre>
AllowOverride All
DirectoryIndex index.php index.html index.htm index.html.var
</pre>


<pre>
systemctl enable httpd.service
</pre>


Set asterisk service to start automatically
= Configure php =
  # vi /etc/rc.conf
<pre>
  add asteirsk to DEAMONS=
vi /etc/php/php.ini
</pre>
uncomment
<pre>
extension=mysqli.so
extension=mysql.so
</pre>


<pre>
vi /etc/httpd/conf/httpd.conf
</pre>
add the following lines in thier respective sections
<pre>
LoadModule php5_module modules/libphp5.so
Include conf/extra/php5_module.conf
AddHandler application/x-httpd-php .php
</pre>


Install Sendmail
uncomment the following lines
  # pacman -R heirloom-mailx
<pre>
  # rm /etc/mail.rc.pacsave
TypesConfig conf/mime.types
  # pacman -S ssmtp
MIMEMagicFile conf/magic
  # vi /etc/ssmtp/ssmtp.conf
</pre>
          mailhub=192.168.13.3
          hostname=rpi.klaverstyn.com
          FromLineOverride=yes


 
<pre>
install Apache, PHP and aCDR
vi /etc/httpd/conf/mime.types
  # pacman -S apache php-apache php php-gd
</pre>
 
add the following line
  # vi /etc/httpd/conf/httpd.conf
<pre>
        AllowOverride All
application/x-httpd-php5 php php5
        DirectoryIndex index.php index.html index.htm index.html.var
</pre>
 
  # systemctl enable httpd.service
 
  # vi /etc/php/php.ini
      uncomment
          extension=mysqli.so
          extension=mysql.so
 
  # vi /etc/httpd/conf/httpd.conf
          LoadModule php5_module modules/libphp5.so (add)
          Include conf/extra/php5_module.conf      (add)
          TypesConfig conf/mime.types               (uncomment)
          MIMEMagicFile conf/magic                  (uncomment)
          AddHandler application/x-httpd-php .php  (add)
 
  # vi /etc/httpd/conf/mime.types
          application/x-httpd-php5 php php5
    
    


  # systemctl start httpd.service
<pre>
systemctl start httpd.service
</pre>


Note: The web root is /srv/http/
'''Note'''': The web root is /srv/http/




Backup Script
= Backup Script =
  # pacman -S smbclient
Refer to [Astetrisk Backup] for the script itself.
<pre>
pacman -S smbclient
</pre>




= perl =
NOTE: to install the perl module requires more RAM that what is avaiazble on the 256MM model of the rPi.  Make sure you have a swap file otherwise this section will fail.
<pre>
pacman -S perl cpan libyaml perl-yaml libyaml perl-libwww sox mpg123
</pre>


(perl requires ram, ensure swapfile)
== Text to Speech ==
google text to speech
<pre>
  # pacman -S perl-yaml libyaml perl-libwww sox mpg123
perl -MCPAN -e "install Bundle::LWP"
  # perl -MCPAN -e "install Bundle::LWP"
perl -MCPAN -e "install CGI::Util"
  # perl -MCPAN -e "install CGI::Util"
</pre>


<pre>
wget https://github.com/zaf/asterisk-googletts/blob/master/googletts.agi
mv googletts.agi /var/lib/asterisk/agi-bin/
chmod 755 /var/lib/asterisk/agi-bin/googletts.agi
</pre>


fax2mail
== fax2mail ==
  # yum -y install perl cpan libyaml perl-YAML
<pre>
 
cd /usr/src
  # wget http://search.cpan.org/CPAN/authors/id/R/RO/ROSCH/mime-construct-1.11.tar.gz
wget http://search.cpan.org/CPAN/authors/id/R/RO/ROSCH/mime-construct-1.11.tar.gz
  # tar xzvf mime-construct-1.11.tar.gz
tar xzvf mime-construct-1.11.tar.gz
  # cd mime-construct-1.11
rm -f mime-construct-1.11.tar.gz
  # perl Makefile.PL
cd mime-construct-1.11
  # make install  
perl Makefile.PL
 
make install  
  # cd
cd..
  # perl -MCPAN -e "install Bundle::LWP"
</pre>
  # perl -MCPAN -e "install Proc::WaitStat"
  # perl -MCPAN -e "install MIME::Types"


<pre>
perl -MCPAN -e "install Bundle::LWP"
perl -MCPAN -e "install Proc::WaitStat"
perl -MCPAN -e "install MIME::Types"
</pre>








reference:
= Reference =
<pre>
https://wiki.archlinux.org/index.php/Systemd
https://wiki.archlinux.org/index.php/Systemd
https://wiki.archlinux.org/index.php/Configuring_Network
https://wiki.archlinux.org/index.php/Configuring_Network
Line 259: Line 334:
https://wiki.archlinux.org/index.php/LAMP#PHP
https://wiki.archlinux.org/index.php/LAMP#PHP
</pre>
</pre>
[[Category : Asterisk]]  [[Category : Rasberry Pi]]
[[Category : Asterisk]]  [[Category : Rasberry Pi]]

Revision as of 03:39, 26 October 2012

If you don't want to follow these instuctions and would prefer to download an image you can do so by downloading the image from Asterisk for Rasberry Pi Image.

The following instructions are based on Arch Linux ARM (archlinux-hf-2012-09-18.zip)

Write Image to SD Card

Using Win32DiskImager and the latest version of Arch Linux ARM from Rasberry Pi write the image to the SD card.

Once the image is written insert the Sd card into the Rasberry Pi and boot. The device will get an IP address from DHCP.

Expand Parition

Now that the device has booted log on and change the default partiion from 2 GB to the maximum partiion of your SD card.

fdisk /dev/mmcblk0
d (delete)
2 (partition 2)
n (new)
p (primary partition)
2 (partition 2 as previously deleted)
enter (accept default start sector)
enter (accept default end sector)
w (write changes)

reboot

Once the rPi has rebooted

resize2fs /dev/mmcblk0p2
reboot


Swap File

As the rPi has limited RAM, either 256 or 512 depending on your version we'll creat a swap file to allow appliction to use higher memory if required.

I would recommend allocating the size of the swap file to be that equal to the RAM size.

fallocate -l 256M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

The swap file is now active. We now need to ensure that it is used at boot.

vi /etc/fstab
<pre>
add the line to the file
<pre>
/swapfile none swap defaults 0 0

Update OS

pacman -Syu
reboot

Utilities

Install utilities to help with setup/administration

  # pacman -S initscripts vim mlocate zip unzip

vi to vim

pacman -R vi
ln -s /usr/bin/vim /usr/bin/vi

Create ll alias

vi /root/.profile
<pre>

add the line
<pre>
alias ll="ls -la"
= Enable Sound Card =
vi /etc/rc.conf
<pre>

add the line

<pre>
MODULES=(snd-bcm2835)

Regional settings

vi /etc/locale.gen (enable all AU and US, 4 lines)
vi /etc/rc.conf
locale-gen

Time Synchronisation

cp /usr/share/zoneinfo/Australia/Brisbane /etc/localtime
pacman -R openntpd
pacman -S ntp
ntpdate ntp.bri.connect.com.au

vi /etc/rc.conf
hwclock (remove)
ntpdate (add)

= Hostname =
<pre>
vi /etc/hostname
vi /etc/hosts

vi /etc/dhcpcd.conf
           add line: nohook resolv.conf
        remove line: nohook lookup-hostname

Network

vi /etc/conf.d/network
<pre>
add the lines
<pre>
interface=eth0
address=192.168.1.1
netmask=255.255.255.0
broadcast=192.168.0.255
gateway=192.168.1.254
<pre>

<pre>
vi /etc/systemd/system/network.service

add the lines

[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down

[Install]
WantedBy=multi-user.target
systemctl disable dhcpcd@eth0.service
systemctl enable network.service

reboot
vi /etc/resolv.conf

add the lines

domain mydomain.com
search mydomain.com
nameserver 192.168.1.254

Asterisk Pacgages

pacman -S gcc make hgsvn libxml2 libnewt sqlite subversion mysql spandsp speex
systemctl enable mysqld.service
systemctl start mysqld.service
<pre>

== Secure mysql ==
<pre>
/usr/bin/mysql_secure_installation

Free Memory

So Asterisk will compile we need to free as amny applictions as possible from memory

systemctl stop ntpd.service
systemctl stop mysqld.service

Install Asterisk

Download and install Asterisk. you can refer to [Asterik Install] if required, but only Asterisk is required.


Set Asterisk to Automatic

vi /etc/rc.conf

and add asterisk to DEAMONS

Sendmail

pacman -R heirloom-mailx
rm /etc/mail.rc.pacsave
pacman -S ssmtp
vi /etc/ssmtp/ssmtp.conf

and add the lines

mailhub=192.168.13.3
hostname=rpi.klaverstyn.com
FromLineOverride=yes

Install Apache

pacman -S apache php-apache php php-gd 
vi /etc/httpd/conf/httpd.conf

and modify the following

AllowOverride All
DirectoryIndex index.php index.html index.htm index.html.var
systemctl enable httpd.service

Configure php

vi /etc/php/php.ini

uncomment

extension=mysqli.so
extension=mysql.so
vi /etc/httpd/conf/httpd.conf

add the following lines in thier respective sections

LoadModule php5_module modules/libphp5.so
Include conf/extra/php5_module.conf
AddHandler application/x-httpd-php .php

uncomment the following lines

TypesConfig conf/mime.types
MIMEMagicFile conf/magic
vi /etc/httpd/conf/mime.types

add the following line

application/x-httpd-php5		php php5


systemctl start httpd.service

Note': The web root is /srv/http/


Backup Script

Refer to [Astetrisk Backup] for the script itself.

pacman -S smbclient


perl

NOTE: to install the perl module requires more RAM that what is avaiazble on the 256MM model of the rPi. Make sure you have a swap file otherwise this section will fail.

pacman -S perl cpan libyaml perl-yaml libyaml perl-libwww sox mpg123

Text to Speech

perl -MCPAN -e "install Bundle::LWP"
perl -MCPAN -e "install CGI::Util"
wget https://github.com/zaf/asterisk-googletts/blob/master/googletts.agi
mv googletts.agi /var/lib/asterisk/agi-bin/
chmod 755 /var/lib/asterisk/agi-bin/googletts.agi

fax2mail

cd /usr/src
wget http://search.cpan.org/CPAN/authors/id/R/RO/ROSCH/mime-construct-1.11.tar.gz
tar xzvf mime-construct-1.11.tar.gz
rm -f mime-construct-1.11.tar.gz
cd mime-construct-1.11
perl Makefile.PL
make install 
cd..
perl -MCPAN -e "install Bundle::LWP"
perl -MCPAN -e "install Proc::WaitStat"
perl -MCPAN -e "install MIME::Types"



Reference

https://wiki.archlinux.org/index.php/Systemd
https://wiki.archlinux.org/index.php/Configuring_Network
https://wiki.archlinux.org/index.php/Beginners%27_Guide
https://wiki.archlinux.org/index.php/LAMP#PHP