This commit is contained in:
Cryptoval2 2025-09-05 15:46:39 -04:00
parent ed1cbc96e6
commit cca89fceeb

View File

@ -1,8 +1,8 @@
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root." >&2
exit 1
echo "This script must be run as root." >&2
exit 1
fi
# ------ Settings
@ -14,9 +14,10 @@ mkdir -p ${ShrunkDir}
mkdir -p ${TmpDir}
# ------ Settings
Qcow2Files=$(ls -t ${Qcow2Dir}/*.qcow2)
echo "Files to compress: ${Qcow2Files}"
Qcow2Files=$(find ${Qcow2Dir} -type f -name "*.qcow2" -mtime -1 -print)
echo "Files to compress:"
echo ${Qcow2Files}
exit
for file in ${Qcow2Files}
do
@ -52,15 +53,16 @@ do
echo "Compression is successful. Compression ratio is ${ratio}%"
rm ${SparseFile}
Cmd="chown oleg:oleg ${ShrunkFile}"
echo ${Cmd}
eval ${Cmd}
##
GuestFile="${ShrunkFile#*.}"
GuestFile="${GuestFile%.shrunk}"
Cmd="ln -snf ${ShrunkFile} /opt/vm_drive/${GuestFile}"
echo ${Cmd}
eval ${Cmd}
##
Cmd="chown oleg:oleg ${ShrunkFile}"
echo ${Cmd}
eval ${Cmd}
fi
done