With this script you connect a kazoo webhook to it and then will get connected to couchdb and parse variables with postgresql queries to be executed on fusionpbx's environment.
Note that you should configure fusionpbx with provisioner settings enabled and visualize the phones JSON on SmartPBX
- Install a fusionpbx normally on different instance or VPS
- Setup a Webserver with NGINX with SSL Certificates, PHP and Postgresql; then, import the provisioner-db.sql with proper user credentials (ie. provisioner), the schema is called 'provisioner', also install python3, postgresql client and curl and some of the php libraries.
- Move or rename the api-phones-alternate.php file to index.php, edit and the DB connection parameters with also the CORS headers at the top of the file (to your Monster-UI URL)
- Add a location block to the nginx server section like the following:
location /api/phones {
add_header "Access-Control-Allow-Origin" "https://portal.example.com";
rewrite ^(.*)$ /index.php ;
}
- Restart the nginx service
- Edit the Monster-UI js/config.js and add the provisioner link as following:
api: {
'default': 'https://api.example.net:8443/v2/',
'provisioner': 'https://phoneprov.example.net/api/'
}
- Copy Brands and Models Image files to the Monster-UI Webroot CSS path.
cd provisioner
\cp -rp brands/* /var/www/monster-ui/css/assets/brands/
\cp -rp models/* /var/www/monster-ui/css/assets/models/
- Inside the /var/www/env.php file; configure the CouchdB and postgresql connection parameters and ensure they are correct. For reaching fusionpbx's postgresql, you can use a SSH Forwarding. Also, you should also change fusionpbx's postgres listen address to other than 127.0.0.1 and allow queries from nginx webserver's IP by editing pg_hba.conf
- Configure sudo (visudo) to allow access from www-data (or apache) user without password
apache ALL=(ALL) NOPASSWD: ALL
- Test The SmartPBX device additions (SmartPBX >> Devices >> Add Devices) and ensure the phone brands/models are showing up correctly.
- Copy prov-webhook.php to /var/www/html and env.php to /var/www Folders
- Go to Master Account and configure webhooks (about 6 of them) to point to prov-webhook.php.
webhook A:
-Trigger Event = Object
-Request Type = POST
-URL: The prov-webhook php URL
-Body Format: JSON
-Custom Data >> Type: account >> Action: doc_created
webhook B:
-Trigger Event = Object
-Request Type = POST
-URL: The prov-webhook php URL
-Body Format: JSON
-Custom Data >> Type: account >> Action: doc_edited
webhook C:
-Trigger Event = Object
-Request Type = POST
-URL: The prov-webhook php URL
-Body Format: JSON
-Custom Data >> Type: device >> Action: doc_created
webhook D:
-Trigger Event = Object
-Request Type = POST
-URL: The prov-webhook php URL
-Body Format: JSON
-Custom Data >> Type: device >> Action: doc_edited
webhook E:
-Trigger Event = Object
-Request Type = POST
-URL: The prov-webhook php URL
-Body Format: JSON
-Custom Data >> Type: device >> Action: doc_deleted
webhook F:
-Trigger Event = Object
-Request Type = POST
-URL: The prov-webhook php URL
-Body Format: JSON
-Custom Data >> Type: account >> Action: doc_deleted
- Enable the checkbox named 'Include Sub Accounts' to all of the webhooks.
- Now check everything by adding or editing account and phones on each of the tenants; if they are ok; head to fusionbpx webpanel and you will see the kazoo accounts and devices added with them.
- Combo/Feature Keys are able to configure from kazoo to be replicated onto fusionpbx.
- Kazoo SmartPBX includes combo_keys and feature_keys and they have about 4 key types:
- speed dial
- parking
- personal parking
- presence (BLF)
- line
Go to FusionPBX's devices >> vendors >> Yealink (example) and put the values like the following:
'monitored call park' -> 10
'none' -> 0 (with a space) Repeat same addition for each brand for this entry. The idea is create a kind of duplicate but with the key type changed as above
15. Copy The 'creds' folder to the nginx server's webroot and add a nginx location block like the following:
location /creds {
rewrite $(.*)$ /creds/index.php ;
}
- Dont forget to edit the CORS headers at the beginning of the index files to your monster-ui base URL
- Import the 'https://github.com/fmateo05/monster-ui-fusionpbx-provisioner' and change folder as fusionpbx-provisioner
- Edit the app.js and set up too look like the following:
requests: {
'provisioner.devices.list': {
apiRoot: 'https://prov.example.net/creds/',
url: '{accountId}',
verb: 'GET'
}
},
- Load the app page and you will see the provisioner URL; but first you should add a device inside the created account and after that the URL will be populated.
*.prov.your-domain.tld IN A <IP of your fusionpbx instance>
*.sip.your-domain.tld IN A <IP of your kamailio instance(s)>
- Then you can use the populated url to set it up on your DHCP-Option-66 capable router!! (Mine are some of Ubiquiti Edge Router X)