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.
|
# Get information about the default ogLive client.
|
||||||
function get_default() {
|
function get_default() {
|
||||||
local DEFAULT_LINK="$TFTPDIR/$DEFOGLIVE"
|
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.
|
# Verificar que el enlace simbólico del ogLive por defecto existe.
|
||||||
if [ ! -L "$DEFAULT_LINK" ]; then
|
if [ ! -L "$DEFAULT_LINK" ]; then
|
||||||
|
|
@ -433,9 +433,18 @@ function get_default() {
|
||||||
OGLIVEREV="$(echo $OGLIVEDIR | cut -d- -f4)"
|
OGLIVEREV="$(echo $OGLIVEDIR | cut -d- -f4)"
|
||||||
OGLIVEISO="" # No tenemos la información del ISO aquí, podría necesitarse un ajuste si se requiere
|
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.
|
# Construir el JSON con la información.
|
||||||
local INFO=$(cat << EOT
|
local INFO=$(cat << EOT
|
||||||
{
|
{
|
||||||
|
"id": "$CHECKSUM",
|
||||||
"distribution": "$OGLIVEDIST",
|
"distribution": "$OGLIVEDIST",
|
||||||
"kernel": "$OGLIVEKRNL",
|
"kernel": "$OGLIVEKRNL",
|
||||||
"architecture": "$OGLIVEARCH",
|
"architecture": "$OGLIVEARCH",
|
||||||
|
|
@ -450,6 +459,7 @@ EOT
|
||||||
echo "$INFO"
|
echo "$INFO"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Set default ogLive client by checksum.
|
# Set default ogLive client by checksum.
|
||||||
function set_default() {
|
function set_default() {
|
||||||
local CHECKSUM=$1
|
local CHECKSUM=$1
|
||||||
|
|
@ -496,11 +506,7 @@ function list_installed_oglives() {
|
||||||
local installed_ogLives=()
|
local installed_ogLives=()
|
||||||
|
|
||||||
for i in $INST; do
|
for i in $INST; do
|
||||||
NF=$(echo $i | awk -F- '{print NF-1}')
|
local OGLIVEDIR=""
|
||||||
local OGLIVEDIST=""
|
|
||||||
local OGLIVEKRNL=""
|
|
||||||
local OGLIVEARCH=""
|
|
||||||
local OGLIVEREV=""
|
|
||||||
local CHECKSUM=""
|
local CHECKSUM=""
|
||||||
local CHECKSUM_FILE="$TFTPDIR/$i/ogclient.sqfs.sum"
|
local CHECKSUM_FILE="$TFTPDIR/$i/ogclient.sqfs.sum"
|
||||||
|
|
||||||
|
|
@ -508,23 +514,12 @@ function list_installed_oglives() {
|
||||||
CHECKSUM=$(cat "$CHECKSUM_FILE" | cut -d ' ' -f 1)
|
CHECKSUM=$(cat "$CHECKSUM_FILE" | cut -d ' ' -f 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $NF in
|
OGLIVEDIR=$i
|
||||||
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
|
|
||||||
|
|
||||||
local DATA=$(jq -n \
|
local DATA=$(jq -n \
|
||||||
--arg id "$CHECKSUM" \
|
--arg id "$CHECKSUM" \
|
||||||
--arg filename "$OGLIVEDIR" \
|
--arg filename "$OGLIVEDIR" \
|
||||||
--arg dist "$OGLIVEDIST" \
|
'{id: $id, filename: $filename}')
|
||||||
--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}')
|
|
||||||
|
|
||||||
installed_ogLives+=("$DATA")
|
installed_ogLives+=("$DATA")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue