From 5c494fa74332eb9f34ea97f7ee3b2b0ce3a6597c Mon Sep 17 00:00:00 2001 From: lunardunno <126363523+lunardunno@users.noreply.github.com> Date: Mon, 7 Apr 2025 14:16:07 +0400 Subject: [PATCH] Checking docker status Checking Docker activity. Checking and changing locale. Changing "command not found" handling for sh compatibility. --- client/core/controllers/serverController.cpp | 4 +++- client/core/defs.h | 1 + client/core/errorstrings.cpp | 1 + client/server_scripts/install_docker.sh | 5 ++++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/core/controllers/serverController.cpp b/client/core/controllers/serverController.cpp index ac5885be..071a2bc9 100644 --- a/client/core/controllers/serverController.cpp +++ b/client/core/controllers/serverController.cpp @@ -411,7 +411,9 @@ ErrorCode ServerController::installDockerWorker(const ServerCredentials &credent return ErrorCode::ServerPacketManagerError; if (stdOut.contains("Podman is not supported")) return ErrorCode::ServerPodmanIsNotSupported; - if (stdOut.contains("command not found")) + if (stdOut.contains("Status Docker is not active")) + return ErrorCode::ServerDockerStatusIsNotActive; + if (stdOut.contains("sudo:") && stdOut.contains("not found")) return ErrorCode::ServerDockerFailedError; return error; diff --git a/client/core/defs.h b/client/core/defs.h index 0a4cfdf1..d6d28635 100644 --- a/client/core/defs.h +++ b/client/core/defs.h @@ -59,6 +59,7 @@ namespace amnezia ServerUserNotAllowedInSudoers = 209, ServerUserPasswordRequired = 210, ServerPodmanIsNotSupported = 211, + ServerDockerStatusIsNotActive = 212, // Ssh connection errors SshRequestDeniedError = 300, diff --git a/client/core/errorstrings.cpp b/client/core/errorstrings.cpp index eebd6320..bf462ce2 100644 --- a/client/core/errorstrings.cpp +++ b/client/core/errorstrings.cpp @@ -27,6 +27,7 @@ QString errorString(ErrorCode code) { 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::ServerPodmanIsNotSupported): errorMessage = QObject::tr("Server error: podman-docker is not supported"); break; + case(ErrorCode::ServerDockerStatusIsNotActive): errorMessage = QObject::tr("Server error: Docker status is not active"); break; // Libssh errors case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break; diff --git a/client/server_scripts/install_docker.sh b/client/server_scripts/install_docker.sh index 3b2a8236..2ee9a595 100644 --- a/client/server_scripts/install_docker.sh +++ b/client/server_scripts/install_docker.sh @@ -4,6 +4,7 @@ elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q instal elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="-Sup"; what_pkg="-Sp"; docker_pkg="docker"; dist="archlinux";\ else echo "Packet manager not found"; exit 1; fi;\ echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, What pkg command: $what_pkg, Docker pkg: $docker_pkg";\ +echo $LANG | grep -qE '^(en_US.UTF-8|C.UTF-8|C)$' || export LC_ALL=C;\ if [ "$dist" = "debian" ]; then export DEBIAN_FRONTEND=noninteractive; fi;\ if ! command -v sudo > /dev/null 2>&1; then $pm $check_pkgs; $pm $silent_inst sudo; fi;\ if ! command -v fuser > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst psmisc; fi;\ @@ -27,8 +28,10 @@ if [ "$(systemctl is-active docker)" != "active" ]; then \ then sudo $pm $silent_inst $docker_pkg;\ fi;\ sleep 5; sudo systemctl start docker; sleep 5;\ + if [ "$(systemctl is-active docker)" != "active" ];\ + then echo "Status Docker is not active";\ + fi;\ else echo "Podman is not supported";\ fi;\ fi;\ -if ! command -v sudo > /dev/null 2>&1; then echo "Failed to install sudo, command not found"; exit 1; fi;\ sudo docker --version