Skip to content

Instantly share code, notes, and snippets.

@bspavel
Forked from andrius/download-and-install.sh
Created July 8, 2018 10:55
Show Gist options
  • Save bspavel/2ac1b71d6d6e575a9535bfd09214dcf9 to your computer and use it in GitHub Desktop.
Save bspavel/2ac1b71d6d6e575a9535bfd09214dcf9 to your computer and use it in GitHub Desktop.
Script to download and install Asterisk PBX, Ruby and Adhearsion AGI on debian-based system
#!/bin/bash
# function to generate random password, on input requires an argument - lenght of password
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
# MySQL default root password
MYSQL_ROOT_PASSWORD=`genpasswd 16` # can be replaced by static text password
# Remove MySQL with following commands (copy-paste to shell)
# M=`dpkg -l|grep mysql|awk '{print $2}'|xargs`;apt-get -y purge ${M};rm -rf /etc/mysql;rm -rf /var/lib/mysql
MYSQL_SERVER_VERSION=`apt-cache showpkg mysql-server|grep "Versions:" -A 1|tail --lines 1|awk '{print $1}'`
# tell installer about pre-set MySQL server password
echo "mysql-server-${MYSQL_SERVER_VERSION} mysql-server/root_password password ${MYSQL_ROOT_PASSWORD}" \
| debconf-set-selections
echo "mysql-server-${MYSQL_SERVER_VERSION} mysql-server/root_password_again password ${MYSQL_ROOT_PASSWORD}" \
| debconf-set-selections
# install necessary packages
apt-get update
apt-get upgrade
apt-get -y install build-essential linux-headers-`uname -r` libxml2-dev libncurses-dev libnewt-dev \
openssl libreadline6 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev \
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libtiff-dev \
libjpeg-progs libjpeg-dev libpng-dev mysql-server libmysqlclient-dev sqlite3 libsqlite3-dev \
wget rsync subversion
# create /usr/src if not exists
mkdir -p /usr/src
cd /usr/src
# download SpanDSP (need to support faxing)
wget --continue http://soft-switch.org/downloads/spandsp/spandsp-0.0.6pre21.tgz
# download imagemagick (need to convert faxes)
wget --continue http://www.imagemagick.org/download/ImageMagick-6.8.3-9.tar.gz
# download asterisk PBX
wget --continue http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11.2.1.tar.gz
# unpack downloaded packages
tar -zxf spandsp-0.0.6pre21.tgz
tar -zxf ImageMagick-6.8.3-9.tar.gz
tar -zxf asterisk-11.2.1.tar.gz
# dowlnoad asterisk add-ons
cd asterisk-11.2.1
./contrib/scripts/get_ilbc_source.sh
./contrib/scripts/get_mp3_source.sh
# install imagemagick
cd ../ImageMagick-6.8.3-9
./configure && make all && make install
# install spandsp
cd ../spandsp-0.0.6
./configure && make all && make install
# install asterisk PBX
cd ../asterisk-11.2.1
./configure && make all && make install && make samples && make config && make install-logrotate
# install asterisk utilities
cp ./contrib/scripts/astcli /usr/local/bin/
# Automate asterisk service to run on startup.
update-rc.d asterisk defaults
# install rvm and ruby
curl -L get.rvm.io | bash -s stable
# to remove rvm do:
# rvm implode
source /etc/profile.d/rvm.sh
ldconfig
rvm install 1.9.3
gem install --no-rdoc --no-ri bundler sqlite3 mysql \
adhearsion adhearsion-activerecord adhearsion-asterisk adhearsion-drb adhearsion-rails adhearsion-xmpp
echo -e "\n\n\n\n"
echo "**************************************************************************************"
echo " INSTALLATION DONE"
echo " YOUR ROOT MYSQL PASSWORD IS ${MYSQL_ROOT_PASSWORD}"
echo " SAVE IT IN SAFE PLACE :)"
echo "**************************************************************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment