-MAIN-MENU-  
Appal Home
Appal.org
  -MAIN-MENU-  
Search The Website
-*-

Script to make an Asterisk+FreePBX VOIP/Telco switch under Debian Linux (2013)   Posted: March 27, 2014
This script will make a Debian Stable Linux server that runs Asterisk and FreePBX. Before you run the script, edit it to set the Asterisk, Asterisk Addons, DAHDI, LibPRI and FreePBX versions (e.g.: VER_ASTERISK) to install. It may need some other adjustments, as it was last updated in 2013, (YMMV).

Installer for Asterisk + FreePBX on a Debian machine

Usage: dfreepbx [ -x --xpedite \| -s --setup \| -f --fetch \| -i --install \| -p --passwords \| -h --help]

Example: dfreepbx -x -f -i -p

Xpedite: Fast mode, skips most 'Press Enter' prompts.

Setup: (use 1x only) installs the build and development tools

Fetch: Download and unpack fresh source files.

Install: Build, Install and Configure source files.

Passwords: Set the security and passwords.

Old .conf files are in .conf-orig. Run as root, the script requires access to the Internet. NB: Do _NOT_ change any default passwords UNTIL Part 3: Setting Up Security (invoked with -p). After using -p, set the default password for the root mysql user. By default it is null. From MySQL, invoke: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');

Once installed, run asterisk+freepbx with: amportal start

Edit this script to set the following versions and filenames:

-> Asterisk = ${VER_ASTERISK},

-> Dahdi = ${VER_DAHDI}

-> Libpri = ${VER_LIBPRI},

-> Addons = ${VER_ADDONS}

-> FreePBX = ${VER_FREEPBX} (+ apache2 php5 mysql5)

-> Log File = ${LOGFILE}



#!/bin/bash
#dfreepbx v0.5 2010.03.30
# == CONTRIBUTERS ==
# Yoann QUERET - yoann@queret.net, https://www.queret.net/asterisk/
# Serge Berney - s.berney@kinonline.net
# Neil Stone - neil@flashtek-uk.com
# W.S. Herrick - p0g0 at madwifi-project.org
#======================================================================
# Use dfreepbx.sh as root, run as shown:
# chmod 766 dfreepbx.sh
# ./dfreepbx.sh -x -s -f -i -p
#
# The script manages the installation of packages, tools, source and configuration of freepbx.
# Except for the optional -x, the parameters are ordered as -s then -f then -i then -p.
# Examples:
# dfreepbx.sh -x -s
# dfreepbx -x -f
# dfreepbx.sh -i -p
#
# Once the entire "-s -f -i -p" sequence has been completed 1x, you can then use the options in any order.
#========================================================================
#

LOGFILE="/usr/src/debian-freepbx.log";
echo "Start" | tee ${LOGFILE}
VER_ASTERISK="1.6.2.4"; # 11.5.0
VER_ADDONS="1.6.2.0"; # 1.6.2.4
VER_DAHDI="2.2.1+2.2.1"; #2.7.0+2.7.0
VER_LIBPRI="1.4.10.2"; # 1.4.14
VER_FREEPBX="2.6.0"; # 2.10.0

VER_KERNEL=`uname -r`
DEBIAN_VERSION=`cat /etc/debian_version`
err_state="0"
fast="F"


function fr_setup
{
clear
echo "1x Set up: Essential Build, Security and Development files" | tee -a ${LOGFILE}
echo "Run once after a fresh debian install."
echo "Press Enter to continue, Ctrl-C Quits"
read
apt-get update
cp -a -x /etc/shorewall /etc/shorewall.orig
cp -a -x /etc/ppp /etc/ppp.orig
apt-get install -y build-essential dbview zip debian-keyring gcc-4.3-locales autoconf automake1.9 libtool bison gdb mc jed iptraf equivs shorewall shorewall-doc lynx pppoe pppstatus pppoeconf xdialog modconf ppp chkrootkit unhide clamav xserver-xorg-core xorg kde-core synaptic sux wireshark tshark ntpdate gpm kdiff3 tkdiff | tee -a ${LOGFILE}
# rkhunter
}

