Free Pbx Installation Script
#!/bin/bash
#
#Install mysql
#run the script script by sudo su or with root privilege
sudo apt-get update
sudo apt-get install -y mysql-server
#
#installing the pre-dependencies
#
sudo apt-get install -y build-essential linux-headers-`uname -r` openssh-server bison flex apache2 php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient15-dev mpg123 libxml2-dev
#
#Compile and install dahdi;
#
tar xvf dahdi-linux-complete-2.2.1+2.2.1.tar.gz
cd dahdi-linux-complete-2.2.1+2.2.1
make all && make install && make config
#
#libpri compilation and install:
#
cd ..
tar xvf libpri-1.4.10.2.tar.gz
cd libpri-1.4.10.2
make && make install
#
#installing the free pbx
#
cd ..
tar xvf asterisk-1.6.2.6.tar.gz
cd asterisk-1.6.2.6
./configure
make && make install
#
#As before lets install the sample files
#
make samples
#
#install sound in free pbx
#
cd /var/lib/astersik/sounds
wget -O - http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-gsm-current.tar.gz | tar xvfz -
#
# We create the user "asterisk" and
#add the apache user to the "asterisk" group
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
#
#
#The start up script
cd /etc/init.d/
wget http://randystech.com/downloads/asterisk
chmod +x asterisk
update-rc.d asterisk defaults
#We are almost done. Now we are going to install FreePBX, the graphical interface that we will install
#to manage Asterisk
cd /usr/src/
wget -O - http://mirror.freepbx.org/freepbx-2.7.0.tar.gz | tar xvfz -
cd freepbx-2.7.0/
#
#Copy amportal.conf configuration file to /etc/:
#
cp amportal.conf /etc/
#set the database password here
#when you are running the shell script
# creating user astrick in mysql with password 4321
export ASTERISK_DB_PW=4321
export MYSQL_ROOT_PW=1234
mysqladmin -u root -p${MYSQL_ROOT_PW} create asterisk
mysqladmin -u root -p${MYSQL_ROOT_PW} create asteriskcdrdb
mysql -u root -p${MYSQL_ROOT_PW} asterisk < SQL/newinstall.sql
mysql -u root -p${MYSQL_ROOT_PW} asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql -u root -p${MYSQL_ROOT_PW} <<-END_PRIVS
GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY "${ASTERISK_DB_PW}";
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY "${ASTERISK_DB_PW}";
flush privileges;
END_PRIVS
#
#And slightly modify the settings in /etc/amportal.conf
#
sed -i "s/# \(AMPDBUSER=.*\)/\1/" /etc/amportal.conf
sed -i "s/# \(AMPDBPASS=\).*/\1${ASTERISK_DB_PW}/" /etc/amportal.conf
sed -i "s@\(AMPWEBROOT=\).*@\1/var/www/@" /etc/amportal.conf
sed -i "s@\(FOPWEBROOT=\).*@\1/var/www/panel@" /etc/amportal.conf
sed -i "s@\(FOPWEBADDRESS=\).*@PUTIPADDRESS@" /etc/amportal.conf
#
#Adjust some PHP.ini settings related to the use of memory
#
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
#
#Change the permissions of a series of directories:
#
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R www-data.asterick /var/www/
#
#We enable the asterisk configuration as it is indicated in /etc/asterisk/asterisk.conf by removing the
#trailing characters in the first line:
#
sed -i '1 s/\(\[directories\]\).*/\1/' /etc/asterisk/asterisk.conf
#
# now install the free pbx
#
./start_asterisk start
./install_amp
#restart the apache and dahdi
#
/etc/init.d/apache2 restart
/etc/init.d/dahdi restart
#
#create a link
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal start
No comments:
Post a Comment