aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshevabam <shevabam@users.noreply.github.com>2017-03-20 18:27:03 +0100
committerGitHub <noreply@github.com>2017-03-20 18:27:03 +0100
commitf82dab49443f83fc9445297037cd15d85b229f60 (patch)
tree552d53811c62002d9ae3f0cf3a890d2c88bf27a5
parent7ed8e89bfb400e0e26db5be9982e4a7aa4aed3c2 (diff)
parentfffe83f2c73a2928e32c2c70ad788fea9a94d17a (diff)
Merge pull request #47 from Nicolas01/fixFileExistsInOsDetection
Fix file exists in os detection
-rw-r--r--libs/cpu.php4
-rw-r--r--libs/system.php8
2 files changed, 6 insertions, 6 deletions
diff --git a/libs/cpu.php b/libs/cpu.php
index 9665c87..993e289 100644
--- a/libs/cpu.php
+++ b/libs/cpu.php
@@ -64,7 +64,7 @@ if ($frequency == 'N.A')
// CPU Temp
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]))
$temp = $t[0].' °C';
@@ -88,4 +88,4 @@ $datas = array(
'temp' => $temp,
);
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);
diff --git a/libs/system.php b/libs/system.php
index 702ef3b..ee43722 100644
--- a/libs/system.php
+++ b/libs/system.php
@@ -6,11 +6,11 @@ date_default_timezone_set(@date_default_timezone_get());
$hostname = php_uname('n');
// 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 \'"\'')))
{
@@ -72,4 +72,4 @@ $datas = array(
'server_date' => $server_date,
);
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);