function fr_fetch
{
clear
echo "#################################################################"
echo "# PART 1 - Installation of asterisk " | tee -a ${LOGFILE}
echo "### ---------------------------------------------------------- ##"
echo "# Press to continue "
echo "#################################################################"
if [ "$fast" != "T" ]; then
read
fi ##@@

echo "+----------------------------------------------------------------+"
echo "| Downloading the sources to /tmp/asterisk/ |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
mkdir /tmp/asterisk/
wget -c https://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-${VER_ASTERISK}.tar.gz -O /tmp/asterisk/asterisk-${VER_ASTERISK}.tar.gz | tee -a ${LOGFILE}
wget -c https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/dahdi-linux-complete-${VER_DAHDI}.tar.gz -O /tmp/asterisk/dahdi-linux-complete-${VER_DAHDI}.tar.gz | tee -a ${LOGFILE}
wget -c https://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-${VER_LIBPRI}.tar.gz -O /tmp/asterisk/libpri-${VER_LIBPRI}.tar.gz | tee -a ${LOGFILE}
wget -c https://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-${VER_ADDONS}.tar.gz -O /tmp/asterisk/asterisk-addons-${VER_ADDONS}.tar.gz | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo "| Constructing compile environment |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
aptitude update

aptitude -y install g++ libncurses5-dev linux-headers-${VER_KERNEL} sqlite libnewt-dev \
libusb-dev zlib1g-dev libmysqlclient15-dev libsqlite0-dev libxml2-dev openssh-server | tee -a ${LOGFILE}


echo "+----------------------------------------------------------------+"
echo "| Configuration of kernel sources |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/
ln -s /usr/src/linux-headers-${VER_KERNEL} /usr/src/linux
echo "+----------------------------------------------------------------+"
echo "| Decompresion of sources in /usr/src/ |"
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/
tar zxvf /tmp/asterisk/asterisk-${VER_ASTERISK}.tar.gz | tee -a ${LOGFILE}
tar zxvf /tmp/asterisk/asterisk-addons-${VER_ADDONS}.tar.gz | tee -a ${LOGFILE}
tar zxvf /tmp/asterisk/libpri-${VER_LIBPRI}.tar.gz | tee -a ${LOGFILE}
tar zxvf /tmp/asterisk/dahdi-linux-complete-${VER_DAHDI}.tar.gz | tee -a ${LOGFILE}
echo "Fetch and Install Apache and MySql servers" | tee -a ${LOGFILE}
aptitude update
aptitude install -y apache2 php5 php5-cli mysql-server-5.0 php-pear php5-mysql php-db libapache2-mod-php5 php5-gd php5-curl mpg123 | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Downloading the FreePBX sources to /tmp/freepbx/ |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
mkdir /tmp/freepbx/
wget https://mirror.freepbx.org/freepbx-${VER_FREEPBX}.tar.gz -O /tmp/freepbx/freepbx-${VER_FREEPBX}.tar.gz | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Extracting the sources for freepbx in /usr/src/ |"
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src
tar zxvf /tmp/freepbx/freepbx-${VER_FREEPBX}.tar.gz | tee -a ${LOGFILE}
echo " End of Step One: Fetching the Source Files." | tee -a ${LOGFILE}
#EOF function fetch
}

