Elastix on OpenVZ

From Proxmox VE
Jump to: navigation, search
  • Install of Elastix from ISO file without loop on OpenVZ container
  • For purposes of this article, the VMID will be assumed to be 102. Change as necessary in your environment.

Pre-Install

  • Get the Elastix ISO
wget --no-check-certificate \
  https://sourceforge.net/projects/elastix/files/Elastix%20PBX%20Appliance%20Software/2.4.0/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso \
  -O /var/lib/vz/template/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso
  • Get the template and rename it to conform to PVE naming convention
wget --no-check-certificate \
  https://download.openvz.org/template/precreated/centos-5-x86_64.tar.gz \
  -O /var/lib/vz/template/cache/centos-5-standard_5.11-1_amd64.tar.gz

Enable PVE Console Access

  • Enable PVE Console access in the VM for use in PVE > 2.x
    • Access the private space of the container with
      • Either edit the VMID 102's file from the host using nano /var/lib/vz/private/102/etc/inittab
      • Or start and enter the container from the host using vzctl enter 102 and edit using nano /etc/inittab
    • Append the following line to /etc/inittab in the VM:
1:2345:respawn:/sbin/agetty tty1 38400 linux

Start Container and Enable Networking

Since veth is used, we need to create the network access file in the container (accessed from the host using vzctl enter 102) - we choose dhcp for this example by creating the file /etc/sysconfig/network-scripts/ifcfg-eth0

cat <<EOT > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
EOT

# Restart the Network daemon and update the OS with
service network restart

yum update

The above requires that a DHCP server is available in the network and preferably a Static DHCP has been assigned to the VM's veth device (eth0).

Install pre-requiites

Current OS and Kernel Version

# cat /etc/redhat-release
CentOS release 5.11 (Final)

# uname -a
Linux elastixpbx.example.com 2.6.32-44-pve #1 SMP Fri Feb 26 09:28:08 CET 2016 x86_64 x86_64 x86_64 GNU/Linux

Install OS utility packages

# yum install zip unzip bzip2
yum install zip

# Enable epel repo
rpm -ivh http://mirror.cs.princeton.edu/pub/mirrors/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpm

yum update
yum install p7zip p7zip-plugins

# yum install wget httpd make sendmail sendmail-cf caching-nameserver 
yum install gcc gcc-c++ bison mysql-devel mysql-server php php-mysql \
  php-pear php-pear-DB php-mbstring tftp-server ncurses-devel libtermcap-devel \
  sox newt-devel libxml2-devel libtiff-devel php-gd audiofile-devel gtk2-devel \
  subversion sysstat fail2ban system-config-securitylevel-tui python-setuptools nano

# bwm-ng is in DAG repo
rpm -ivh ftp://195.220.108.108/linux/dag/redhat/el5/en/x86_64/dag/RPMS/bwm-ng-0.5-2.el5.rf.x86_64.rpm

# These are not in the template itself
# yum remove yum-updatesd cups cups-lpd redhat-lsb autofs pcsc-lite smartmontools cpuspeed

# Shutdown unnecessary daemon brcm-iscsi which tends to do a lot of logging even when not used
chkconfig iscsi off
chkconfig iscsid off
# service iscsid stop
# service iscsi stop

# Replace syslog with the improved and backwards compatible rsyslog
yum -y install rsyslog
chkconfig syslog off
chkconfig rsyslog on
service syslog stop
service rsyslog start

# To prevent problems that can occur in an OpenVZ VPS if udev is ever updated append to /etc/rc.local
cat <<EOT >> /etc/rc.local
/bin/rm -rf /dev/tty*
/bin/rm -rf /dev/pty*
/bin/rm -rf /dev/null
/bin/rm -rf /dev/random
/bin/mknod -m 0666 /dev/null c 1 3
/bin/mknod -m 0644 /dev/random c 1 8
/sbin/MAKEDEV tty
/sbin/MAKEDEV pty
EOT

# Turn off selinux
setenforce 0

Elastix components

Either the Elastix ISO can be downloaded into the VM 102 or copied/temporarily moved from the host to the VM filesystem.

In the VM

mkdir -p /mnt/iso
wget --no-check-certificate \
  https://sourceforge.net/projects/elastix/files/Elastix%20PBX%20Appliance%20Software/2.4.0/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso \
  -O /mnt/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso
7z x -r Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso -o/mnt/iso
rm -f /mnt/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso

Alternatively from the host

mv /var/lib/vz/template/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso \
  /var/lib/vz/private/102/mnt/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso

vzctl enter 102

mkdir -p /mnt/iso
7z x -r Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso -o/mnt/iso

exit

mv /var/lib/vz/private/102/mnt/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso \
  /var/lib/vz/template/iso/Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso

Install Elastix

Create the Elastix-CD Repo

cat <<EOT > /etc/yum.repos.d/elastix-cd.repo
[elastix-cd]
name=Elastix RPM Repo CD
baseurl=file:///mnt/iso/
gpgcheck=0
enabled=1
EOT

Elastix packages install

yum -y update
# Installs autoconf, m4 from elastix-cd repo

