Change TFTP detection logic
Accept first hit
This commit is contained in:
parent
d83c3ab93f
commit
bab83c7e3e
13
install.php
13
install.php
|
@ -893,7 +893,7 @@ function checkTftpServer() {
|
||||||
$remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999);
|
$remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999);
|
||||||
$remoteFileContent = "# This is a test file created by Sccp_Manager. It can be deleted without impact";
|
$remoteFileContent = "# This is a test file created by Sccp_Manager. It can be deleted without impact";
|
||||||
$possibleFtpDirs = array('/srv', '/srv/tftp','/var/lib/tftp', '/tftpboot');
|
$possibleFtpDirs = array('/srv', '/srv/tftp','/var/lib/tftp', '/tftpboot');
|
||||||
|
|
||||||
// write a couple of sentinels to different distro tftp locations in the filesystem
|
// write a couple of sentinels to different distro tftp locations in the filesystem
|
||||||
foreach ($possibleFtpDirs as $dirToTest) {
|
foreach ($possibleFtpDirs as $dirToTest) {
|
||||||
if (is_dir($dirToTest) && is_writable($dirToTest) && empty($tftpRootPath)) {
|
if (is_dir($dirToTest) && is_writable($dirToTest) && empty($tftpRootPath)) {
|
||||||
|
@ -901,7 +901,7 @@ function checkTftpServer() {
|
||||||
file_put_contents($tempFile, $remoteFileContent);
|
file_put_contents($tempFile, $remoteFileContent);
|
||||||
|
|
||||||
// try to pull the written file through tftp.
|
// try to pull the written file through tftp.
|
||||||
// this way we can determine if tftp server is active, and what it's
|
// this way we can determine if tftp server is active, and what it's
|
||||||
// source directory is.
|
// source directory is.
|
||||||
if ($remoteFileContent == $thisInstaller->tftpReadTestFile($remoteFileName)) {
|
if ($remoteFileContent == $thisInstaller->tftpReadTestFile($remoteFileName)) {
|
||||||
$tftpRootPath = $dirToTest;
|
$tftpRootPath = $dirToTest;
|
||||||
|
@ -911,8 +911,13 @@ function checkTftpServer() {
|
||||||
// Need to set the new value here to pass to extconfigs below
|
// Need to set the new value here to pass to extconfigs below
|
||||||
$settingsFromDb['tftp_path']['data'] = $tftpRootPath;
|
$settingsFromDb['tftp_path']['data'] = $tftpRootPath;
|
||||||
}
|
}
|
||||||
|
// Found sentinel file. Remove it and exit loop
|
||||||
|
if (file_exists($tempFile)) {
|
||||||
|
unlink($tempFile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// remove all sentinel file
|
// Did not find sentinel so remove and continue
|
||||||
if (file_exists($tempFile)) {
|
if (file_exists($tempFile)) {
|
||||||
unlink($tempFile);
|
unlink($tempFile);
|
||||||
}
|
}
|
||||||
|
@ -921,7 +926,7 @@ function checkTftpServer() {
|
||||||
if (empty($tftpRootPath)) {
|
if (empty($tftpRootPath)) {
|
||||||
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);
|
||||||
|
|
||||||
foreach ($settingsToDb as $settingToSave) {
|
foreach ($settingsToDb as $settingToSave) {
|
||||||
|
|
|
@ -583,15 +583,15 @@ class xmlinterface
|
||||||
case 'softKeyFile':
|
case 'softKeyFile':
|
||||||
case 'dialTemplate': // Доработать !
|
case 'dialTemplate': // Доработать !
|
||||||
$xml_ext_file = '';
|
$xml_ext_file = '';
|
||||||
$templet_path = (($dkey == 'softKeyFile') ? $dev_config['tftp_softkey_path'] : $dev_config['tftp_dialplan_path']);
|
$template_path = (($dkey == 'softKeyFile') ? $dev_config['tftp_softkey_path'] : $dev_config['tftp_dialplan_path']);
|
||||||
$tmp_key = ($dkey == 'softKeyFile') ? 'softkeyset' : '_dialrules';
|
$tmp_key = ($dkey == 'softKeyFile') ? 'softkeyset' : '_dialrules';
|
||||||
if (!empty($dev_config[$tmp_key])) {
|
if (!empty($dev_config[$tmp_key])) {
|
||||||
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkey' . $dev_config[$tmp_key] . '.xml' : $dev_config[$tmp_key] . '.xml');
|
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkey' . $dev_config[$tmp_key] . '.xml' : $dev_config[$tmp_key] . '.xml');
|
||||||
}
|
}
|
||||||
if (empty($xml_ext_file) || !file_exists($templet_path . '/' . $xml_ext_file)) {
|
if (empty($xml_ext_file) || !file_exists($template_path . '/' . $xml_ext_file)) {
|
||||||
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkeydefault.xml' : 'dialplan.xml');
|
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkeydefault.xml' : 'dialplan.xml');
|
||||||
}
|
}
|
||||||
if (file_exists($templet_path . '/' . $xml_ext_file)) {
|
if (file_exists($template_path . '/' . $xml_ext_file)) {
|
||||||
$xml_node->$dkey = $xml_ext_file;
|
$xml_node->$dkey = $xml_ext_file;
|
||||||
} else {
|
} else {
|
||||||
$xml_node->$dkey = null;
|
$xml_node->$dkey = null;
|
||||||
|
|
Loading…
Reference in a new issue