52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace NoccyLabs\Hotfix\System;
|
|
|
|
use Symfony\Component\Console\Application;
|
|
|
|
class Facts
|
|
{
|
|
private $facts;
|
|
|
|
public static function getSystemFacts()
|
|
{
|
|
static $facts;
|
|
if (!$facts) {
|
|
$facts = new self();
|
|
$facts->read();
|
|
}
|
|
return $facts;
|
|
}
|
|
|
|
public function read()
|
|
{
|
|
$facts = [];
|
|
$has_lsb_release = exec("which lsb_release");
|
|
if ($has_lsb_release) {
|
|
exec("lsb_release -idrcs", $output);
|
|
$facts['lsb'] = (object)[
|
|
'id' => strtolower($output[0]),
|
|
'description' => $output[1],
|
|
'release' => $output[2],
|
|
'codename' => $output[3]
|
|
];
|
|
} elseif (file_exists("/etc/os-release")) {
|
|
$ini = parse_ini_file("/etc/os-release");
|
|
$facts['lsb'] = (object)[
|
|
'id' => strtolower(@$ini['ID']),
|
|
'description' => @$ini['PRETTY_NAME'],
|
|
'release' => @$ini['VERSION_ID'],
|
|
'codename' => @$ini['VERSION_CODENAME']
|
|
];
|
|
}
|
|
|
|
$this->facts = $facts;
|
|
}
|
|
|
|
public function getFacts()
|
|
{
|
|
return $this->facts;
|
|
}
|
|
|
|
}
|