-
-
Save billsimon/5ae9c5db8c6036c63b3f9aee34176654 to your computer and use it in GitHub Desktop.
Groundwire FreePBX provisioning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Licensed GPL v3.0 (https://www.gnu.org/licenses/gpl-3.0.en.html) by Bill Simon | |
// | |
// USAGE: gw.php?EXTNUM=ACCOUNTCODE, example: https://pbx/gw.php?1000=asdfasdfasdf | |
// | |
// Configure these: | |
// Transport options: https://doc.acrobits.net/cloudsoftphone/account.html#transport | |
$transport = "tls+sip:"; // use "udp:", "tcp:", "tls+sip:", or "tls:" | |
// If using a non-standard port, use the format ':xxxx' e.g. ':5062' otherwise leave empty | |
$port = ''; | |
// Configure account block below | |
$bootstrap_settings['freepbx_auth'] = false; | |
require_once '/etc/freepbx.conf'; | |
$ext = (int) array_keys($_REQUEST)[0]; | |
if ($ext <= 0) | |
exit; // if we didn't get something like an extension number | |
$code = $_REQUEST[$ext]; | |
if (! $device = FreePBX::Core()->getDevice($ext)) | |
exit; // if device doesn't exist | |
if (empty($device['accountcode']) || ($device['accountcode'] !== $code)) | |
exit; // if code is wrong or no code for extension | |
if ((strpos($_SERVER['HTTP_USER_AGENT'], "Acrobits Softphone Business") === 0) || // iOS | |
(strpos($_SERVER['HTTP_USER_AGENT'], "Groundwire") === 0)) { // Android | |
// provisioning | |
header('Content-type: application/xml'); | |
// Documentation at https://doc.acrobits.net/cloudsoftphone/account.html | |
echo <<<AccountBlock | |
<account> | |
<title>$ext</title> | |
<username>$ext</username> | |
<password>{$device['secret']}</password> | |
<host>{$_SERVER['SERVER_NAME']}$port</host> | |
<transport>$transport</transport> | |
<allowMessage>1</allowMessage> | |
<voiceMailNumber>*97</voiceMailNumber> | |
<allowVideo>1</allowVideo> | |
<natTraversal>off</natTraversal> | |
<icm>auto</icm> | |
</account> | |
AccountBlock; | |
} else { | |
// generate link | |
header('Content-type: text/html'); | |
// for iOS | |
echo '<html><body><a href="provlinkb'; | |
if ($_SERVER['HTTPS']) { echo 's'; } | |
echo ':'; | |
echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | |
echo '">Add account ' . $ext . ' to Groundwire iOS</a><p></p>'; | |
// for Android | |
echo '<a href="intent://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | |
echo '#Intent;scheme=provlinkb'; | |
if ($_SERVER['HTTPS']) { echo 's'; } | |
echo ';package=cz.acrobits.softphone.aliengroundwire;end">Add account ' . $ext . ' to Groundwire Android</a>'; | |
echo '</body></html>'; | |
} | |
?> |
I followed all the instructions provided and successfully used the script, which displayed links for both iOS and Android platforms. Since I only have an iOS device, I selected the iOS option. The script appeared to provision Groundwire with the extension, password, and server details correctly. However, despite these settings being applied, I'm unable to connect, and Groundwire displays an error message. Interestingly, there is absolutely no corresponding log in Asterisk, which is quite puzzling. On the other hand provisioning the same extension manually works without a problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
First of all, thank you very much for sharing. Very nice script, I've managed to implement it in the following way: if I create the account manualy, enter title, user, pass, domain and at Advanced > Web services > External provisioning URL I put https://pbx/gw.php?= the account is provisioned with values from server, even disable options set with priority higger than 40 (GUI) like is mentioned in the documentation.
The problem is: I cannot add an account using the link generated Add account to Groundwire Android. I've tryed even with fresh install but nu luck.
I'm using latest version of Groundwire, 5.5.4 build 1692333...
I've also tryed to add account from https://office.acrobits.cz/urltest.xhtml with URL provlinkbs:dist.acrobits.net/test/provlink.xml but still no luck.
When I press the link in browser, I'm redirected to Groundwire to the following screen:
Are u kind enough to help me with a tip of what am I doing wrong? It should work out of the box, as installed from Google Play?
Thank you!