Skip to content

Commit c84b525

Browse files
authored
Merge pull request dokuwiki#4451 from dokuwiki/oschecks
fix OS checks. fixes dokuwiki#4446 and dokuwiki#4445
2 parents f3cc9de + 0a37411 commit c84b525

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

inc/infoutils.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function getRuntimeVersions()
184184

185185
if (getenv('KUBERNETES_SERVICE_HOST')) {
186186
$data['container'] = 'Kubernetes';
187-
} elseif (file_exists('/.dockerenv')) {
187+
} elseif (@file_exists('/.dockerenv')) {
188188
$data['container'] = 'Docker';
189189
}
190190

@@ -199,14 +199,16 @@ function getRuntimeVersions()
199199
*/
200200
function getOsRelease()
201201
{
202+
$reader = fn($file) => @parse_ini_string(preg_replace('/#.*$/m', '', file_get_contents($file)));
203+
202204
$osRelease = [];
203-
if (file_exists('/etc/os-release')) {
205+
if (@file_exists('/etc/os-release')) {
204206
// pretty much any common Linux distribution has this
205-
$osRelease = parse_ini_file('/etc/os-release');
206-
} elseif (file_exists('/etc/synoinfo.conf') && file_exists('/etc/VERSION')) {
207+
$osRelease = $reader('/etc/os-release');
208+
} elseif (@file_exists('/etc/synoinfo.conf') && @file_exists('/etc/VERSION')) {
207209
// Synology DSM has its own way
208-
$synoInfo = parse_ini_file('/usr/lib/synoinfo.conf');
209-
$synoVersion = parse_ini_file('/etc/VERSION');
210+
$synoInfo = $reader('/etc/synoinfo.conf');
211+
$synoVersion = $reader('/etc/VERSION');
210212
$osRelease['NAME'] = 'Synology DSM';
211213
$osRelease['ID'] = 'synology';
212214
$osRelease['ID_LIKE'] = 'linux';
@@ -218,6 +220,7 @@ function getOsRelease()
218220
return $osRelease;
219221
}
220222

223+
221224
/**
222225
* Run a few sanity checks
223226
*

0 commit comments

Comments
 (0)