====== FusionPBX ======
[[https://www.fusionpbx.com/|FusionPBX]] is a multi-tenant PBX system based on [[FreeSwitch]].
I thought it might be interesting to look at the dialplan source code to find out how someone had built a working system using FreeSwitch (whose documentation is poor, to put it mildly).
**Note:** The following instructions are //not yet complete// - they do not yet result in a working FusionPBX installation.
I had expected that the [[https://www.fusionpbx.com/download|instructions]] for downloading and installing it on Debian would have the same expectation that systemd is installed as FreeSwitch itself does, however somewhat to my surprise the FusionPBX installer build FreeSwitch from source instead of installing it as a package.
The result __appears__ to work, as you get to see the FreeSwitch CLI "logo" shortly before the end of the FusionPBX installation.
However, there are in fact [[FusionPBXproblems|problems]] **which do not get reported** by the installer.
The main reason turns out to be that the file **/usr/src/fusionpbx-install.sh/debian/resources/environment.sh** identifies the Debian release name (eg: "stretch", "buster" and "bullseye") and various further scripts then use this text information to install things such as PHP and FreeSwitch.
The problem is that if the output of **lsb_release -cs** doesn't match any of these names, some things either don't get installed at all (eg: PHP) or else get mis-configured (eg: nginx is told to expect to use php8.1 files, even though PHP itself hasn't been installed at any version whatsoever).
**No error message is generated** if the release name found on the system does not match one of the expected values.
The solution is to:
- add steps to the standard installation instructions (to modify the **environment.sh** script)
- eliminate two bugs from the installer scripts:
- they assume that several commands exist in /usr/bin rather than /bin
- they run **lsb_release -sc** during installation instead of using the previously-derived variable **os_codename**
- create and install a dummy systemd package so that PHP will install
Amended instructions are (see below for a script to do all this for you):
- wget https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/debian/pre-install.sh
- chmod +x pre-install.sh
- ./pre-install.sh
- cd /usr/src/fusionpbx-install.sh/debian
- **edit the file resources/environment.sh**
* **Find the line (near the top of the script)**
* **#cpu details**
* **Insert __before__ this line**[ "$os_codename" = "ascii" ] && os_codename=stretch
[ "$os_codename" = "beowulf" ] && os_codename=buster
[ "$os_codename" = "chimaera" ] && os_codename=bullseye
* **This converts the Devuan release name to the equivalent Debian release name so that further scripts think they know what they're doing**
- **edit the file resources/switch/source-master.sh**
* **Find the line //ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli//**
* **Change this to //ln -s /usr/local/freeswitch/bin/fs_cli /bin/fs_cli//**
- **change any scripts which run //lsb_release -sc// to use the variable //$os_codename// instead**
* **sed -i 's/`lsb_release -sc`/$os_codename/' `grep -rl lsb_release .`**
* **sed -i 's/$(lsb_release -sc)/$os_codename/' `grep -rl lsb_release .`**
- **change the PHP installer and upgrader scripts not to have pointless sub-shell commands**
* **sed -i "s#sh -c '##; s#php.list'#php.list#" resources/php.sh resources/upgrade/php.sh**
- **modify all scripts under //resources// not to have hard-coded (and incorrect) command paths**
* **sed -i 's#/usr/bin/##' `grep -lr /usr/bin/ resources`**
- **create the dummy packge systemd-tmpfiles**
* **aptitude install equivs**
* **create the file //systemd-tmpfiles// containing the following lines:**Section: misc
Priority: optional
Standards-Version: 3.9.2
Package: systemd-tmpfiles
Description: something to allow PHP 8.1 to install
* **equivs-build systemd-tmpfiles**
* **dpkg -i systemd-tmpfiles_1.0_all.deb**
* **Continue with the standard installer instructions:**
- ./install.sh
The following script will perform all the above steps:#!/bin/bash
# Download the FusionPBX installer, modify it so that it works, then execute it
wget https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/debian/pre-install.sh
chmod +x pre-install.sh
./pre-install.sh
aptitude -y install equivs
echo -e "Section: misc\nPriority: optional\nStandards-Version: 3.9.2\n\nPackage: systemd-tmpfiles\nDescription: something to allow PHP 8.1 to install" >systemd-tmpfiles
equivs-build systemd-tmpfiles
dpkg -i systemd-tmpfiles_1.0_all.deb
cd /usr/src/fusionpbx-install.sh/debian
grep -q beowulf resources/environment.sh || sed -i 's/#cpu details/[ "$os_codename" = "ascii" ] \&\& os_codename=stretch\n[ "$os_codename" = "beowulf" ] \&\& os_codename=buster\n[ "$os_codename" = "chimaera" ] \&\& os_codename=bullseye\n\n#cpu details/' resources/environment.sh
sed -i 's#/usr/bin/fs_cli#/bin/fs_cli#' resources/switch/source-master.sh
sed -i 's/`lsb_release -sc`/$os_codename/; s/$(lsb_release -sc)/$os_codename/' `grep -rl lsb_release .`
sed -i "s/sh -c '//; s/php.list'/php.list/" resources/php.sh resources/upgrade/php.sh
sed -i 's#/usr/bin/##' `grep -lr /usr/bin/ resources`
./install.sh
20 minutes and 27 thousand lines of output later, and you __still__ get a 502 Bad Gateway error in your browser (but at least PHP is now installed).
----
[[.:|Go up]]\\
Return to [[:|main index]].