Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/OperatingSystems/FreeBSD.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public function getNetworkInfo(): array {
if (count($gw[0]) > 0) {
$result['gateway'] = implode(', ', array_map('trim', $gw[0]));
}
$resolvConf = $this->readContent('/etc/resolv.conf');
if (preg_match_all('/^\s*nameserver\s+(\S+)/m', $resolvConf, $matches)) {
$result['dns'] = implode(', ', array_unique($matches[1]));
}
} catch (RuntimeException) {
// okay
}
Expand Down Expand Up @@ -239,6 +243,17 @@ public function getThermalZones(): array {
return [];
}

/**
* @throws RuntimeException
*/
protected function readContent(string $filename): string {
$data = @file_get_contents($filename);
if ($data === false || $data === '') {
throw new RuntimeException('Unable to read: "' . $filename . '"');
}
return trim($data);
}

/**
* Execute a command with shell_exec.
*
Expand Down