function fr_install
{
echo "+----------------------------------------------------------------+"
echo "| Install Step: Building from the source |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@


echo "+----------------------------------------------------------------+"
echo "| Compilation of DAHDI |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/dahdi-linux-complete-${VER_DAHDI}
make | tee -a ${LOGFILE}
make install | tee -a ${LOGFILE}
make config | tee -a ${LOGFILE}


echo "+----------------------------------------------------------------+"
echo "| Compilation of libpri |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/libpri-${VER_LIBPRI}
make install | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Compilation of Asterisk |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/asterisk-${VER_ASTERISK}
./configure | tee -a ${LOGFILE}
echo "== ATTENTION =="
echo "If you do not understand this question, choose NO,"
echo "The standard options will be used."
echo "--"

key = "n" ##@@

if [ "$fast" != "T" ]; then
read -n 1 -p "Would you like to select which Asterisk modules to install ? [y/N]" key
fi ##@@

if [ $key == "y" ]; then
make menuconfig
fi
make | tee -a ${LOGFILE}
make install | tee -a ${LOGFILE}
make samples | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Compilation of Asterisk addons |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/asterisk-addons-${VER_ADDONS}
./configure | tee -a ${LOGFILE}

echo "== ATTENTION =="
echo "If you do not understand this question, choose NO,"
echo "The standard options will be used."
echo "--"
key = "n" ##@@
if [ "$fast" != "T" ]; then
read -n 1 -p "Would you like to select which Asterisk addons modules to install ? [y/N]" key
fi ##@@

if [ $key == "y" ]; then
make menuconfig
fi
make install | tee -a ${LOGFILE}


echo "+----------------------------------------------------------------+"
echo "| Symbolic Links (Modules) |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
##ln -s /lib/modules/$VER_KERNEL/ /lib/modules/`uname -r`/asterisk
depmod | tee -a ${LOGFILE}

echo "#################################################################"
echo "# Installation of files : FINISHED " | tee -a ${LOGFILE}
echo "### ---------------------------------------------------------- ##"
echo "# Press to continue "
echo "#################################################################"
if [ "$fast" != "T" ]; then
read
fi ##@@


clear
echo "#################################################################"
echo "# Set Default Configurations," | tee -a ${LOGFILE}
echo "Prior .conf files are copied to .conf-orig " | tee -a ${LOGFILE}
echo "### ---------------------------------------------------------- ##"
echo "# Press to continue "
echo "#################################################################"
if [ "$fast" != "T" ]; then
read
fi ##@@


echo "+----------------------------------------------------------------+"
echo "| Changing the maximum upload, memory limit and magic_quotes_gpc |"
echo "| in PHP |"
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
sed -i-orig -e "s/\(upload_max_filesize *= *\)\(.*\)/\120M/" \
-e "s/magic_quotes_gpc\ =\ On/magic_quotes_gpc\ =\ Off/" \
-e "s/memory_limit\ =\ 16M/memory_limit\ =\ 100M/" \
/etc/php5/apache2/php.ini | tee -a ${LOGFILE}
sed -i-orig -e "s/\(upload_max_filesize *= *\)\(.*\)/\120M/" \
-e "s/magic_quotes_gpc\ =\ On/magic_quotes_gpc\ =\ Off/" \
-e "s/memory_limit\ =\ 16M/memory_limit\ =\ 100M/" \
/etc/php5/cli/php.ini | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Music on hold (Symbolic link) |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

echo "+----------------------------------------------------------------+"
echo "| Creating the user and setting permissions for user 'asterisk' |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
adduser asterisk --disabled-password --gecos "asterisk PBX" --home /var/lib/asterisk
adduser www-data asterisk


echo "+----------------------------------------------------------------+"
echo "| Changing the use www-data to asterisk for Apache2 |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
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

echo "+----------------------------------------------------------------+"
echo "| Setup MySQL Tables and Users |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
echo "create database asteriskcdrdb;" | mysql -u root | tee -a ${LOGFILE}
echo "create database asterisk;" | mysql -u root | tee -a ${LOGFILE}
echo "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109';" | mysql -u root | tee -a ${LOGFILE}
echo "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109';" | mysql -u root | tee -a ${LOGFILE}

mysql -u asteriskuser -pamp109 asteriskcdrdb < /usr/src/freepbx-${VER_FREEPBX}/SQL/cdr_mysql_table.sql
mysql -u asteriskuser -pamp109 asterisk < /usr/src/freepbx-${VER_FREEPBX}/SQL/newinstall.sql

echo "+----------------------------------------------------------------+"
echo "| Configuration of Asterisk to work with FreePBX |" | tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cp /etc/asterisk/asterisk.conf /etc/asterisk/asterisk.conf.orig
sed -i "s/\(astrundir *=> *\)\(.*\)/\1\/var\/run\/asterisk/" /etc/asterisk/asterisk.conf

mkdir /var/run/asterisk
chown -R asterisk:asterisk /var/run/asterisk

echo "+----------------------------------------------------------------+"
echo "| Running Asterisk post installation |"
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
/usr/sbin/asterisk | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Modification of FreePBX configuration files |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
#$webroot = "/var/www/html";
cp /usr/src/freepbx-${VER_FREEPBX}/install_amp /usr/src/freepbx-${VER_FREEPBX}/install_amp-orig
sed -i "s/\(^\$webroot*\)\(.*\)/\1 = \"\/var\/www\";/" /usr/src/freepbx-${VER_FREEPBX}/install_amp
chmod 755 /usr/src/freepbx-${VER_FREEPBX}/install_amp
echo "Assign eth0 IP to FreePBX" | tee -a ${LOGFILE}
LOCAL_IP=`/sbin/ifconfig eth0`
LOCAL_IP=`echo ${LOCAL_IP} | sed -e "s/\ Bcast:\(.*\)//"`
LOCAL_IP=`echo ${LOCAL_IP} | sed -e "s/\(.*\)\ inet addr://"`
sed -i "s/xx.xx.xx.xx/${LOCAL_IP}/g" "/usr/src/freepbx-${VER_FREEPBX}/install_amp"

chmod 755 /usr/src/freepbx-${VER_FREEPBX}/install_amp

echo "+----------------------------------------------------------------+"
echo "| Installing FreePBX |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo "| Simply press at each question. |"
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cd /usr/src/freepbx-${VER_FREEPBX}/
./install_amp

/usr/src/freepbx-${VER_FREEPBX}/apply_conf.sh | tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Stop Asterisk post installation |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
asteriskPID=$(cat /var/run/asterisk/asterisk.pid)
kill -9 $(cat /var/run/asterisk/asterisk.pid)


echo "+----------------------------------------------------------------+"
echo "| Remove Apache2 redirect |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
sed -i "s/\(RedirectMatch*\)\(.*\)//" /etc/apache2/sites-enabled/000-default

echo "+----------------------------------------------------------------+"
echo "| Restart Apache2 |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
/etc/init.d/apache2 restart| tee -a ${LOGFILE}

echo "+----------------------------------------------------------------+"
echo "| Setting permissions |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@

chown -R asterisk:asterisk /etc/asterisk
chmod 770 /etc/asterisk/

chown -R asterisk:asterisk /var/lib/asterisk/
chmod 770 /var/lib/asterisk/

chown -R asterisk:asterisk /var/www/


echo "+----------------------------------------------------------------+"
echo "| Copying images |"
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
cp /var/www/admin/modules/dashboard/images/notify_* /var/www/admin/images/

echo "+----------------------------------------------------------------+"
echo "To run Asterisk+FreePBX: /etc/init.d/freepbx [start|stop|restart]"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
echo " Press to continue"
if [ "$fast" != "T" ]; then
read
fi ##@@
STARTUP_SCRIPT="/etc/init.d/freepbx";
echo "Creating file ${STARTUP_SCRIPT} ...";

echo '#!/bin/bash' > ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo 'AMPORTAL_BIN=/usr/local/sbin/amportal' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo 'if [ ! -x ${AMPORTAL_BIN} ]; then' >> ${STARTUP_SCRIPT}
echo ' echo "error : amportal binary can not be found (${AMPORTAL_BIN})"' >> ${STARTUP_SCRIPT}
echo ' exit 0' >> ${STARTUP_SCRIPT}
echo 'fi' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo 'start() {' >> ${STARTUP_SCRIPT}
echo ' echo "Starting FreePBX ..."' >> ${STARTUP_SCRIPT}
echo ' ${AMPORTAL_BIN} start' >> ${STARTUP_SCRIPT}
echo '}' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo 'stop() {' >> ${STARTUP_SCRIPT}
echo ' echo "Stopping FreePBX ..."' >> ${STARTUP_SCRIPT}
echo ' ${AMPORTAL_BIN} stop' >> ${STARTUP_SCRIPT}
echo '}' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo 'case "$1" in' >> ${STARTUP_SCRIPT}
echo ' start)' >> ${STARTUP_SCRIPT}
echo ' start' >> ${STARTUP_SCRIPT}
echo ' ;;' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo ' stop)' >> ${STARTUP_SCRIPT}
echo ' stop' >> ${STARTUP_SCRIPT}
echo ' ;;' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo ' restart)' >> ${STARTUP_SCRIPT}
echo ' stop' >> ${STARTUP_SCRIPT}
echo ' start' >> ${STARTUP_SCRIPT}
echo ' ;;' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo ' *)' >> ${STARTUP_SCRIPT}
echo ' echo $"Usage: $0 {start|stop|restart}"' >> ${STARTUP_SCRIPT}
echo ' exit 1' >> ${STARTUP_SCRIPT}
echo 'esac' >> ${STARTUP_SCRIPT}
echo '' >> ${STARTUP_SCRIPT}
echo 'exit 0' >> ${STARTUP_SCRIPT}
chmod 755 ${STARTUP_SCRIPT}

echo "Setting ${STARTUP_SCRIPT} to be run at boot time..."
update-rc.d freepbx start 99 2 3 4 5 .
echo "Startup Script: ${STARTUP_SCRIPT}" | tee -a ${LOGFILE}
cat ${STARTUP_SCRIPT} | tee -a ${LOGFILE}

echo "#################################################################"
echo "# Configuration : FINISHED "| tee -a ${LOGFILE}
echo "### ---------------------------------------------------------- ##"
echo "# Press to continue "
echo "#################################################################"
if [ "$fast" != "T" ]; then
read
fi ##@@
}