# yum install mlocate gcc gcc-c++ wget sox
yum -y install asterisk* elastix-* freeze fxload libmfcr2 lzop \
       perl-HTML-TokeParser-Simple perl-WWW-Mechanize mod_ssl system-config-network-tui

# package libmfcr2 (for x86_64 atleast) does not install and hence is not used and does not appear needed

# TTY Fix - comment out the line with "TTY=" in /usr/sbin/safe_asterisk
sed -e 's/^TTY/# TTY/' -i /usr/sbin/safe_asterisk

reboot

Elastix First Boot

/etc/rc3.d/S66elastix-firstboot start
rm -f /etc/yum.repos.d/elastix-cd.repo
yum update
  • MySQL and FreePBX passwords: MySecret
  • These passwords are stored in the config files in /etc/asterisk
    • cbmysql.conf
    • cdr_mysql.conf
    • extensions_additional.conf
    • manager.conf
    • res_config_mysql.conf
  • Stands upgraded to Elastix 2.50

On rebooting, access the Elastix web UI at https://elastixpbx.example.com - admin / MySecret

Optional Webmin install

  • Webmin provides a simple control panel to manage the Server.
  • This is optional
  • It is generally used among others, for:
    • View the logs
    • Configure services like Mail and FTP
    • Manage config files for services like Apache, BIND DNS and MySQL
    • Take dumps of MySQL
    • View status of various services and effect control over them
# yum -y install openssl perl perl-Net-SSLeay
yum install openssl-devel perl-Crypt-SSLeay
wget --no-check-certificate \
     http://jaist.dl.sourceforge.net/project/webadmin/webmin/1.790/webmin-1.790-1.noarch.rpm
rpm -U webmin-1.790-1.noarch.rpm
rm -f webmin-1.790-1.noarch.rpm

# Start BIND DNS
service named start

# Avoid errors in new browsers that are security paranoid of user generated SSL certs
sed -e 's/no\_ssl3.*/no_ssl=0/' -i /etc/webmin/miniserv.conf
sed -e 's/no\_tls1.*/no_tlsl=0/' -i /etc/webmin/miniserv.conf
sed -e 's/no\_tls1\_1.*/no_tlsl_1=0/' -i /etc/webmin/miniserv.conf

cd /etc/webmin
./restart
service named status

reboot

jQuery code fix

A bug in detecting the jQuery version causes upto the first decimal of the version alone to be checked rendering later versions to appear as earlier ones. This results in Javascript Error: blockUI requires jQuery v1.2.3 or later!....

File: /var/www/html/modules/registration/themes/default/js/jquery.blockUI.js
Replace all \r\n with \n
Replace line 17:
if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
with
if ((/1\.(2\.([3-9]|[1-9][0-9])|[3-9]\.[0-9]*|[1-9][0-9]*\.[0-9]*)/.test($.fn.jquery)) === false ) {

The patched file is available here.

Post-Install

Elastix Updates

In future, when doing an Elastix update, do take backups within Elastix since trying to revert to an earlier version will not be possible as the SQLite db files may possibly have different schemas and defaults. All versions are visible in the Elastix Web UI. As on date it is:

 Kernel
   Linux(x86_64)-2.6.32-44

 Elastix
   elastix-2.5.0-1
   elastix-a2billing-2.1.0-1.gita40e37fefef7ab85999d04298b6e582b41930e7e
   elastix-a2billing-callback_daemon-2.1.0-1.gita40e37fefef7ab85999d04298b6e582b41930e7e
   elastix-addons-2.5.0-4
   elastix-agenda-2.5.0-1
   elastix-asterisk-sounds-1.2.3-1
   elastix-email_admin-2.5.0-4
   elastix-endpointconfig2-2.5.0-1
   elastix-extras-2.5.0-1
   elastix-fax-2.5.0-3
   elastix-firstboot-2.5.0-3
   elastix-framework-2.5.0-11
   elastix-im-2.5.0-1
   elastix-my_extension-2.5.0-1
   elastix-pbx-2.5.0-6
   elastix-portknock-0.0.1-0
   elastix-reports-2.5.0-5
   elastix-security-2.5.0-3
   elastix-system-2.5.0-3
   elastix-vtigercrm-5.2.1-10

 RoundCubeMail
   RoundCubeMail-0.3.1-12

 Mail
   postfix-2.3.3-7.el5
   cyrus-imapd-2.3.7-16.el5_11

 IM
   openfire-3.7.1-1

 FreePBX
   freePBX-2.11.0-23

 Asterisk
   asterisk-11.21.0-0
   asterisk-perl-1.03-0
   asterisk-addons-11.21.0-0

 FAX
   hylafax-4.3.11-1rhel5
   iaxmodem-1.2.0-2

 DRIVERS
   dahdi-2.10.2-0
   rhino-(not installed)- 
   wanpipe-util-7.0.14-0

Customisation

  • Custom Sound Recordings are at /var/lib/asterisk/sounds/custom
  • Elastix logos are at /var/www/html/themes/ under
    • blackmin/images/elastix_logo_mini.png
    • tenant/images/elastix_logo_mini.png
    • tenant/images/elastix_logo_mini2.png
  • These logos are referred to in the theme's _common folder's tpl files.

References