Asterisk for Raspberry Pi on ArchLinux

From KlavoWiki
Revision as of 01:41, 26 October 2012 by David (talk | contribs)
Jump to navigationJump to search

Note: Work In Progress

These instructions work for the Raberry Pi B-512 version with 512 MB RAM and not the 256MB version. You can follow these instruction for the 256MB version but you will have to skip the perl modules which is used for fax2mail and Google's text to speech.

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 sdcard and boot Rasberry Pi.

expand sdcard to use full capacity
  #  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

  # resize2fs /dev/mmcblk0p2
  # reboot

create swap file
  # fallocate -l 256M /swapfile
  # chmod 600 /swapfile
  # mkswap /swapfile
  # swapon /swapfile

  # vi /etc/fstab
       /swapfile none swap defaults 0 0  (add)



update operating system
  # pacman -Syu
  # reboot

Install utilities to help with setup/administration
  # pacman -S initscripts vim mlocate zip unzip


change vi to vim
  # pacman -R vi
  # ln -s /usr/bin/vim /usr/bin/vi

  # vim /root/.profile
         alias ll="ls -la"

enable sound card in Linux
  # vim /etc/rc.conf
        MODULES=(snd-bcm2835)

Regional settings
  # vim /etc/locale.gen (enable all AU and US lines)
  # vim /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

  # vim /etc/rc.conf
	remove hwclock
        add ntpdate

Edit hostnamer and network settings
  #  vim /etc/hostname
  #  vim /etc/hosts

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


change IP address details
  # vim /etc/conf.d/network

	interface=eth0
	address=192.168.1.1
	netmask=255.255.255.0
	broadcast=192.168.0.255
	gateway=192.168.0.254

  # vim /etc/systemd/system/network.service

	[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

  #  vim /etc/resolv.conf
	domain klaverstyn.com
	search klaverstyn.com
	nameserver 192.168.13.1


install required packages for asterisk
  # pacman -S gcc make hgsvn libxml2 libnewt sqlite subversion mysql spandsp speex
  # systemctl enable mysqld.service
  # systemctl start mysqld.service


secure mysql
  # /usr/bin/mysql_secure_installation

stop services to free memory
ensure correct time
  # systemctl stop ntpd.service
  # systemctl stop mysqld.service

install asterisk


Set asterisk service to start automatically
  # vim /etc/rc.conf
  add asteirsk to DEAMONS=


Install Sendmail
  # pacman -R heirloom-mailx
  # rm /etc/mail.rc.pacsave
  # pacman -S ssmtp
  # vi /etc/ssmtp/ssmtp.conf
          mailhub=192.168.13.3
          hostname=rpi.klaverstyn.com
          FromLineOverride=yes


install Apache, PHP and aCDR
  # pacman -S apache php-apache php php-gd 

  # vim /etc/httpd/conf/httpd.conf
         AllowOverride All
         DirectoryIndex index.php index.html index.htm index.html.var

  # systemctl enable httpd.service

  # vim /etc/php/php.ini
       uncomment
          extension=mysqli.so
          extension=mysql.so

  # vim /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)

  # vim /etc/httpd/conf/mime.types
          application/x-httpd-php5		php php5
  

  # systemctl start httpd.service

Note: The web root is /srv/http/


Backup Script
  # pacman -S smbclient



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


fax2mail
  # yum -y install perl cpan libyaml perl-YAML

  # 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
  # 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