Added ability to specify compatibility in hotfix
This commit is contained in:
51
src/System/Facts.php
Normal file
51
src/System/Facts.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user