Asterisk 1.2 auto install script for CentOS 4 and CentOS 5

I created an auto install script to install Asterisk 1.2 for CentOS 4 and CentOS 5. This script will install the following:

  • Zaptel
  • Libpri
  • Asterisk
  • Asterisk Addons
  • Open Source G729 Codec

Before running these script, you must install the some software needed to compile Asterisk.
For CentOS 4:

yum install gcc kernel kernel-devel bison openssl-devel

For CentOS 5:

yum install gcc kernel kernel-devel bison openssl-devel libtermcap-devel ncurses-devel

kernel-smp-devel (instead of kernel-devel) is necessary if you are using a dual core processor.

#!/bin/sh
#Asterisk Download page
ZAPTEL="http://downloads.digium.com/pub/zaptel/releases/zaptel-1.2.25.tar.gz"
ASTERISK="http://downloads.digium.com/pub/asterisk/releases/asterisk-1.2.28.tar.gz"
ASTERISKADDONS="http://downloads.digium.com/pub/asterisk/releases/asterisk-addons-1.2.8.tar.gz"
#Asterisk Package
ZAPPACKAGE="zaptel-1.2.25.tar.gz"
ASTPACKAGE="asterisk-1.2.28.tar.gz"
ASTADDONSPACKAGE="asterisk-addons-1.2.8.tar.gz"
#Asterisk Folder
ZAPFOLDER="zaptel-1.2.25"
ASTFOLDER="asterisk-1.2.28"
ASTADDONSFOLDER="asterisk-addons-1.2.8"
##########Do not edit from here##################################################
#################################################################################
echo "Downloading and extracting zaptel and asterisk source"
cd /usr/src
wget $ZAPTEL
wget $ASTERISK
wget $ASTERISKADDONS
tar -zxvf $ZAPPACKAGE
tar -zxvf $ASTPACKAGE
tar -zxvf $ASTADDONSPACKAGE

echo "Installing zaptel"
cd $ZAPFOLDER
make clean
make
make install
cd ..

echo "Installing asterisk"
cd $ASTFOLDER
make clean
make
make install
make samples
cd ..

echo "Installing lammp server"
echo "Installing rpmforge-release package"
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el4.rf.i386.rpm
yum --enablerepo=centosplus -y install httpd php php-gd php-mbstring php-mcrypt php-mysql mysql-client mysql-server mysql-devel phpmyadmin
 
echo "Installing asterisk-addons"
cd $ASTADDONSFOLDER
make clean
make
make install

echo "Loading ztdummy driver"
modprobe zaptel
modprobe ztdummy

echo "adding rules to /etc/rc.local"

echo "modprobe zaptel
modprobe ztdummy
asterisk -g" >> /etc/rc.local

echo "Downloading open source g729 codec"
cd /usr/lib/asterisk/modules/
wget http://asterisk.hosting.lv/bin12/codec_g729-ast12-gcc4-glibc-pentium4.so

echo "Running Asterisk"
asterisk -g

echo "***********************************************************************"
echo "*             INSTALLATION SUCCESSFUL                                 *"
echo "***********************************************************************"
echo "* You can test if Asterisk installed successfully using               *" 
echo "* asterisk -ncrvvv and start configuring your dial plan               *"
echo "***********************************************************************"
exit 0

Asterisk 1.2 auto install script for CentOS 4

#!/bin/sh
#Asterisk Download page
ZAPTEL="http://downloads.digium.com/pub/zaptel/releases/zaptel-1.2.25.tar.gz"
ASTERISK="http://downloads.digium.com/pub/asterisk/releases/asterisk-1.2.28.tar.gz"
ASTERISKADDONS="http://downloads.digium.com/pub/asterisk/releases/asterisk-addons-1.2.8.tar.gz"
#Asterisk Package
ZAPPACKAGE="zaptel-1.2.25.tar.gz"
ASTPACKAGE="asterisk-1.2.28.tar.gz"
ASTADDONSPACKAGE="asterisk-addons-1.2.8.tar.gz"
#Asterisk Folder
ZAPFOLDER="zaptel-1.2.25"
ASTFOLDER="asterisk-1.2.28"
ASTADDONSFOLDER="asterisk-addons-1.2.8"
##########Do not edit from here##################################################
#################################################################################
echo "Downloading and extracting zaptel and asterisk source"
cd /usr/src
wget $ZAPTEL
wget $ASTERISK
wget $ASTERISKADDONS
tar -zxvf $ZAPPACKAGE
tar -zxvf $ASTPACKAGE
tar -zxvf $ASTADDONSPACKAGE

echo "Installing zaptel"
cd $ZAPFOLDER
make clean
make
make install
cd ..

echo "Installing asterisk"
cd $ASTFOLDER
make clean
make
make install
make samples
cd ..

echo "Installing lammp server"
echo "Installing rpmforge-release package"
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm 
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm 
yum -y install httpd php php-gd php-mbstring php-mcrypt php-mysql mysql-client mysql-server mysql-devel phpmyadmin
 
echo "Installing asterisk-addons"
cd $ASTADDONSFOLDER
make clean
make
make install

echo "Loading ztdummy driver"
modprobe zaptel
modprobe ztdummy

echo "adding rules to /etc/rc.local"

echo "modprobe zaptel
modprobe ztdummy
asterisk -g" >> /etc/rc.local

echo "Downloading open source g729 codec"
cd /usr/lib/asterisk/modules/
wget http://asterisk.hosting.lv/bin12/codec_g729-ast12-gcc4-glibc-pentium4.so

echo "Running Asterisk"
asterisk -g

echo "***********************************************************************"
echo "*             INSTALLATION SUCCESSFUL                                 *"
echo "***********************************************************************"
echo "* You can test if Asterisk installed successfully using               *" 
echo "* asterisk -ncrvvv and start configuring your dial plan               *"
echo "***********************************************************************"
exit 0

Asterisk 1.2 auto install script for CentOS 5

You can download the script for CentOS 4 here and for CentOS 5 here.

To run the script just type:

./install-asterisk-1.2.el5.sh

If you run any of these script and it returns:

sh/bin bad interpreter: No such file or directory

Try to run:

dos2unix install-asterisk-1.2.el5.sh

Comments and suggestions are welcomed. Please help me improve these scripts.