mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 10:58:42 +00:00
Fix Rancid GIT (#11795)
This commit is contained in:
parent
28ee0f1823
commit
4611b19ae5
@ -34,6 +34,7 @@ use LibreNMS\Interfaces\UI\DeviceTab;
|
||||
|
||||
class ShowConfigController extends Controller implements DeviceTab
|
||||
{
|
||||
private $rancidPath;
|
||||
private $rancidFile;
|
||||
|
||||
public function visible(Device $device): bool
|
||||
@ -63,6 +64,7 @@ class ShowConfigController extends Controller implements DeviceTab
|
||||
public function data(Device $device): array
|
||||
{
|
||||
return [
|
||||
'rancid_path' => $this->getRancidPath(),
|
||||
'rancid_file' => $this->getRancidConfigFile(),
|
||||
];
|
||||
}
|
||||
@ -74,6 +76,15 @@ class ShowConfigController extends Controller implements DeviceTab
|
||||
&& $device->getAttrib('override_Oxidized_disable') !== 'true';
|
||||
}
|
||||
|
||||
private function getRancidPath()
|
||||
{
|
||||
if (is_null($this->rancidPath)) {
|
||||
$this->rancidFile = $this->findRancidConfigFile();
|
||||
}
|
||||
|
||||
return $this->rancidPath;
|
||||
}
|
||||
|
||||
private function getRancidConfigFile()
|
||||
{
|
||||
if (is_null($this->rancidFile)) {
|
||||
@ -97,12 +108,15 @@ class ShowConfigController extends Controller implements DeviceTab
|
||||
}
|
||||
|
||||
if (is_file($configs . $device['hostname'])) {
|
||||
$this->rancidPath = $configs;
|
||||
return $configs . $device['hostname'];
|
||||
} elseif (is_file($configs . strtok($device['hostname'], '.'))) { // Strip domain
|
||||
$this->rancidPath = $configs;
|
||||
return $configs . strtok($device['hostname'], '.');
|
||||
} else {
|
||||
if (!empty(Config::get('mydomain'))) { // Try with domain name if set
|
||||
if (is_file($configs . $device['hostname'] . '.' . Config::get('mydomain'))) {
|
||||
$this->rancidPath = $configs;
|
||||
return $configs . $device['hostname'] . '.' . Config::get('mydomain');
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
if (Config::get('rancid_repo_type') == 'git') {
|
||||
$sep = ' | ';
|
||||
|
||||
$process = new Process(array('git', 'log', '-n 8', '--pretty=format:%h;%ct', $rancid_file), $configs);
|
||||
$process = new Process(array('git', 'log', '-n 8', '--pretty=format:%h;%ct', $rancid_file), $rancid_path);
|
||||
$process->run();
|
||||
$gitlogs_raw = explode(PHP_EOL, $process->getOutput());
|
||||
$gitlogs = array();
|
||||
@ -100,7 +100,7 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
}
|
||||
} elseif (Config::get('rancid_repo_type') == 'git') {
|
||||
if (in_array($vars['rev'], $revlist)) {
|
||||
$process = new Process(array('git', 'diff', $vars['rev'] . '^', $vars['rev'], $rancid_file), $configs);
|
||||
$process = new Process(array('git', 'diff', $vars['rev'] . '^', $vars['rev'], $rancid_file), $rancid_path);
|
||||
$process->run();
|
||||
$diff = $process->getOutput();
|
||||
if (!$diff) {
|
||||
|
Loading…
Reference in New Issue
Block a user