Added Linux version check

Added Linux version check and introduced corresponding ServerLinuxKernelTooOld error.
This commit is contained in:
lunardunno 2025-04-01 04:32:32 +04:00
parent 8156ac7757
commit ded3995169
3 changed files with 17 additions and 0 deletions

View file

@ -407,6 +407,21 @@ ErrorCode ServerController::installDockerWorker(const ServerCredentials &credent
cbReadStdOut, cbReadStdErr);
qDebug().noquote() << "ServerController::installDockerWorker" << stdOut;
if (container == DockerContainer::Awg) {
QRegularExpression regex(R"(Linux\s+(\d+)\.(\d+))");
QRegularExpressionMatch match = regex.match(stdOut);
if (match.hasMatch()) {
int major = match.captured(1).toInt();
int minor = match.captured(2).toInt();
if (major > 4 || (major == 4 && minor >= 0)) {
qDebug() << "Linux version is acceptable:" << major << "." << minor;
} else {
qDebug() << "Linux version is too low:" << major << "." << minor;
return ErrorCode::ServerLinuxKernelTooOld;
}
}
}
if (stdOut.contains("lock"))
return ErrorCode::ServerPacketManagerError;
if (stdOut.contains("command not found"))

View file

@ -58,6 +58,7 @@ namespace amnezia
ServerUserDirectoryNotAccessible = 208,
ServerUserNotAllowedInSudoers = 209,
ServerUserPasswordRequired = 210,
ServerLinuxKernelTooOld = 211,
// Ssh connection errors
SshRequestDeniedError = 300,

View file

@ -26,6 +26,7 @@ QString errorString(ErrorCode code) {
case(ErrorCode::ServerUserDirectoryNotAccessible): errorMessage = QObject::tr("The server user's home directory is not accessible"); break;
case(ErrorCode::ServerUserNotAllowedInSudoers): errorMessage = QObject::tr("Action not allowed in sudoers"); break;
case(ErrorCode::ServerUserPasswordRequired): errorMessage = QObject::tr("The user's password is required"); break;
case(ErrorCode::ServerLinuxKernelTooOld): errorMessage = QObject::tr("Server error: Linux kernel is too old"); break;
// Libssh errors
case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break;