function fr_passwords
{
clear
echo "#################################################################"
echo "# PART 3 - SETTING UP SECURITY "| tee -a ${LOGFILE}
echo "### ---------------------------------------------------------- ##"
echo "# Press to continue "
echo "#################################################################"
read

echo "+----------------------------------------------------------------+"
echo "| Change the default SQL password for the SQL user asteriskuser |"| tee -a ${LOGFILE}
echo "| > Change AMPDBPASS=amp109 in /etc/amportal.conf |"| tee -a ${LOGFILE}
echo "| > Change SQL PASSWORD |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"

read -p "NEW asteriskuser SQL password ? " key
echo $key| tee -a ${LOGFILE}
sed -i "s/\(^AMPDBPASS=*\)\(.*\)/\1$key/" /etc/amportal.conf
echo "SET PASSWORD FOR 'asteriskuser'@'localhost' = PASSWORD('$key');" | mysql -u root| tee -a ${LOGFILE}


echo "+----------------------------------------------------------------+"
echo "| Changing the default password for the Asterisk Manager |"| tee -a ${LOGFILE}
echo "| > Change secret = amp111 in /etc/asterisk/manager.conf |"| tee -a ${LOGFILE}
echo "| > Change AMPMGRPASS=amp111 in /etc/amportal.conf |"| tee -a ${LOGFILE}
echo "+----------------------------------------------------------------+"
read -p "NEW Asterisk Manager password ? " key
echo $key| tee -a ${LOGFILE}

sed -i "s/\(^secret = *\)\(.*\)/\1$key/" /etc/asterisk/manager.conf
sed -i "s/\(^AMPMGRPASS=*\)\(.*\)/\1$key/" /etc/amportal.conf

echo "enabling DAHDI in amportal.conf..."| tee -a ${LOGFILE}
echo ZAP2DAHDICOMPAT=true >> /etc/amportal.conf
echo "End of Part 3, Security. _INSTALLATION COMPLETE_" | tee -a ${LOGFILE}
#EOF function fr_passwords
}

