Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

This is for the new SNG7 Distro using PHP 5.6 only!

Setup

If you already have the FreePBX distro installed then you already have the perfect environment to start FreePBX development. The steps below outline what you will need to do to be able to develop in FreePBX using the FreePBX distro:

yum -y install sangoma-devel

Note that 'sangoma-devel' is only available on SNG7 based Distros. If you're using an older SHMZ6 Distro, you will need to 'yum -y install git' instead.

rm -rf /usr/src/freepbx
echo "repo_directory=/usr/src/freepbx" >> ~/.freepbxconfig
cd /usr/src
git clone https://git.freepbx.org/scm/freepbx/devtools.git
cd /usr/src/devtools
./freepbx_git.php --setup --mode=ssh --switch=release/15.0 --keys=freepbx

There are two ways of synchronizing your machine with the main Git repository, ssh or https.  ssh is significantly faster, and is the recommended way, but you do need to grant access to the SSH key of your development machine with the FreePBX Git Repository.

If you are unsure of how, or unable to do so, remove the '--mode=ssh' parameter, and it will work purely over https. 

At this point (regardless of ssh or https) you will be asked for your FreePBX.org username and password. This is so the setup script can iterate over the list of projects available, which is not available without a login.

./freepbx_git.php --setup --mode=ssh --switch=release/15.0 --keys=freepbx

Make sure everything is symlinked correctly.

./freepbx_git.php -s

Once that is complete you are now free to install the developer mode of FreePBX. Keep in mind that we blow away the entire webroot so that the symlinks are created correctly and so that there are duplicate files laying around.

fwconsole ma upgradeall --edge
chown -R asterisk:asterisk /usr/src/freepbx
cd /usr/src/freepbx/framework
rm -Rf /var/www/html/*
./install --dev-links -n
fwconsole ma installlocal
fwconsole chown
fwconsole reload

Fixing Broken Modules

If after development mode has been setup you can check if any modules are broken by querying FreePBX like so:

fwconsole ma list | grep "Broken"

If any Broken Module are found, you can attempt to fix them individually by running:

/usr/src/devtools/freepbx_git.php -m <module> --switch=release/15.0
Update Dev SymLinks? [n]: y
chown -R asterisk:asterisk /usr/src/freepbx
fwconsole ma install <module>
fwconsole reload

If you've got any issue with PM2, then do the same thing for a Broken module.

You can also fix all of them in a batch by using the fix_broken_modules.sh script

cd /usr/src/devtools
./fix_broken_modules.sh

Before running that script, make sure your Freepbx Username and Password are set in ~/.freepbxconfig.  Remember to remove them after this script to avoid having your credentials stored in plain text:

~/.freepbxconfig

repo_directory=/usr/src/freepbx
username=Your Freepbx Username
password=Your Freepbx Password

Maintenance

Adding your own custom module

If after development mode has been setup you wish to add your own module the steps are simple.

First change directories to the freepbx source directory

cd /usr/src/freepbx

Next you'll either need to checkout your module from your favorite VCS (VCS means git,svn or others). Or add it manually. Remember that the raw name of your module should be the folder name so dont try to get creative and have a module name of "mya@wsome!!Module&&"

git clone git@github.com:tm1000/ucphelloworld.git

Lastly you'll want to run the linker. This process links your module folder into the framework modules folder which let's framework know your module exists

/usr/src/devtools/freepbx_git.php -s

Then tell framework to go update the symlinks. You'll also need to tell framework to go update the symlinks every time you add a new file!

/usr/src/freepbx/framework/install --dev-links -n

Set proper permissions

chown -R asterisk:asterisk /usr/src/freepbx

Finally install your module!

fwconsole ma install ucphelloworld

Don't forget to reload!

fwconsole reload

Updating all modules from GIT

Later down the line if you want to update everything in FreePBX from upstream simply run

cd /usr/src/devtools
./freepbx_git.php --refresh
./freepbx_git.php -s
chown -R asterisk:asterisk /usr/src/freepbx
fwconsole ma installlocal
fwconsole reload

Checking out (adding new modules)

If you want to checkout a single module run

/usr/src/devtools/freepbx_git.php -m <module> --switch=release/15.0
Update Dev SymLinks? [n]: y
chown -R asterisk:asterisk /usr/src/freepbx
fwconsole ma install <module>
fwconsole reload

Tricks and tips

Also, we can add some aliases in .bashrc file adding two lines like this:

.../...
alias cdmodules='cd /var/www/html/admin/modules'
alias cdsrc='cd /usr/src/'
.../...

But, we can add whatever you want as alias in this file.
Here, if we type cdsrc, we will go to the /usr/src dirzectory.
The next login we will get these aliases

To read the freepbx debug logs directly, we can create a file under /usr/local/bin/taildebug with this content.

tail -f /var/log/asterisk/freepbx_dbug

Don't forget the privileges.

chmod 755 /usr/local/bin/taildebug

Feel free to create some shortcuts as you want.

  • No labels