Merge pull request #47 from Nicolas01/fixFileExistsInOsDetection
Fix file exists in os detection
This commit is contained in:
commit
f82dab4944
|
@ -64,7 +64,7 @@ if ($frequency == 'N.A')
|
||||||
// CPU Temp
|
// CPU Temp
|
||||||
if ($Config->get('cpu:enable_temperature'))
|
if ($Config->get('cpu:enable_temperature'))
|
||||||
{
|
{
|
||||||
if (exec('/usr/bin/sensors | grep -E "^(CPU Temp|Core 0)" | cut -d \'+\' -f2 | cut -d \'.\' -f1', $t))
|
if (file_exists('/usr/bin/sensors') && exec('/usr/bin/sensors | grep -E "^(CPU Temp|Core 0)" | cut -d \'+\' -f2 | cut -d \'.\' -f1', $t))
|
||||||
{
|
{
|
||||||
if (isset($t[0]))
|
if (isset($t[0]))
|
||||||
$temp = $t[0].' °C';
|
$temp = $t[0].' °C';
|
||||||
|
@ -88,4 +88,4 @@ $datas = array(
|
||||||
'temp' => $temp,
|
'temp' => $temp,
|
||||||
);
|
);
|
||||||
|
|
||||||
echo json_encode($datas);
|
echo json_encode($datas);
|
||||||
|
|
|
@ -6,11 +6,11 @@ date_default_timezone_set(@date_default_timezone_get());
|
||||||
$hostname = php_uname('n');
|
$hostname = php_uname('n');
|
||||||
|
|
||||||
// OS
|
// OS
|
||||||
if (!($os = shell_exec('/usr/bin/lsb_release -ds | cut -d= -f2 | tr -d \'"\'')))
|
if (!file_exists('/usr/bin/lsb_release') || !($os = shell_exec('/usr/bin/lsb_release -ds | cut -d= -f2 | tr -d \'"\'')))
|
||||||
{
|
{
|
||||||
if (!($os = shell_exec('cat /etc/system-release | cut -d= -f2 | tr -d \'"\'')))
|
if (!file_exists('/etc/system-release') || !($os = shell_exec('cat /etc/system-release | cut -d= -f2 | tr -d \'"\'')))
|
||||||
{
|
{
|
||||||
if (!($os = shell_exec('cat /etc/os-release | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
|
if (!file_exists('/etc/os-release') || !($os = shell_exec('cat /etc/os-release | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
|
||||||
{
|
{
|
||||||
if (!($os = shell_exec('find /etc/*-release -type f -exec cat {} \; | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
|
if (!($os = shell_exec('find /etc/*-release -type f -exec cat {} \; | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
|
||||||
{
|
{
|
||||||
|
@ -72,4 +72,4 @@ $datas = array(
|
||||||
'server_date' => $server_date,
|
'server_date' => $server_date,
|
||||||
);
|
);
|
||||||
|
|
||||||
echo json_encode($datas);
|
echo json_encode($datas);
|
||||||
|
|
Loading…
Reference in New Issue