Install Asterisk on an O2 Joggler

I am using a 4GB MicroSDHC card reader with a 4GB micro sdhc card inserted. This is a tiny device and can be barely seen when inserted into the Joggler USB port. Prior to starting the install of Asterisk this was the layout.
If you have not already installed Ubuntu, you will need to use the Install Ubuntu on the Joggler link.
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 3588580 2090120 1317600 62% /
udev 251876 336 251540 1% /dev
none 251876 1120 250756 1% /dev/shm
none 251876 104 251772 1% /var/run
none 251876 0 251876 0% /var/lock
none 251876 0 251876 0% /lib/init/rw
/dev/sda1 65045 10603 54442 17% /media/BOOTV13
After installation of Asterisk and Freepbx
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 3588580 2366644 1041076 70% /
udev 251876 336 251540 1% /dev
none 251876 1200 250676 1% /dev/shm
none 251876 116 251760 1% /var/run
none 251876 0 251876 0% /var/lock
none 251876 0 251876 0% /lib/init/rw
/dev/sda1 65045 10603 54442 17% /media/BOOTV13
To install you can copy and paste the following - beware of comments (in red) and where there are lines, you will need to complete to that point then start the next block.
Don't set passwords for mysql (just hit enter) and enter 127.0.0.1 when
prompted for ip during freepbx install. I changed my web root from
/var/www/html to /var/www
From a terminal or ssh login use :
sudo su (enter your password)
I needed to create a user and group called asterisk
adduser --system asterisk
dpkg-reconfigure dash (choose No)
/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
aptitude remove apparmor apparmor-utils
apt-get -y install apache2 php5-mysql libapache2-mod-php5 mysql-server ntp (asked 3 times for password - enter rtn)
a2enmod php5
sed -i "s/magic_quotes_gpc = On/magic_quotes_gpc = Off/" /etc/php5/apache2/php.ini
sed -i "s/memory_limit = 16M/memory_limit = 100M/" /etc/php5/apache2/php.ini
sed -i "s/iso-8859-1/utf8/" /etc/php5/apache2/php.ini
sed -i "s/;default_charset/default_charset/" /etc/php5/apache2/php.ini
mkdir /var/run/asterisk
mkdir /var/log/asterisk
chown asterisk:asterisk /var/log/asterisk
apt-get -y install asterisk asterisk-mysql asterisk-mp3 php-db php5-gd php-pear sox curl asterisk-sounds-extra (Asks for ITU code - enter 44 if in UK etc)
adduser www-data asterisk
sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=asterisk/" /etc/apache2/envvars
sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=asterisk/" /etc/apache2/envvars
usermod -s /bin/bash asterisk
cd /usr/local/src
wget http://mirror.freepbx.org/freepbx-2.7.0.tar.gz (or latest version)
tar xvfz freepbx*
cd freepbx*
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql -vv -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'"
mysql -vv -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'"
mysql -vv -e "flush privileges"
cp /etc/asterisk/modules.conf /etc/asterisk/modules.conf.old
pear install DB
./install_amp (enter 5 rtns, followed by /var/www for web root, followed by IP address of netbook + 4 rtns)
rm -rf /etc/asterisk/modules.conf
mv /etc/asterisk/modules.conf.old /etc/asterisk/modules.conf
sed -i "s/BACKGROUND=0/BACKGROUND=1/" /usr/sbin/safe_asterisk
ln -s /var/lib/asterisk/sounds/custom /usr/local/share/asterisk/sounds/
chown asterisk:asterisk -R /usr/share/asterisk
chmod 755 -R /usr/share/asterisk
chown -R asterisk:asterisk /usr/local/share/asterisk/
update-rc.d -f asterisk remove
cat >/etc/rc.local << EOF
mkdir /var/log/apache2
mkdir /var/log/asterisk
chown asterisk:asterisk /var/log/asterisk
chmod 775 /var/run
/usr/sbin/apache2ctl graceful
/usr/local/sbin/amportal start
exit 0
EOF
chmod 755 /etc/rc.local
mv /usr/local/share/asterisk/sounds /usr/local/share/asterisk/sounds.old
ln -s /var/lib/asterisk/sounds/custom /usr/local/share/asterisk/sounds
cd /tmp
apt-get install linux-headers-2.6.31-20-generic
wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
tar xfz zaptel-1.4-current.tar.gz
cd `find . -name "zaptel-1.4.*" -print`
./configure
make install config (Got errors here - but seems to be working...)
rm /var/log/asterisk/full
ln -s /dev/null /var/log/asterisk/full
reboot
With a bit of luck your system should reboot and both asterisk and apache2 are running :)
While setting up Asterisk/Freepbx I noticed that the creation of recordings was working fine, but when the recording was used in an IVR there was just silence. After research I found that I needed to alter some folder locations (thanks to clarknova at freepbx) so built solution into script.
A further problem was that although I could create a conference, whenever I dialed the conference number I always got the message "That is not a valid conference number". Again with further reading this is normally due to zaptel driver not being installed. I thought that as I had no zaptel hardware, it was not necessary to install zaptel but it appears I was wrong :(