From 1039ea07906d6af0e1fab8a6f49ab2282bc7f6b9 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:18:24 +0100 Subject: [PATCH] return clean OS name --- app/Actions/Server/ValidateServer.php | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/Actions/Server/ValidateServer.php b/app/Actions/Server/ValidateServer.php index 2e81e1008..2d404e43b 100644 --- a/app/Actions/Server/ValidateServer.php +++ b/app/Actions/Server/ValidateServer.php @@ -54,6 +54,8 @@ class ValidateServer }, []); $ID = data_get($collectedData, 'ID'); + $VERSION_ID = data_get($collectedData, 'VERSION_ID'); + $PRETTY_NAME = data_get($collectedData, 'PRETTY_NAME'); $supported = collect(SUPPORTED_OS) ->first(fn ($supportedOs) => str($supportedOs)->contains($ID)); @@ -65,7 +67,36 @@ class ValidateServer return ['supported' => false, 'error' => $errorMessage]; } - return ['supported' => true, 'os_type' => str($supported), 'error' => null]; + // Map OS display names + $osDisplayNames = [ + 'ubuntu' => 'Ubuntu', + 'debian' => 'Debian', + 'raspbian' => 'Raspbian', + 'centos' => 'CentOS', + 'fedora' => 'Fedora', + 'rhel' => 'Red Hat Enterprise Linux', + 'ol' => 'Oracle Linux', + 'rocky' => 'Rocky Linux', + 'almalinux' => 'AlmaLinux', + 'amzn' => 'Amazon Linux', + 'alpine' => 'Alpine Linux', + 'arch' => 'Arch Linux', + 'archarm' => 'Arch Linux ARM', + 'sles' => 'SUSE Linux Enterprise Server', + 'opensuse-leap' => 'openSUSE Leap', + 'opensuse-tumbleweed' => 'openSUSE Tumbleweed', + ]; + + $displayName = $osDisplayNames[$ID] ?? ucfirst($ID); + $fullOsName = $VERSION_ID ? "$displayName $VERSION_ID" : $displayName; + + return [ + 'supported' => true, + 'os_type' => str($supported), + 'display_name' => $fullOsName, + 'pretty_name' => $PRETTY_NAME, + 'error' => null, + ]; } catch (\Exception $e) { $errorMessage = __('server.os_check_failed'); $server->update(['validation_logs' => $errorMessage]);