Development

Differences between revisions 1 and 36 (spanning 35 versions)
Revision 1 as of 2011-06-12 17:36:14
Size: 8140
Editor: d114-78-50-78
Comment:
Revision 36 as of 2011-06-15 15:29:11
Size: 10206
Editor: d58-106-27-195
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
This is a raw script for review on the wiki, anyone is welcome to make this more presentable.

#installing freepbx and asterisk on natty
#only run this script once, fix all other errors manually if there are any, to stop adding too many lines to the required files edited
#This is a raw script for review on the wiki, anyone is welcome to make this more presentable and change anything about it.

#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'.
Line 6: Line 24:
Line 7: Line 26:
Line 8: Line 28:
Line 9: Line 30:
Line 10: Line 32:
Line 11: Line 34:
Line 13: Line 37:
sudo -i
Line 14: Line 40:
Line 15: Line 42:
#change to your sudo password
export SUDO_PW=temppwd
Line 18: Line 44:
Line 19: Line 46:
Line 20: Line 48:
Line 21: Line 50:
Line 22: Line 52:
Line 23: Line 54:
#sudo -i
##${SUDO_PW}
##http://ubuntuforums.org/archive/index.php/t-19236.html

#remove the following comments if updatedb and locate don't work, this version doesn't include 'find', so maybe use a later version, the current is 4.4.6

#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
Line 28: Line 58:
Line 29: Line 60:
Line 30: Line 62:
Line 31: Line 64:
Line 32: Line 66:
Line 33: Line 68:
Line 34: Line 70:
Line 35: Line 72:
Line 36: Line 74:
Line 37: Line 76:
Line 39: Line 79:
#this is handy for finding things if you need later, using 'locate'
updatedb
#apt-get -y install findutils

#this is handy for finding things if you need later, using 'locate' and 'find'

#
updatedb
Line 43: Line 86:
Line 44: Line 88:
Line 45: Line 90:
Line 46: Line 92:
Line 47: Line 94:
Line 48: Line 96:
Line 49: Line 98:
Line 53: Line 103:
Line 54: Line 105:
Line 55: Line 107:
Line 56: Line 109:
Line 59: Line 113:
Line 60: Line 115:
Line 61: Line 117:
Line 62: Line 119:
Line 65: Line 123:
Line 66: Line 125:
Line 69: Line 129:
Line 70: Line 131:
Line 71: Line 133:
Line 72: Line 135:
Line 73: Line 137:
Line 76: Line 141:
Line 77: Line 143:
Line 78: Line 145:
Line 79: Line 147:
Line 82: Line 151:
Line 85: Line 155:
Line 88: Line 159:
Line 90: Line 162:
Line 91: Line 164:
Line 92: Line 166:
Line 93: Line 168:
Line 94: Line 170:
Line 95: Line 172:
Line 96: Line 174:
Line 99: Line 178:
Line 105: Line 185:
Line 106: Line 187:
Line 107: Line 189:
Line 110: Line 193:
Line 111: Line 195:
Line 112: Line 197:
Line 115: Line 201:
Line 118: Line 205:
Line 119: Line 207:
Line 120: Line 209:
Line 121: Line 211:
Line 122: Line 213:
Line 123: Line 215:
Line 124: Line 217:
Line 125: Line 219:
Line 134: Line 229:
Line 135: Line 231:
Line 138: Line 235:
Line 139: Line 237:
Line 145: Line 244:
Line 146: Line 246:
Line 151: Line 252:
Line 152: Line 254:
Line 153: Line 256:
Line 156: Line 260:
Line 157: Line 262:
Line 158: Line 264:
Line 159: Line 266:
Line 160: Line 268:
Line 161: Line 270:
Line 166: Line 276:
Line 172: Line 283:
Line 175: Line 287:
Line 178: Line 291:
Line 181: Line 295:
Line 182: Line 297:
Line 183: Line 299:
Line 184: Line 301:
Line 185: Line 303:
Line 186: Line 305:
Line 187: Line 307:
Line 188: Line 309:
Line 189: Line 311:
Line 192: Line 315:
Line 193: Line 317:
Line 194: Line 319:
Line 195: Line 321:
Line 198: Line 325:
Line 199: Line 327:
Line 200: Line 329:
Line 201: Line 331:
Line 202: Line 333:
Line 203: Line 335:
Line 204: Line 337:
Line 205: Line 339:
Line 206: Line 341:
Line 207: Line 343:
Line 210: Line 347:
Line 213: Line 351:
Line 214: Line 353:
Line 215: Line 355:
Line 216: Line 357:
Line 217: Line 359:
Line 218: Line 361:
Line 219: Line 363:
Line 222: Line 367:
./install_amp
./install_amp --username=root --password={MYSQL_ROOT_PW}
Line 225: Line 371:
Line 228: Line 375:
Line 230: Line 378:
echo "you're done, go to your browser URL and type in 'localhost:/admin', username is admin, password is admin"

#if you get the error Unable to connect to remote asterisk (does /var/run/asterisk/asterisk/asterisk/asterisk/asterisk/asterisk/asterisk/asterisk/asterisk/asterisk/asterisk.ctl exist?)
# I'll post a solution to that soon, every time you run the script it adds another 'asterisk' to the run file, which is obviously not right
#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"

#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

#wget https://launchpad.net/ubuntu/+source/findutils/4.4.0-2ubuntu2/https://launchpad.net/ubuntu/+archive/primary/+files/findutils_4.4.0.orig.tar.gz

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