refs #437 Adds better control in rsync process
parent
cc0a0bffbc
commit
636c6fb2c5
|
@ -377,30 +377,54 @@ function install() {
|
||||||
echo "Mounting SquashFS and checking Rsync version..."
|
echo "Mounting SquashFS and checking Rsync version..."
|
||||||
OGSQFS=$OGLIVEDIR/ogclient.sqfs
|
OGSQFS=$OGLIVEDIR/ogclient.sqfs
|
||||||
|
|
||||||
# Intentar montar SquashFS
|
echo "Attempting to mount SquashFS..."
|
||||||
if mount -o loop,ro $OGSQFS $TMPDIR; then
|
if mount -o loop,ro $OGSQFS $TMPDIR; then
|
||||||
# Obtener versiones de rsync
|
echo "Mounted SquashFS successfully."
|
||||||
|
|
||||||
RSYNCSERV=$(rsync --version 2>/dev/null | awk '/protocol/ {print $6}')
|
RSYNCSERV=$(rsync --version 2>/dev/null | awk '/protocol/ {print $6}')
|
||||||
RSYNCCLNT=$(chroot $TMPDIR /usr/bin/rsync --version 2>/dev/null | awk '/protocol/ {print $6}')
|
RSYNCCLNT=$(chroot $TMPDIR /usr/bin/rsync --version 2>/dev/null | awk '/protocol/ {print $6}')
|
||||||
|
echo "RSYNCSERV: $RSYNCSERV"
|
||||||
|
echo "RSYNCCLNT: $RSYNCCLNT"
|
||||||
|
|
||||||
# Lógica para manejar rsync
|
|
||||||
if [ -z "$RSYNCSERV" ] || [ "$RSYNCSERV" -gt "${RSYNCCLNT:-1}" ]; then
|
if [ -z "$RSYNCSERV" ] || [ "$RSYNCSERV" -gt "${RSYNCCLNT:-1}" ]; then
|
||||||
[ -e "$OPENGNSYS/client/bin/rsync-$RSYNCSERV" ] && \
|
echo "Comparing server and client versions for rsync..."
|
||||||
mv -f "$OPENGNSYS/client/bin/rsync-$RSYNCSERV" "$OPENGNSYS/client/bin/rsync" || \
|
if [ -e "$OPENGNSYS/client/bin/rsync-$RSYNCSERV" ]; then
|
||||||
{ echo "{\"error\": \"mv rsync failed.\"}"; umount $TMPDIR; exit 1; }
|
echo "File exists: $OPENGNSYS/client/bin/rsync-$RSYNCSERV"
|
||||||
|
if mv -f "$OPENGNSYS/client/bin/rsync-$RSYNCSERV" "$OPENGNSYS/client/bin/rsync"; then
|
||||||
|
echo "Moved rsync successfully"
|
||||||
else
|
else
|
||||||
[ -e "$OPENGNSYS/client/bin/rsync" ] && \
|
echo "{\"error\": \"mv rsync failed.\"}"
|
||||||
mv -f "$OPENGNSYS/client/bin/rsync" "$OPENGNSYS/client/bin/rsync-$($OPENGNSYS/client/bin/rsync --version 2>/dev/null | awk '/protocol/ {print $6}')" || \
|
# Optional exit if moving rsync fails
|
||||||
{ echo "{\"error\": \"mv rsync client failed.\"}"; umount $TMPDIR; exit 1; }
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "File not found: $OPENGNSYS/client/bin/rsync-$RSYNCSERV"
|
||||||
|
echo "Rsync version $RSYNCSERV not found in $OPENGNSYS/client/bin. No action needed."
|
||||||
|
# No exit here, as this is not a critical error
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Server rsync version is not greater, checking default rsync..."
|
||||||
|
if [ -e "$OPENGNSYS/client/bin/rsync" ]; then
|
||||||
|
echo "File exists: $OPENGNSYS/client/bin/rsync"
|
||||||
|
if mv -f "$OPENGNSYS/client/bin/rsync" "$OPENGNSYS/client/bin/rsync-$($OPENGNSYS/client/bin/rsync --version 2>/dev/null | awk '/protocol/ {print $6}')"; then
|
||||||
|
echo "Moved rsync client successfully"
|
||||||
|
else
|
||||||
|
echo "{\"error\": \"mv rsync client failed.\"}"
|
||||||
|
# Optional exit if moving rsync fails
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "File not found: $OPENGNSYS/client/bin/rsync"
|
||||||
|
echo "Default rsync not found in $OPENGNSYS/client/bin. No action needed."
|
||||||
|
# No exit here, as this is not a critical error
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Unmounting SquashFS..."
|
echo "Unmounting SquashFS..."
|
||||||
if umount $TMPDIR; then
|
if umount $TMPDIR; then
|
||||||
echo "Unmounted successfully"
|
echo "Unmounted successfully"
|
||||||
# Espera antes de intentar eliminar el directorio
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# Intentar eliminar el directorio TMPDIR
|
|
||||||
if rmdir $TMPDIR; then
|
if rmdir $TMPDIR; then
|
||||||
echo "Cleaned up successfully"
|
echo "Cleaned up successfully"
|
||||||
else
|
else
|
||||||
|
@ -414,8 +438,17 @@ function install() {
|
||||||
echo "{\"error\": \"mount SquashFS failed.\"}"
|
echo "{\"error\": \"mount SquashFS failed.\"}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local json_output
|
echo "Updating JSON file..."
|
||||||
json_output=$(jq -n --arg dist "$OGLIVEDIST" --arg krnl "$OGLIVEKRNL" --arg arch "$OGLIVEARCH" --arg rev "$OGLIVEREV" --arg dir "$OGLIVEDIR" --arg iso "$(basename "$OGLIVEFILE")" \
|
|
||||||
|
|
||||||
|
# Crear JSON output
|
||||||
|
json_output=$(jq -n \
|
||||||
|
--arg dist "$OGLIVEDIST" \
|
||||||
|
--arg krnl "$OGLIVEKRNL" \
|
||||||
|
--arg arch "$OGLIVEARCH" \
|
||||||
|
--arg rev "$OGLIVEREV" \
|
||||||
|
--arg dir "$OGLIVEDIR" \
|
||||||
|
--arg iso "$(basename "$OGLIVEFILE")" \
|
||||||
'{distribution: $dist, kernel: $krnl, architecture: $arch, revision: $rev, directory: $dir, iso: $iso}')
|
'{distribution: $dist, kernel: $krnl, architecture: $arch, revision: $rev, directory: $dir, iso: $iso}')
|
||||||
|
|
||||||
echo "$json_output"
|
echo "$json_output"
|
||||||
|
|
Loading…
Reference in New Issue