function fr_help
{
clear
echo "Installer for Asterisk + FreePBX on a Debian machine"
echo "Usage: dfreepbx [ -x --xpedite \| -s --setup \| -f --fetch \| -i --install \| -p --passwords \| -h --help]"
echo " Example: dfreepbx -x -f -i -p"
echo "Xpedite: Fast mode, skips most 'Press Enter' prompts."
echo "Setup: (use 1x only) installs the build and development tools"
echo "Fetch: Download and unpack fresh source files."
echo "Install: Build, Install and Configure source files."
echo "Passwords: Set the security and passwords."
echo ""
echo "Old .conf files are in .conf-orig. Run as root, the script "
echo "requires access to the Internet. NB: Do _NOT_ change any "
echo "default passwords UNTIL Part 3: Setting Up Security (invoked"
echo "with -p). After using -p, set the default password "
echo "for the root mysql user. By default it is null. From MySQL, "
echo "invoke: SET PASSWORD FOR 'root'@'localhost' = "
echo "PASSWORD(''); "
echo "Once installed, run asterisk+freepbx with: amportal start"
echo ""
echo "Edit this script to set the following versions and filenames:"
echo "-> Asterisk = ${VER_ASTERISK},-> Dahdi = ${VER_DAHDI}"
echo "-> Libpri = ${VER_LIBPRI},-> Addons = ${VER_ADDONS}"
echo "-> FreePBX = ${VER_FREEPBX} (+ apache2 php5 mysql5)"
echo "-> Log File = ${LOGFILE}, Press Enter to continue "
read
}

########## MAIN ###########


if ! [ -e `which ifconfig` ]
then
# echo $err_state
clear
read -n 1 -p "You must run this script with root privilege (either user = root, or with sudo). Hit CTRL-C now if you need to escalate your privilege level and restart" junk
err_state="1"
fi
if [ "$err_state" != "1" ]; then
if ! [ $# -gt 0 ]; then
fr_help
else
while [ "$1" != "" ]; do
case $1 in
-x | --xpedite ) fast="T"
;;
-s | --setup ) fr_setup
;;
-f | --fetch ) fr_fetch
;;
-i | --install ) fr_install
;;
-p | --passwords ) fr_passwords
;;
-h | --help ) fr_help
exit
;;
* ) fast="F"; fr_help
exit 1
esac
shift
done
fi
fi
exit 0


   All Postings
BROWSE       Headlines and Postings

Privacy Policy
Webmaster & Acknowledgments
Copyright (C) 2002,2016 W.S. Herrick and/or Respective Copyright Holders