Get masterFilesList at install direct from Provisioner. If not available, install a copy from the module
This commit is contained in:
steve-lad 2021-12-27 11:09:42 +01:00
parent 1b979222fa
commit a2217e6e37
6 changed files with 35 additions and 6 deletions

View file

@ -616,13 +616,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private function findInstLangs() { private function findInstLangs() {
//locales and country tones are installed in the tftp_lang_path //locales and country tones are installed in the tftp_lang_path
//Available packs from provisioner are in masterFilesStructure.xml in tftpRoot Path //Available packs from provisioner are in masterFilesStructure.xml in tftpRoot Path
// TODO: Need to include this file as part of module in case download not allowed/available
$searchDir = '/'; //set default for when called by installer on virgin system $searchDir = '/'; //set default for when called by installer on virgin system
$result = array(); $result = array();
if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) {
if (!$this->getFileListFromProvisioner()) { if (!$this->getFileListFromProvisioner($this->sccppath['tftp_path'])) {
// File does not exist and cannot get from internet. // File does not exist and cannot get from internet.
return $result; return $result;
}; };

View file

@ -1035,9 +1035,29 @@ function checkTftpServer() {
die_freepbx(_("Error updating sccpsettings. $sql")); die_freepbx(_("Error updating sccpsettings. $sql"));
} }
} }
getMasterFileList($tftpRootPath);
return; return;
} }
function getMasterFileList(string $tftpRootPath) {
global $thisInstaller;
global $amp_conf;
outn("<li>" . _("Checking TFTP server path and availability ...") . "</li>");
if (file_exists("{$tftpRootPath}/masterFilesStructure.xml")) {
outn("<li>" . _("Backing up existing masterFilesList ...") . "</li>");
rename("{$tftpRootPath}/masterFilesStructure.xml","{$tftpRootPath}/masterFilesStructure.xml.old");
}
outn("<li>" . _("Getting latest master file list from provisioner ...") . "</li>");
if (!$thisInstaller->getFileListFromProvisioner($tftpRootPath)) {
outn("<li>" . _("Unable to fetch master file list from provisioner, installing local copy ...") . "</li>");
// Cannot get file from internet, so use copy with this dist which may be older.
if (!copy($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/contrib/masterFilesStructure.xml',"{$tftpRootPath}/masterFilesStructure.xml")) {
return false;
};
return true;
};
}
function cleanUpSccpSettings() { function cleanUpSccpSettings() {
global $thisInstaller; global $thisInstaller;
global $settingsFromDb; global $settingsFromDb;

View file

@ -1,7 +1,7 @@
<module> <module>
<rawname>sccp_manager</rawname> <rawname>sccp_manager</rawname>
<name>SCCP Manager</name> <name>SCCP Manager</name>
<version>14.3.0.14a</version> <version>14.3.0.15</version>
<type>setup</type> <type>setup</type>
<category>SCCP Connectivity</category> <category>SCCP Connectivity</category>
<publisher>Steve Lad, Alex GP</publisher> <publisher>Steve Lad, Alex GP</publisher>
@ -24,6 +24,7 @@
* Version 14.2.0.9 * - Bug Fix - incorrect response class for Reset Token Device * Version 14.2.0.9 * - Bug Fix - incorrect response class for Reset Token Device
* Version 14.2.0.10 * - Bug Fix - line not assigned on device creation * Version 14.2.0.10 * - Bug Fix - line not assigned on device creation
* Version 14.3.0.0 * - New Minor Version - Change DB and add new settings * Version 14.3.0.0 * - New Minor Version - Change DB and add new settings
* Version 14.3.0.15 * - Get masterFilesList from provisoner via installer Fix Issue 39
</changelog> </changelog>
<location>https://github.com/chan-sccp/sccp_manager</location> <location>https://github.com/chan-sccp/sccp_manager</location>
<supported> <supported>

View file

@ -554,8 +554,9 @@ trait ajaxHelper {
$filesToGet = array(); $filesToGet = array();
$totalFiles = 0; $totalFiles = 0;
$provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/";
// TODO: Maybe should always fetch to ensure have latest, backing up old version
if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) {
if (!$this->getFileListFromProvisioner()) { if (!$this->getFileListFromProvisioner($this->sccppath['tftp_path'])) {
return array('status' => false, return array('status' => false,
'message' => "{$provisionerUrl}tools/tftpbootFiles.xml cannot be found. Check your internet connection, and that this path exists", 'message' => "{$provisionerUrl}tools/tftpbootFiles.xml cannot be found. Check your internet connection, and that this path exists",
'reload' => false); 'reload' => false);

View file

@ -253,12 +253,12 @@ trait helperfunctions {
$dom->save($filename); $dom->save($filename);
} }
public function getFileListFromProvisioner() { public function getFileListFromProvisioner(string $tftpRootPath) {
$provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/";
// Get master tftpboot directory structure // Get master tftpboot directory structure
try { try {
file_put_contents("{$this->sccppath['tftp_path']}/masterFilesStructure.xml",file_get_contents("{$provisionerUrl}tools/tftpbootFiles.xml")); file_put_contents("{$tftpRootPath}/masterFilesStructure.xml",file_get_contents("{$provisionerUrl}tools/tftpbootFiles.xml"));
} catch (\Exception $e) { } catch (\Exception $e) {
return false; return false;
} }

View file

@ -152,6 +152,14 @@ global $amp_conf;
<?php <?php
$selectArray = array(); $selectArray = array();
//below probably unnecessary as installer should ensure that a copy always exists
// TODO: Maybe should always check here to ensure that have latest
if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) {
if (!$this->getFileListFromProvisioner($this->sccppath['tftp_path'])) {
// File does not exist and cannot get from internet.
return $result;
};
}
$tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml");
$firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']"); $firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']");