diff --git a/appinfo/routes.php b/appinfo/routes.php index 4c13704d..ce6bc98c 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -83,6 +83,7 @@ return [ // Config API ['name' => 'Other#setUserConfig', 'url' => '/api/config/{key}', 'verb' => 'PUT'], + ['name' => 'Other#getSystemStatus', 'url' => '/api/system-status', 'verb' => 'GET'], ['name' => 'Other#getSystemConfig', 'url' => '/api/system-config', 'verb' => 'GET'], ['name' => 'Other#setSystemConfig', 'url' => '/api/system-config/{key}', 'verb' => 'PUT'], diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index d1a4e4cc..581333da 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -25,6 +25,7 @@ namespace OCA\Memories\Controller; use OCA\Memories\AppInfo\Application; use OCA\Memories\Exceptions; +use OCA\Memories\Exif; use OCA\Memories\Util; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; @@ -76,8 +77,6 @@ class OtherController extends GenericApiController /** * @AdminRequired * - * @NoCSRFRequired - * * @param mixed $value */ public function setSystemConfig(string $key, $value): Http\Response @@ -109,6 +108,43 @@ class OtherController extends GenericApiController }); } + /** + * @AdminRequired + * + * @NoCSRFRequired + */ + public function getSystemStatus(): Http\Response + { + return Util::guardEx(function () { + $status = []; + + // Check exiftool + $status['exiftool'] = $this->getExecutableStatus(Util::getSystemConfig('memories.exiftool')); + + // Check for system perl + $status['perl'] = $this->getExecutableStatus(exec('which perl')); + + // Check ffmpeg and ffprobe binaries + $status['ffmpeg'] = $this->getExecutableStatus(Util::getSystemConfig('memories.vod.ffmpeg')); + $status['ffprobe'] = $this->getExecutableStatus(Util::getSystemConfig('memories.vod.ffprobe')); + + // Check go-vod binary + $status['govod'] = $this->getExecutableStatus(Util::getSystemConfig('memories.vod.path')); + + // Check for VA-API device + $devPath = '/dev/dri/renderD128'; + if (!is_file($devPath)) { + $status['vaapi_dev'] = 'not_found'; + } elseif (!is_readable($devPath)) { + $status['vaapi_dev'] = 'not_readable'; + } else { + $status['vaapi_dev'] = 'ok'; + } + + return new JSONResponse($status, Http::STATUS_OK); + }); + } + /** * @NoAdminRequired * @@ -127,4 +163,17 @@ class OtherController extends GenericApiController return $response; } + + private function getExecutableStatus(string $path): string + { + if (!is_file($path)) { + return 'not_found'; + } + + if (!is_executable($path)) { + return 'not_executable'; + } + + return 'ok'; + } } diff --git a/src/Admin.vue b/src/Admin.vue index b3f8313b..8be78883 100644 --- a/src/Admin.vue +++ b/src/Admin.vue @@ -2,6 +2,12 @@

{{ t("memories", "EXIF Extraction") }}

+ + + + + + + + - - {{ - t( - "memories", - "/dev/dri/renderD128 is required for VA-API acceleration." - ) - }} + + {{ vaapiStatusText() }} diff --git a/src/services/API.ts b/src/services/API.ts index 59d3250e..fce521be 100644 --- a/src/services/API.ts +++ b/src/services/API.ts @@ -190,6 +190,10 @@ export class API { : gen(`${BASE}/system-config`); } + static SYSTEM_STATUS() { + return gen(`${BASE}/system-status`); + } + static MAP_CLUSTERS() { return tok(gen(`${BASE}/map/clusters`)); }