refs #404 adds checksum id to the get_default function in oglivecli
parent
92b058532e
commit
a2977166ea
|
@ -408,7 +408,7 @@ function uninstall() {
|
|||
# Get information about the default ogLive client.
|
||||
function get_default() {
|
||||
local DEFAULT_LINK="$TFTPDIR/$DEFOGLIVE"
|
||||
local DIR OGLIVEDIST OGLIVEKRNL OGLIVEARCH OGLIVEREV OGLIVEISO OGLIVEDIR
|
||||
local DIR OGLIVEDIST OGLIVEKRNL OGLIVEARCH OGLIVEREV OGLIVEISO OGLIVEDIR CHECKSUM CHECKSUM_FILE
|
||||
|
||||
# Verificar que el enlace simbólico del ogLive por defecto existe.
|
||||
if [ ! -L "$DEFAULT_LINK" ]; then
|
||||
|
@ -433,9 +433,18 @@ function get_default() {
|
|||
OGLIVEREV="$(echo $OGLIVEDIR | cut -d- -f4)"
|
||||
OGLIVEISO="" # No tenemos la información del ISO aquí, podría necesitarse un ajuste si se requiere
|
||||
|
||||
# Obtener el UUID (Checksum) del archivo ogclient.sqfs.sum
|
||||
CHECKSUM_FILE="$DIR/ogclient.sqfs.sum"
|
||||
if [ -f "$CHECKSUM_FILE" ]; then
|
||||
CHECKSUM=$(cat "$CHECKSUM_FILE" | cut -d ' ' -f 1)
|
||||
else
|
||||
CHECKSUM=""
|
||||
fi
|
||||
|
||||
# Construir el JSON con la información.
|
||||
local INFO=$(cat << EOT
|
||||
{
|
||||
"id": "$CHECKSUM",
|
||||
"distribution": "$OGLIVEDIST",
|
||||
"kernel": "$OGLIVEKRNL",
|
||||
"architecture": "$OGLIVEARCH",
|
||||
|
@ -450,6 +459,7 @@ EOT
|
|||
echo "$INFO"
|
||||
}
|
||||
|
||||
|
||||
# Set default ogLive client by checksum.
|
||||
function set_default() {
|
||||
local CHECKSUM=$1
|
||||
|
@ -496,11 +506,7 @@ function list_installed_oglives() {
|
|||
local installed_ogLives=()
|
||||
|
||||
for i in $INST; do
|
||||
NF=$(echo $i | awk -F- '{print NF-1}')
|
||||
local OGLIVEDIST=""
|
||||
local OGLIVEKRNL=""
|
||||
local OGLIVEARCH=""
|
||||
local OGLIVEREV=""
|
||||
local OGLIVEDIR=""
|
||||
local CHECKSUM=""
|
||||
local CHECKSUM_FILE="$TFTPDIR/$i/ogclient.sqfs.sum"
|
||||
|
||||
|
@ -508,23 +514,12 @@ function list_installed_oglives() {
|
|||
CHECKSUM=$(cat "$CHECKSUM_FILE" | cut -d ' ' -f 1)
|
||||
fi
|
||||
|
||||
case $NF in
|
||||
1) OGLIVEDIST="" OGLIVEKRNL=$(echo $i|cut -f2 -d-) OGLIVEARCH="i386" OGLIVEREV="" ;;
|
||||
2) eval $(echo $i | awk -F- '{printf "OGLIVEDIST=\"\" OGLIVEKRNL=%s OGLIVEARCH=amd64 OGLIVEREV=%s OGLIVEDIR=%s",$2,$3,$0}') ;;
|
||||
3) eval $(echo $i | awk -F- '{if ($3=="i386") printf "OGLIVEDIST=\"\" OGLIVEKRNL=%s OGLIVEARCH=%s OGLIVEREV=%s OGLIVEDIR=%s",$2,$3,$4,$0; else printf "OGLIVEDIST=%s OGLIVEKRNL=%s OGLIVEARCH=i386 OGLIVEREV=%s OGLIVEDIR=%s",$2,$3,$4,$0}') ;;
|
||||
4) eval $(echo $i | awk -F- '{printf "OGLIVEDIST=%s OGLIVEKRNL=%s OGLIVEARCH=%s OGLIVEREV=%s OGLIVEDIR=%s",$2,$3,$4,$5,$0}') ;;
|
||||
esac
|
||||
OGLIVEDIR=$i
|
||||
|
||||
local DATA=$(jq -n \
|
||||
--arg id "$CHECKSUM" \
|
||||
--arg filename "$OGLIVEDIR" \
|
||||
--arg dist "$OGLIVEDIST" \
|
||||
--arg krnl "$OGLIVEKRNL" \
|
||||
--arg arch "$OGLIVEARCH" \
|
||||
--arg rev "$OGLIVEREV" \
|
||||
--arg dir "$TFTPDIR/$OGLIVEDIR" \
|
||||
--arg iso "" \
|
||||
'{id: $id, filename: $filename, distribution: $dist, kernel: $krnl, architecture: $arch, revision: $rev, directory: $dir, iso: $iso}')
|
||||
'{id: $id, filename: $filename}')
|
||||
|
||||
installed_ogLives+=("$DATA")
|
||||
|
||||
|
|
Loading…
Reference in New Issue