diff --git a/bin/oglivecli b/bin/oglivecli index 35ccc8c..e0874d7 100755 --- a/bin/oglivecli +++ b/bin/oglivecli @@ -139,6 +139,8 @@ function download() { else local download_url="$1" OGLIVEFILE=$(basename "$download_url") + local oglive_name="${OGLIVEFILE%.iso}" # Nombre del ogLive sin la extensión .iso + INSTALLED_PATH="$TFTPDIR/$oglive_name" # Ruta de instalación donde se verifica # Validar que la URL apunte a un archivo ISO. if [[ ! "$OGLIVEFILE" =~ \.iso$ ]]; then @@ -148,6 +150,11 @@ function download() { # Obtener el tamaño de descarga. SOURCELENGTH=$(curl -k --head --retry 5 --retry-delay 5 --max-time 30 "$download_url" | awk -F: '/Content-Length:/ {print $2}') [ -n "$SOURCELENGTH" ] || raiseError download "No se pudo obtener el tamaño del archivo desde \"$download_url\"." + + # Verificar si el ogLive ya está instalado + if [ -d "$INSTALLED_PATH" ]; then + raiseError download "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." + fi # Descargar ogLive. TARGETFILE="$DOWNLOADDIR/$OGLIVEFILE" diff --git a/installer/ogboot_installer.py b/installer/ogboot_installer.py index 290128a..8688d9e 100755 --- a/installer/ogboot_installer.py +++ b/installer/ogboot_installer.py @@ -476,12 +476,19 @@ def copyClientFiles(): logger.error(f"Error while copying client structure") errstatus = 1 - logger.info(f"Copying OpenGnsys Cloning Engine files.") + logger.info(f"Copying OpenGnsys Cloning Engine files in client library.") os.makedirs(f"{INSTALL_OGBOOT_TARGET}/client/lib/engine/bin", mode=0o775, exist_ok=True) if 0 != subprocess.run (['rsync', '-aH', f'{REPO_DIR}/client/engine/', f'{INSTALL_OGBOOT_TARGET}/client/lib/engine/bin/']).returncode: logger.error(f"Error while copying engine files") errstatus = 1 + logger.info(f"Copying OpenGnsys Cloning Engine files in client engine.") + os.makedirs(f"{INSTALL_OGBOOT_TARGET}/client/engine", mode=0o775, exist_ok=True) + if 0 != subprocess.run (['rsync', '-aH', f'{REPO_DIR}/client/engine/', f'{INSTALL_OGBOOT_TARGET}/client/engine/']).returncode: + logger.error(f"Error while copying engine files") + errstatus = 1 + + # Creación del archivo ogAdmClient.cfg try: template_path = os.path.join(REPO_DIR, "etc/ogAdmClient.cfg.tmpl") diff --git a/src/OgBootBundle/Controller/OgBootController.php b/src/OgBootBundle/Controller/OgBootController.php index 0133288..c330b3a 100644 --- a/src/OgBootBundle/Controller/OgBootController.php +++ b/src/OgBootBundle/Controller/OgBootController.php @@ -140,11 +140,22 @@ public function getStatus(): Response $ogLiveConfigResult = $ogLiveResponse['output']; $ogLiveExitCode = $ogLiveResponse['exitCode']; + $defaultOglive = ""; + $installedOglives = []; + $ogLiveError = null; + if ($ogLiveExitCode !== 0) { - return new JsonResponse( - ['error' => 'FAILED_TO_RETRIEVE_OGLIVE_CONFIGURATION', 'details' => $ogLiveConfigResult['error'] ?? 'Unknown error'], - Response::HTTP_INTERNAL_SERVER_ERROR - ); + // Capturar el error, pero continuar la ejecución + $ogLiveError = [ + 'error' => 'FAILED_TO_RETRIEVE_OGLIVE_CONFIGURATION', + 'details' => $ogLiveConfigResult['error'] ?? 'Unknown error' + ]; + $defaultOglive = ""; + $installedOglives = []; + } else { + // Extraer datos si el comando fue exitoso + $defaultOglive = $ogLiveConfigResult['default_oglive'] ?? ""; + $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; } // Llamar a oglivecli para obtener el estado de los servicios @@ -159,17 +170,6 @@ public function getStatus(): Response ); } - // Verificar si las claves 'default_oglive' e 'installed_ogLives' existen en la respuesta de oglivecli - $defaultOglive = $ogLiveConfigResult['default_oglive'] ?? null; - $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; - - if ($defaultOglive === null || empty($installedOglives)) { - return new JsonResponse( - ['error' => 'NOT_FOUND', 'message' => 'No default or installed ogLives found.'], - Response::HTTP_NOT_FOUND - ); - } - $response = [ 'success' => 'Status retrieved successfully', 'message' => [ @@ -180,6 +180,11 @@ public function getStatus(): Response ] ]; // Formatear la respuesta final con todos los datos + // Incluir el error de oglive si existe + if ($ogLiveError !== null) { + $response['message']['oglive_error'] = $ogLiveError; + } + return new JsonResponse($response, Response::HTTP_OK); }