Development
10186
Comment:
|
10206
|
Deletions are marked like this. | Additions are marked like this. |
Line 13: | Line 13: |
#The (unconfirmed) fix is to Disable module Routepermissions (in FreePBX module management in admin site), it is not compatible with FreePBX 2.8. See http://www.freepbx.org/v2/ticket/4400 | #The (unconfirmed) fix is here. See http://www.freepbx.org/v2/ticket/4400. Or see http://www.fonality.com/trixbox/forums/trixbox-forums/open-discussion/reload-failed-because-retrieve-conf-encountered-error-1 |
#installing FreePBX and Asterisk on Natty (Tested, 11.04), Maverick 10.10, Lucid 10.04, Oneiric 11.10 (Untested)
#Revision 1.0 by Mick Petrick (please add your revision number and date following)
#updated 13 June 2011
#known bugs (see fix following):
#when saving configuration changes to the trunk, getting an error: Unable to connect to manager localhost:5038 (111): Connection refused [FATAL] Unable to connect to Asterisk Manager from /var/lib/asterisk/bin/retrieve_conf, aborting.
#The (unconfirmed) fix is here. See http://www.freepbx.org/v2/ticket/4400. Or see http://www.fonality.com/trixbox/forums/trixbox-forums/open-discussion/reload-failed-because-retrieve-conf-encountered-error-1
#if you don't want FreePBX installed then you can use the Lucid script at https://wiki.ubuntu.com/AsteriskOnUbuntu/Current
#if you run this script more than once and get the dreaded "Unable to connect to remote asterisk (does /var/run/asterisk/asterisk/asterisk.ctl exist?)" error you'll need to check /etc/asterisk/asterisk.conf to say 'astrundir => /var/run/asterisk'.
#after running this script, if you need to debug try 'asterisk -c' and follow the log, also try 'tail /var/log/asterisk/messages' and of course the standard 'asterisk -vvvvvr' or 'safe_asterisk'.
#this is an untested script which I hope should be accurate
#it's best to read through this script before running it
#it's assumed that you're running from 'sudo -i' or su user
#better still, copy and paste each section in to your command line
#if any part of the install doesn't work for any reason, try 'apt-get update' and try again
#this doesn't include configuring any zaptel drivers, to install XP100P see https://wiki.ubuntu.com/AsteriskOnUbuntu/Current
#to get more info on how to install asterisk-sounds if not installed, etc see https://wiki.ubuntu.com/AsteriskScriptOnHardy and look at the script https://wiki.ubuntu.com/AsteriskScriptOnHardy?action=AttachFile&do=view&target=installZaptelAsteriskFreePBX_1.2.sh
sudo -i
#change to your preferred MySQL password
export MYSQL_ROOT_PW=peachy2keen
#change to freepbx version found at http://www.freepbx.org/download-freepbx
export FREEPBX_VERSION=2.9.0
export ASTERISK_DB_PW=amp109
#put in your ip address here, use 'ifconfig' to find
#if you're using dhcp ip, then it's best to use static if you can and know how and it works
export IP_ADDRESS=10.1.1.16
#remove the following comments if updatedb and locate don't work, this version doesn't include 'find', but running 'apt-get install findutils' after the install reinstalls it
#apt-get remove findutils
#mkdir /usr/src
#cd /usr/src
#tar xvf findutils_4.4.0.orig.tar.gz
#cd findutils_4.4.0.orig.tar.gz
#chmod 777 configure
#./configure
#./make
#make install
#apt-get -y install findutils
#this is handy for finding things if you need later, using 'locate' and 'find'
#updatedb
# ensure package directory up to date and system upgraded
apt-get -y update
apt-get -y upgrade
apt-get -y install asterisk sox asterisk-mysql asterisk-mp3
# you can test asterisk at this point by typing 'asterisk -vvvvr'
# if it's working you'll see a prompt '>'
# type in 'quit' to get back to the command line
#I'm not sure if the following line is required, but it can't hurt apt-get -y update
# retrieve utilities and set debconf to noninteractive front-end
apt-get -y install debconf-utils
debconf-set-selections <<CONF_EOF
debconf debconf/frontend select noninteractive
CONF_EOF
# install mysql server
# use peachy2keen as the password when prompted
apt-get -y install mysql-server
#if mysql is already installed, or a different password was used
#mysqladmin -u root password ${MYSQL_ROOT_PW}
debconf-set-selections <<CONF_EOF
debconf debconf/frontend select Dialog
CONF_EOF
# install packages needed beyond base install with openssh server
apt-get -y install linux-headers-uname -r
apt-get -y install make bison flex g++ gcc apache2 php5
apt-get -y install php5-cli php5-mysql php-pear php-db php5-gd curl
apt-get -y install sox libncurses5-dev libssl-dev libmysqlclient15-dev
apt-get -y install php-pear
#the following should already be installed
apt-get -y install apache2
apt-get -y install php5
apt-get -y install libapache2-mod-php5
/etc/init.d/apache2 restart
apt-get update
pear install DB
#run this line again
apt-get install php5-mysql
#before configuring asterisk, save the current settings
cd /etc mkdir backupasterisk
cp -r asterisk backupasterisk
cp -r /var/run/asterisk backupasterisk
#get freepbx
cd /usr/src
wget http://mirror.freepbx.org/freepbx-${FREEPBX_VERSION}.tar.gz
tar -xvf freepbx-${FREEPBX_VERSION}.tar.gz
cd freepbx-${FREEPBX_VERSION}
#remove the asterisk password so the rest of the script works more easily
passwd --delete asterisk
#the following I got from https://wiki.ubuntu.com/AsteriskScriptOnHardy
# create asterisk user and group, adding to www-data group for apache server
#ignore any error on the following line
adduser asterisk --disabled-password --gecos "asterisk PBX"
adduser www-data asterisk
# fix up apache configuration to run as asterisk user
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf-orig
sed -i "s/\(^User *\)\(.*\)/\1asterisk/" /etc/apache2/apache2.conf
sed -i "s/\(^Group *\)\(.*\)/\1asterisk/" /etc/apache2/apache2.conf
# patch safe_asterisk script to use bash
sed -i "s|#!/bin/sh|#!/bin/bash|" /usr/sbin/safe_asterisk
# add asterisk startup item
cat > /etc/init.d/asterisk <<-END_STARTUP
#!/bin/bash
set -e
set -a
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Asterisk"
NAME=amportal
DAEMON=/usr/sbin/\$NAME
test -x \$DAEMON || exit 0
d_start() {
- amportal start
}
d_stop() {
- amportal stop
}
d_reload() {
- amportal restart
}
case "\$1" in
start)
- echo -n "Starting \$DESC: \$NAME" d_start echo "."
;;
stop)
- echo -n "Stopping \$DESC: \$NAME" d_stop echo "."
;;
restart|force-reload)
- echo -n "Restarting \$DESC: \$NAME" d_stop sleep 10 d_start echo "."
;;
*)
echo "Usage: \$SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3
;;
esac
exit 0
END_STARTUP
chmod 755 /etc/init.d/asterisk
update-rc.d asterisk defaults 90 10
# add dummy timing device for asterisk
modprobe ztdummy
# setup databases for freepbx use
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
# reconfigure php for freepbx
cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini-orig
sed -i "s/\(upload_max_filesize *= *\)\(.*\)/\120M/" /etc/php5/apache2/php.ini
sed -i "s/\(memory_limit *= *\)\(.*\)/\1100M/" /etc/php5/apache2/php.ini
sed -i "s/\(magic_quotes_gpc *= *\)\(.*\)/\1Off/" /etc/php5/apache2/php.ini
# fix up directory use and permissions for asterisk
mkdir /var/run/asterisk
chown asterisk:asterisk /var/run/asterisk
chown asterisk:asterisk -R /etc/asterisk
chown asterisk:asterisk -R /var/lib/asterisk
# chmod a+x /var/lib/asterisk/bin/*
chown asterisk:asterisk -R /var/log/asterisk
chown asterisk:asterisk -R /var/spool/asterisk
chown asterisk:asterisk -R /var/www
sed -i "s/\[directories\](!) .*/[directories]/" /etc/asterisk/asterisk.conf
sed -i "s|astrundir *=> */var/run|astrundir => /var/run/asterisk|" /etc/asterisk/asterisk.conf
# start asterisk
./start_asterisk start
# configure amportal
cp amportal.conf /etc/amportal.conf
sed -i "s/# \(AMPDBUSER=asteriskuser\) */\1/" /etc/amportal.conf
sed -i "s/# \(AMPDBPASS=\).*/\1${ASTERISK_DB_PW}/" /etc/amportal.conf
sed -i "s|\(AMPWEBROOT=\)/var/www/html|\1/var/www|" /etc/amportal.conf
sed -i "s|\(FOPWEBROOT=\)/var/www/html/panel|\1/var/www/panel|" /etc/amportal.conf
sed -i "/#AMPWEBADDRESS=192.168.1.101/d" /etc/amportal.conf
sed -i "s/AMPWEBADDRESS=/AMPWEBADDRESS=${IP_ADDRESS}/" /etc/amportal.conf
# install amp
./install_amp --username=root --password={MYSQL_ROOT_PW}
# start apache web server
/etc/init.d/apache2 restart
# start amportal
amportal start
#current known bug 1 (with fix following): when I run 'grep -r sqlite /etc/asterisk/*' it shows I'm running sqlite, when I run 'asterisk -c' it reports 'Registered Config Engine sqlite' and '.PostgreSQL RealTime: Failed to connect database asterisk on 127.0.0.1: '. Obviously I want to configure for MySQL not Postgres.
#current known bug 2: (with fix following) the message log reports 'manager.c: 127.0.0.1 failed to authenticate as admin'. This may very well be related to known bug number 1.
#for the bug fixes a few edits to the config files should do the trick. Alternatively the Hardy install for Asterisk script works quite well. https://wiki.ubuntu.com/AsteriskScriptOnHardy
# to fix these bugs I did the following
rm -r /etc/asterisk
apt-get -y update
apt-get upgrade
apt-get remove asterisk
apt-get -y install asterisk
apt-get -y install --reinstall asterisk
#run installamp again
./install_amp --username=root --password={MYSQL_ROOT_PW}
amportal start
echo "you're done, go to your browser URL and type in 'localhost/admin', username is admin, password is admin"
AsteriskOnUbuntu/Development (last edited 2011-06-15 19:28:27 by d58-106-27-195)