Integrate Provision functionality into Sccp_Manager
Create required directory structure Check if mapping support is enabled Check if mapping rules are defined Change options available based on above Create index.cnf and sccpManagerRewrite.rules
This commit is contained in:
parent
248abe6cb7
commit
5a184ededb
|
@ -205,6 +205,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function settingsShowPage() {
|
public function settingsShowPage() {
|
||||||
|
$this->checkTftpMapping();
|
||||||
$request = $_REQUEST;
|
$request = $_REQUEST;
|
||||||
$action = !empty($request['action']) ? $request['action'] : '';
|
$action = !empty($request['action']) ? $request['action'] : '';
|
||||||
|
|
||||||
|
|
|
@ -1163,9 +1163,9 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
<label>Rewrite HELP </label>
|
<label>Rewrite HELP </label>
|
||||||
<name>Help_tftp_rewrite</name>
|
<name>Help_tftp_rewrite</name>
|
||||||
<element type='p'>This section is responsible for the modes of operation of external services: tftp http.</element>
|
<element type='p'>This section is responsible for the modes of operation of external services: tftp http.</element>
|
||||||
<element type='p'> * off - Flat model cisco. All data is in the directory /tftproot</element>
|
<element type='p'> * off - Flat model cisco. All data is in the directory TFTP Server Path</element>
|
||||||
<element type='p'> * Custom - The directory structure is strictly defined in the manager (for internal use). Requires tftpd rewrite support.</element>
|
<element type='p'> * Provision - The directory structure is strictly defined in the manager. Requires tftpd mapping support.</element>
|
||||||
<element type='p'> * Provision - Directory structure data is read from an external file. This project supports phones that can work on tftp and http. Support rewrite.</element>
|
<element type='p'> * Custom - TFTP Directory structure can be extended by index.cnf. This supports phones that can work on tftp and http. Remapping support is required</element>
|
||||||
</item>
|
</item>
|
||||||
<label>SCCP Server Path config</label>
|
<label>SCCP Server Path config</label>
|
||||||
<item type="IE" id="1" seq="2">
|
<item type="IE" id="1" seq="2">
|
||||||
|
@ -1173,7 +1173,7 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
<class>provision_hide</class>
|
<class>provision_hide</class>
|
||||||
<input>
|
<input>
|
||||||
<name>tftp_path</name>
|
<name>tftp_path</name>
|
||||||
<default>/tftpboot</default>
|
<default></default>
|
||||||
<class>sccp-custom</class>
|
<class>sccp-custom</class>
|
||||||
</input>
|
</input>
|
||||||
<help>Path to tftp home directory. This was determined by the Sccp_manager installer and should only be changed if the tftp root has been modified since installation</help>
|
<help>Path to tftp home directory. This was determined by the Sccp_manager installer and should only be changed if the tftp root has been modified since installation</help>
|
||||||
|
@ -1188,16 +1188,18 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
</input>
|
</input>
|
||||||
<help>Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision"</help>
|
<help>Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision"</help>
|
||||||
</item>
|
</item>
|
||||||
<item type="IS" id="2" seq="20">
|
<item type="IS" id="21" seq="20">
|
||||||
<name>tftp_rewrite</name>
|
<name>tftp_rewrite</name>
|
||||||
<label>TFTP SERVER remapping support</label>
|
<label>TFTP SERVER remapping support</label>
|
||||||
<default>off</default>
|
<default>off</default>
|
||||||
<option_hide class=".provision_hide">pro</option_hide>
|
<option_hide class=".custom_hide">custom</option_hide>
|
||||||
<option_show class=".provision_show">pro</option_show>
|
<option_show class=".custom_show">custom</option_show>
|
||||||
<button value="off">Disabled</button>
|
<option_disable class=".custom_disable">Custom</option_disable>
|
||||||
<button-d value="internal">Internal</button-d>
|
<option_disable class=".provision_disable">Provision</option_disable>
|
||||||
<button value="on">Custom</button>
|
<option_disable class=".off_disable">Off</option_disable>
|
||||||
|
<button value="off">Off</button>
|
||||||
<button value="pro">Provision</button>
|
<button value="pro">Provision</button>
|
||||||
|
<button value="custom">Custom</button>
|
||||||
<help>Support the use of regular-expression-based filename remapping</help>
|
<help>Support the use of regular-expression-based filename remapping</help>
|
||||||
</item>
|
</item>
|
||||||
<item type="IE" id="2">
|
<item type="IE" id="2">
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#
|
#
|
||||||
# TFTPd Rewrite for SCCP_Manager Custom remaping
|
# TFTPd Rewrite for SCCP_Manager Custom remapping
|
||||||
|
#
|
||||||
|
# This file is maintained by Sccp_Manager, and will be overwritten by the installer
|
||||||
|
# a copy of the original can be found at sccpManagerRewrite.rules.bu
|
||||||
|
#
|
||||||
# /firmware
|
# /firmware
|
||||||
# /settings
|
# /settings
|
||||||
# /wallpapers
|
# /wallpapers
|
||||||
|
@ -174,6 +178,8 @@ ri ^(ATA030204SCCP090202A.zup)$ firmware/ata186/\1
|
||||||
# Sub-Directory Handling
|
# Sub-Directory Handling
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
|
# Do not disable the first rule - this is required by sccp_manager
|
||||||
|
#ri ^(.+\.tlzz)?$ settings/\1
|
||||||
#ri ^(.+\.tlv)?$ settings/\1
|
#ri ^(.+\.tlv)?$ settings/\1
|
||||||
#ri ^\/(.+\.tlv)?$ settings/\1
|
#ri ^\/(.+\.tlv)?$ settings/\1
|
||||||
#ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1
|
#ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1
|
||||||
|
|
|
@ -10,7 +10,7 @@ service tftp
|
||||||
wait = yes
|
wait = yes
|
||||||
user = root
|
user = root
|
||||||
server = /usr/sbin/in.tftpd
|
server = /usr/sbin/in.tftpd
|
||||||
server_args = -c -s -v /tftpboot -m /tftpboot/rewrite.rules
|
server_args = -c -s -v /tftpboot -m -m /etc/asterisk/sccpManagerRewrite.rules
|
||||||
disable = no
|
disable = no
|
||||||
per_source = 11
|
per_source = 11
|
||||||
cps = 100 2
|
cps = 100 2
|
||||||
|
|
10
install.php
10
install.php
|
@ -893,8 +893,8 @@ function checkTftpServer() {
|
||||||
die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again"));
|
die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$settingsToDb['asterisk_etc_path'] =array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir);
|
$settingsToDb['asterisk_etc_path'] = array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir);
|
||||||
$settingsFromDb['asterisk_etc_path']['data'] = $confDir;
|
$settingsFromDb['asterisk_etc_path'] = $settingsToDb['asterisk_etc_path'];
|
||||||
|
|
||||||
foreach ($settingsToDb as $settingToSave) {
|
foreach ($settingsToDb as $settingToSave) {
|
||||||
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});";
|
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});";
|
||||||
|
@ -904,7 +904,11 @@ function checkTftpServer() {
|
||||||
}
|
}
|
||||||
unset($settingsToDb[$settingToSave['keyword']]);
|
unset($settingsToDb[$settingToSave['keyword']]);
|
||||||
}
|
}
|
||||||
|
// put the rewrite rules into the required location
|
||||||
|
if (file_exists("{$confDir}/sccpManagerRewrite.rules")) {
|
||||||
|
rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu");
|
||||||
|
}
|
||||||
|
copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules");
|
||||||
$settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb);
|
$settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb);
|
||||||
|
|
||||||
foreach ($settingsToDb as $settingKey => $settingVal) {
|
foreach ($settingsToDb as $settingKey => $settingVal) {
|
||||||
|
|
|
@ -254,12 +254,15 @@ class extconfigs
|
||||||
'wallpapers' => 'wallpapers'
|
'wallpapers' => 'wallpapers'
|
||||||
);
|
);
|
||||||
$adv_tree = array('pro' => array('templates' => 'tftproot',
|
$adv_tree = array('pro' => array('templates' => 'tftproot',
|
||||||
|
'firmware' => 'tftproot',
|
||||||
'settings' => 'tftproot',
|
'settings' => 'tftproot',
|
||||||
'locales' => 'tftproot',
|
'locales' => 'tftproot',
|
||||||
'firmware' => 'tftproot',
|
|
||||||
'languages' => 'locales',
|
'languages' => 'locales',
|
||||||
|
'templates' => 'tftproot',
|
||||||
'dialplan' => 'tftproot',
|
'dialplan' => 'tftproot',
|
||||||
'softkey' => 'tftproot'
|
'softkey' => 'tftproot',
|
||||||
|
'ringtones' => 'tftproot',
|
||||||
|
'wallpapers' => 'tftproot'
|
||||||
),
|
),
|
||||||
'def' => array('templates' => 'tftproot',
|
'def' => array('templates' => 'tftproot',
|
||||||
'settings' => '',
|
'settings' => '',
|
||||||
|
@ -300,8 +303,21 @@ class extconfigs
|
||||||
$adv_ini_array = parse_ini_file($adv_ini);
|
$adv_ini_array = parse_ini_file($adv_ini);
|
||||||
$adv_config = array_merge($adv_config, $adv_ini_array);
|
$adv_config = array_merge($adv_config, $adv_ini_array);
|
||||||
}
|
}
|
||||||
|
// rewrite adv_ini to reflect the new $adv_config
|
||||||
|
if (file_exists($adv_ini)){
|
||||||
|
rename($adv_ini, "{$adv_ini}.old");
|
||||||
|
}
|
||||||
|
$indexFile = fopen($adv_ini,'w');
|
||||||
|
fwrite($indexFile, "[main]\n");
|
||||||
|
foreach ($adv_config as $advKey => $advVal) {
|
||||||
|
fwrite($indexFile, "{$advKey} = {$advVal}\n");
|
||||||
|
}
|
||||||
|
fclose($indexFile);
|
||||||
|
|
||||||
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => '');
|
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => '');
|
||||||
break;
|
break;
|
||||||
|
case 'unavailable':
|
||||||
|
$settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'unavailable', 'systemdefault' => '');
|
||||||
case 'on':
|
case 'on':
|
||||||
case 'internal':
|
case 'internal':
|
||||||
case 'off':
|
case 'off':
|
||||||
|
@ -332,6 +348,12 @@ class extconfigs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Set up tftproot/settings so that can test if mapping is Enabled and configured.
|
||||||
|
if (!is_dir("{$settingsFromDb['tftp_path']['data']}/settings")) {
|
||||||
|
if (!mkdir("{$settingsFromDb['tftp_path']['data']}/settings", 0755, true)) {
|
||||||
|
die_freepbx(_('Error creating dir : ' . $base_config[$key]));
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: Need to add index.cnf, after setting defaults correctly
|
// TODO: Need to add index.cnf, after setting defaults correctly
|
||||||
if (!file_exists($base_config["tftp_templates_path"] . '/XMLDefault.cnf.xml_template')) {
|
if (!file_exists($base_config["tftp_templates_path"] . '/XMLDefault.cnf.xml_template')) {
|
||||||
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/';
|
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/';
|
||||||
|
|
|
@ -449,7 +449,20 @@ class formcreate
|
||||||
}
|
}
|
||||||
$opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" ';
|
$opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" ';
|
||||||
}
|
}
|
||||||
|
// If TFTP remapping is not available, disable options that require it
|
||||||
|
$disabledButtons = array();
|
||||||
|
if (($child['id'] == 21) && ($sccp_defaults['tftp_rewrite']['data'] == 'unavailable')) {
|
||||||
|
$disabledButtons = (array)$child->option_disable;
|
||||||
|
$unavailableButton = $child->addChild('button','Unavailable');
|
||||||
|
$unavailableButton->addAttribute('value', 'unavailable');
|
||||||
|
dbug('',$child);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($child->xpath('button') as $value) {
|
foreach ($child->xpath('button') as $value) {
|
||||||
|
$opt_disabled = '';
|
||||||
|
if (in_array($value, $disabledButtons )) {
|
||||||
|
$opt_disabled = 'disabled';
|
||||||
|
}
|
||||||
$val_check = strtolower((string)$value[@value]);
|
$val_check = strtolower((string)$value[@value]);
|
||||||
if ($val_check == strtolower($res_v)) {
|
if ($val_check == strtolower($res_v)) {
|
||||||
$val_check = " checked";
|
$val_check = " checked";
|
||||||
|
@ -460,7 +473,7 @@ class formcreate
|
||||||
} else {$val_check = "";}
|
} else {$val_check = "";}
|
||||||
} else {$val_check = "";}
|
} else {$val_check = "";}
|
||||||
}
|
}
|
||||||
echo "<input type=radio name= {$res_id} id=${res_id}_{$i} value={$value[@value]} {$val_check}{$opt_hide}>";
|
echo "<input type=radio name= {$res_id} id=${res_id}_{$i} value={$value[@value]} {$val_check} {$opt_hide} {$opt_disabled}>";
|
||||||
echo "<label for= {$res_id}_{$i}>{$value}</label>";
|
echo "<label for= {$res_id}_{$i}>{$value}</label>";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,6 +213,40 @@ trait helperfunctions {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkTftpMapping(){
|
||||||
|
exec('in.tftpd -V', $tftpInfo);
|
||||||
|
$info['TFTP Server'] = array('Version' => 'Not Found', 'about' => 'Mapping not available');
|
||||||
|
|
||||||
|
if (isset($tftpInfo[0])) {
|
||||||
|
$tftpInfo = explode(',',$tftpInfo[0]);
|
||||||
|
$info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available');
|
||||||
|
$tftpInfo[1] = trim($tftpInfo[1]);
|
||||||
|
$this->sccpvalues['tftp-rewrite']['data'] = 'unavailable';
|
||||||
|
if ($tftpInfo[1] == 'with remap') {
|
||||||
|
$info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]);
|
||||||
|
|
||||||
|
$remoteFileName = ".sccp_manager_remap_probe_sentinel_temp".mt_rand(0, 9999999).".tlzz";
|
||||||
|
$remoteFileContent = "# This is a test file created by Sccp_Manager. It can be deleted without impact";
|
||||||
|
$testFtpDir = "{$this->sccpvalues['tftp_path']['data']}/settings";
|
||||||
|
|
||||||
|
// write a sentinel to a tftp subdirectory to see if mapping is working
|
||||||
|
|
||||||
|
if (is_dir($testFtpDir) && is_writable($testFtpDir)) {
|
||||||
|
// TODO: Need to be sure that installer creates this directory
|
||||||
|
$tempFile = "${testFtpDir}/{$remoteFileName}";
|
||||||
|
file_put_contents($tempFile, $remoteFileContent);
|
||||||
|
|
||||||
|
// try to pull the written file through tftp.
|
||||||
|
// this way we can determine if mapping is active and using sccp_manager maps
|
||||||
|
if ($remoteFileContent != $this->tftpReadTestFile($remoteFileName)) {
|
||||||
|
// Did not find sentinel so mapping not available
|
||||||
|
$this->sccpvalues['tftp_rewrite']['data'] = 'unavailable';
|
||||||
|
}
|
||||||
|
unlink($tempFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// temporary helper function to save xml with proper indentation
|
// temporary helper function to save xml with proper indentation
|
||||||
public function saveXml($xml, $filename) {
|
public function saveXml($xml, $filename) {
|
||||||
$dom = new \DOMDocument("1.0");
|
$dom = new \DOMDocument("1.0");
|
||||||
|
|
|
@ -36,29 +36,35 @@ $info['aminterface'] = $this->aminterface->info();
|
||||||
$info['XML'] = $this->xmlinterface->info();
|
$info['XML'] = $this->xmlinterface->info();
|
||||||
$info['sccp_class'] = $driver['sccp'];
|
$info['sccp_class'] = $driver['sccp'];
|
||||||
$info['Core_sccp'] = array('Version' => $core['Version'],
|
$info['Core_sccp'] = array('Version' => $core['Version'],
|
||||||
'about' => 'Sccp ver.' . $core['Version'] .
|
'about' => "Sccp ver: {$core['Version']} r{$core['vCode']} Revision: {$core['RevisionNum']} Hash: {$core['RevisionHash']}");
|
||||||
' r' . $core['vCode'] . ' Revision :' .
|
|
||||||
$core['RevisionNum'] . ' Hash :' .
|
|
||||||
$core['RevisionHash']);
|
|
||||||
/*
|
|
||||||
if (!$this->srvinterface->useAmiInterface) {
|
|
||||||
$info['aminterface']['about'] .= ' -- Disabled';
|
|
||||||
$info['Core_sccp'] = array('Version' => $core['Version'], 'about' => 'Sccp ver.' . $core['Version'] . ' r' . $core['vCode'] . ' Revision :' . $core['RevisionNum'] . ' Hash :' . $core['RevisionHash'] . ' ----Warning: Upgrade chan_sccp to use full ami functionality');
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.');
|
|
||||||
|
|
||||||
|
$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.');
|
||||||
|
|
||||||
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
||||||
$info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure');
|
$info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure');
|
||||||
}
|
}
|
||||||
if (!empty($this->sccpvalues['tftp_rewrite'])) {
|
|
||||||
if ($this->sccpvalues['tftp_rewrite']['data'] == 'pro') {
|
// Start testing tftp server settings - this should be moved after debug to extConfigs
|
||||||
$info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled');
|
|
||||||
} else {
|
if (!empty($this->sccpvalues['tftp_rewrite']['data'])) {
|
||||||
$info['TFTP_Rewrite'] = array('Version' => 'base', 'about' => 'Rewrite Supported');
|
switch ($this->sccpvalues['tftp_rewrite']['data']) {
|
||||||
|
case 'custom':
|
||||||
|
case 'pro':
|
||||||
|
$info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled');
|
||||||
|
break;
|
||||||
|
case 'unavailable':
|
||||||
|
$info['TFTP Mapping'] = array('Version' => 'off', 'about' => 'remapping is available, but mapping file not included in tftpd-hpa default settings.<br>
|
||||||
|
Add option <br>
|
||||||
|
-m /etc/asterisk/sccpManagerRewrite.rules <br>
|
||||||
|
to the tftpd defaults, location dependant on the system, and restart the tftpd server');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$info['TFTP_Mapping'] = array('Version' => 'off', 'about' => 'Rewrite Supported');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finished testing tftp server options
|
||||||
$info['Сompatible'] = array('Version' => $compatible, 'about' => 'Ok');
|
$info['Сompatible'] = array('Version' => $compatible, 'about' => 'Ok');
|
||||||
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
||||||
if ($compatible > $this->sccpvalues['SccpDBmodel']['data']) {
|
if ($compatible > $this->sccpvalues['SccpDBmodel']['data']) {
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
echo $this->showGroup('sccp_dev_time_s', 1);
|
echo $this->showGroup('sccp_dev_time_s', 1);
|
||||||
echo $this->showGroup('sccp_net', 1);
|
echo $this->showGroup('sccp_net', 1);
|
||||||
echo $this->showGroup('sccp_lang', 1);
|
echo $this->showGroup('sccp_lang', 1);
|
||||||
|
|
||||||
echo $this->showGroup('sccp_extpath_config', 1);
|
echo $this->showGroup('sccp_extpath_config', 1);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue