-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-fpbx
executable file
·151 lines (125 loc) · 5.21 KB
/
install-fpbx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh
# Install FreePBX - version 3
set -ex
LIBDIR="/usr/lib"
if [ `uname -m` = "x86_64" -a -d /usr/lib64 ]
then
LIBDIR="/usr/lib64"
fi
# this all has to be run as root
[ `whoami` != 'root' ] && exec sudo $0
# disable selinux
if [ -z "`sestatus |grep 'status: *disabled'`" ]
then
echo "Disabling selinux..."
sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
echo 0 >/selinux/enforce
fi
# erase any previous configuration
rm -f /etc/amportal.conf
# update system
yum -y update
yum -y groupinstall core
yum -y groupinstall base
yum install gcc gcc-c++ lynx bison mysql-devel mysql-server php php-mysql php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml uuid-devel libtool sqlite-devel
#yum -y install automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel sqlite-devel radiusclient-ng-devel portaudio-devel libresample-devel neon-devel libical-devel openldap-devel gmime-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel libuuid-devel jansson-devel libsrtp-devel subversion git subversion libxslt-devel kernel-devel audiofile-devel gtk2-devel libtiff-devel libtermcap-devel bison php php-mysql php-process php-pear php-mbstring php-xml php-gd tftp-server httpd sox tzdata mysql-connector-odbc mysql-server fail2ban
# disable firewall
service iptables save
service iptables stop
chkconfig iptables off
# enable mysql
service mysqld start || echo "Mysql already running?"
chkconfig mysqld on
# enable apache
service httpd start || echo "Httpd already running?"
chkconfig httpd on
# install peardb
pear channel-update pear.php.net
pear install db-1.7.14 || echo "Peardb already installed?"
# add asterisk user
adduser asterisk -M -c "Asterisk user" || echo "Asterisk user already created?"
# install pjproject
cd /usr/src
rm -rf pjproject-*
wget https://www.pjsip.org/release/2.2.1/pjproject-2.2.1.tar.bz2
tar -xjvf pjproject-2.2.1.tar.bz2
cd pjproject-2.2.1
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound\
--disable-resample --disable-video --disable-opencore-amr --libdir=$LIBDIR
make dep
make
make install
# install libjansson
cd /usr/src
rm -rf jansson
git clone https://github.com/akheron/jansson.git
cd jansson
autoreconf -i
./configure --libdir=$LIBDIR
make
make install
# install asterisk
cd /usr/src
rm -rf asterisk*
wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
contrib/scripts/install_prereq install || echo "Ignoring"
./configure --libdir=$LIBDIR
contrib/scripts/get_mp3_source.sh
#make menuselect
make menuselect.makeopts
menuselect/menuselect --enable cdr_mysql --enable EXTRA-SOUNDS-EN-GSM menuselect.makeopts
make
make install
make config
ldconfig
# install extra sounds
mkdir -p /var/lib/asterisk/sounds || echo "sounds directory already exists?"
cd /var/lib/asterisk/sounds
wget https://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget https://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
# download freepbx
cd /usr/src
wget https://mirror.freepbx.org/modules/packages/freepbx/freepbx-12.0-latest.tgz
tar vxfz freepbx-12.0-latest.tgz
# set ownership
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib*/asterisk
mkdir /var/www/html || echo "Already exists"
chown -R asterisk. /var/www/
# modifications to apache
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
service httpd restart
# configure mysql
cd /usr/src/freepbx
export ASTERISK_DB_PW=amp109
#mysqladmin -f drop asterisk || echo "Ignoring that"
#mysqladmin -f drop asteriskcdrdb || echo "Ignoring that"
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "flush privileges;"
# install freepbx
cd /usr/src/freepbx
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
amportal chown
amportal a ma installall
amportal a reload
amportal a ma refreshsignatures
amportal chown
# fix moh and restart
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal restart