refs #1148 #1155 Adds no compresion cpio option to setsmbpass, fix case if ogliveinfo not exists in oglive list, changes filename of oglives when is installed

ogboot-log opengnsys_devel-0.0.10
Luis Gerardo Romero Garcia 2024-11-18 16:04:11 +01:00
parent 6cdde68206
commit 5ea829c99b
3 changed files with 59 additions and 41 deletions

View File

@ -296,8 +296,9 @@ function install() {
*) *)
OGLIVEARCH="i386" ;; OGLIVEARCH="i386" ;;
esac esac
OGLIVEDIR="$TFTPDIR/$DEFOGLIVE-${OGLIVEKRNL%%-*}-$OGLIVEARCH-$OGLIVEREV" #OGLIVEDIR="$TFTPDIR/$DEFOGLIVE-${OGLIVEKRNL%%-*}-$OGLIVEARCH-$OGLIVEREV"
OGLIVEDIR="${OGLIVEDIR/amd64-/}" #OGLIVEDIR="${OGLIVEDIR/amd64-/}"
OGLIVEDIR=$TFTPDIR$(basename "$OGLIVEFILE" .iso)
OGINITRD="$OGLIVEDIR/oginitrd.img" OGINITRD="$OGLIVEDIR/oginitrd.img"
[ ! -r "$OGINITRD" ] && OGINITRD="$TFTPDIR/$DEFOGLIVE/oginitrd.img" [ ! -r "$OGINITRD" ] && OGINITRD="$TFTPDIR/$DEFOGLIVE/oginitrd.img"
@ -556,14 +557,14 @@ function list_installed_oglives() {
# Verificar si el directorio TFTPDIR es accesible # Verificar si el directorio TFTPDIR es accesible
if [ ! -d "$TFTPDIR" ]; then if [ ! -d "$TFTPDIR" ]; then
echo "{\"error\": \"SERVER_ERROR\", \"message\": \"TFTP directory not found or not accessible.\"}" echo '{"error": "SERVER_ERROR", "message": "TFTP directory not found or not accessible."}'
exit 500 exit 500
fi fi
# Buscar directorios de ogLive instalados # Buscar directorios de ogLive instalados
INST=$(find "$TFTPDIR/" -type d -name "$DEFOGLIVE-*" -a ! -name "*.old" -printf "%f\n" 2>/dev/null | sort) INST=$(find "$TFTPDIR/" -type d -name "$DEFOGLIVE-*" -a ! -name "*.old" -printf "%f\n" 2>/dev/null | sort)
if [ -z "$INST" ]; then if [ -z "$INST" ]; then
echo "{\"error\": \"NOT_FOUND\", \"message\": \"No installed ogLive clients found.\"}" echo '{"error": "NOT_FOUND", "message": "No installed ogLive clients found."}'
exit 404 exit 404
fi fi
@ -580,24 +581,25 @@ function list_installed_oglives() {
local OGLIVEJSON="$OGLIVEDIR/oglive_info.json" local OGLIVEJSON="$OGLIVEDIR/oglive_info.json"
local CHECKSUM_FILE="$OGLIVEDIR/ogclient.sqfs.sum" local CHECKSUM_FILE="$OGLIVEDIR/ogclient.sqfs.sum"
# Verificar que el archivo oglive_info.json existe en el directorio. # Intentar obtener el ID desde el archivo ogclient.sqfs.sum
if [ -f "$CHECKSUM_FILE" ]; then
CHECKSUM=$(cut -d ' ' -f 1 "$CHECKSUM_FILE")
else
local DATA=$(jq -n \
--arg id "unknown" \
--arg error "CHECKSUM_NOT_FOUND" \
--arg message "Checksum file not found or invalid in $OGLIVEDIR. Manual deletion is recommended." \
'{id: $id, error: $error, message: $message}')
installed_ogLives+=("$DATA")
continue
fi
# Verificar que el archivo oglive_info.json existe en el directorio
if [ -f "$OGLIVEJSON" ]; then if [ -f "$OGLIVEJSON" ]; then
OGLIVEDIST=$(jq -r '.OGLIVEDIST' "$OGLIVEJSON") OGLIVEDIST=$(jq -r '.OGLIVEDIST' "$OGLIVEJSON")
OGLIVEKRNL=$(jq -r '.OGLIVEKRNL' "$OGLIVEJSON") OGLIVEKRNL=$(jq -r '.OGLIVEKRNL' "$OGLIVEJSON")
OGLIVEARCH=$(jq -r '.OGLIVEARCH' "$OGLIVEJSON") OGLIVEARCH=$(jq -r '.OGLIVEARCH' "$OGLIVEJSON")
OGLIVEREV=$(jq -r '.OGLIVEREV' "$OGLIVEJSON") OGLIVEREV=$(jq -r '.OGLIVEREV' "$OGLIVEJSON")
else
echo "{\"error\": \"NOT_FOUND\", \"message\": \"oglive_info.json not found in $OGLIVEDIR.\"}"
continue # Continuar con el siguiente ogLive en lugar de detener el proceso
fi
# Obtener el checksum del archivo ogclient.sqfs.sum
if [ -f "$CHECKSUM_FILE" ]; then
CHECKSUM=$(cat "$CHECKSUM_FILE" | cut -d ' ' -f 1)
else
echo "{\"error\": \"NOT_FOUND\", \"message\": \"Checksum file not found in $OGLIVEDIR.\"}"
continue
fi
# Crear el JSON con los datos del ogLive # Crear el JSON con los datos del ogLive
local DATA=$(jq -n \ local DATA=$(jq -n \
@ -608,8 +610,18 @@ function list_installed_oglives() {
--arg rev "$OGLIVEREV" \ --arg rev "$OGLIVEREV" \
--arg dir "$OGLIVEDIR" \ --arg dir "$OGLIVEDIR" \
'{id: $id, distribution: $dist, kernel: $krnl, architecture: $arch, revision: $rev, directory: $dir}') '{id: $id, distribution: $dist, kernel: $krnl, architecture: $arch, revision: $rev, directory: $dir}')
installed_ogLives+=("$DATA") installed_ogLives+=("$DATA")
else
# Informar que el archivo oglive_info.json no existe y que el ogLive puede estar corrupto
local DATA=$(jq -n \
--arg id "$CHECKSUM" \
--arg error "CORRUPT_OG_LIVE" \
--arg message "oglive_info.json not found in $OGLIVEDIR. ogLive may be corrupted." \
'{id: $id, error: $error, message: $message}')
installed_ogLives+=("$DATA")
continue
fi
oglive_count=$((oglive_count + 1)) oglive_count=$((oglive_count + 1))
# Verificar si es el ogLive por defecto # Verificar si es el ogLive por defecto
@ -618,7 +630,7 @@ function list_installed_oglives() {
# Verificar si se encontraron ogLives # Verificar si se encontraron ogLives
if [ "$oglive_count" -eq 0 ]; then if [ "$oglive_count" -eq 0 ]; then
echo "{\"error\": \"NOT_FOUND\", \"message\": \"No valid ogLive clients found.\"}" echo '{"error": "NOT_FOUND", "message": "No valid ogLive clients found."}'
exit 404 exit 404
fi fi

View File

@ -67,7 +67,7 @@ for OGLIVE in $LIST; do
echo "TMPDIR $TMPDIR" echo "TMPDIR $TMPDIR"
cd $TMPDIR || { echo "Error: no se pudo cambiar al directorio temporal."; exit 3; } cd $TMPDIR || { echo "Error: no se pudo cambiar al directorio temporal."; exit 3; }
echo "Verificar si el archivo es gzip o lz4 antes de descomprimir" echo "Verificar si el archivo es gzip, lz4 o ASCII cpio antes de descomprimir"
if file "$CLIENTINITRD" | grep -q "gzip compressed data"; then if file "$CLIENTINITRD" | grep -q "gzip compressed data"; then
if ! gzip -dc "$CLIENTINITRD" | cpio -im; then if ! gzip -dc "$CLIENTINITRD" | cpio -im; then
echo "Error: No se pudo descomprimir y extraer $CLIENTINITRD con gzip." echo "Error: No se pudo descomprimir y extraer $CLIENTINITRD con gzip."
@ -80,8 +80,14 @@ for OGLIVE in $LIST; do
exit 4 exit 4
fi fi
COMPRESS_CMD="lz4 -c" COMPRESS_CMD="lz4 -c"
elif file "$CLIENTINITRD" | grep -q "ASCII cpio archive"; then
if ! cpio -im < "$CLIENTINITRD"; then
echo "Error: No se pudo extraer $CLIENTINITRD como archivo cpio."
exit 4
fi
COMPRESS_CMD="cat" # No compresión, simplemente se pasa el archivo tal cual
else else
echo "Error: $CLIENTINITRD no está en formato gzip o lz4." echo "Error: $CLIENTINITRD no está en formato gzip, lz4 o ASCII cpio."
exit 4 exit 4
fi fi

View File

@ -21,7 +21,7 @@ echo "${MSG_LAUNCHCLIENT:-.}"
if [ -f "/usr/share/OGAgent/opengnsys/linux/OGAgentService.py" -a "$ogstatus" != "offline" ]; then if [ -f "/usr/share/OGAgent/opengnsys/linux/OGAgentService.py" -a "$ogstatus" != "offline" ]; then
# Ejecutar servicio cliente. # Ejecutar servicio cliente.
cd /usr/share/OGAgent cd /usr/share/OGAgent
sed -i -e "/remote=/ s/https:/http:/; /remote=/ s%192.168.[^/]*/%${ogcore}:8000/%" cfg/ogagent.cfg export OGAGENTCFG_OGCORE_IP=$ogcore
python3 -m opengnsys.linux.OGAgentService fg python3 -m opengnsys.linux.OGAgentService fg
else else
for FILE in index $OGGROUP $(ogGetIpAddress) for FILE in index $OGGROUP $(ogGetIpAddress)