31 lines
534 B
Bash
Executable File
31 lines
534 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ $# -ne 3 ]]
|
|
then
|
|
echo Missing arguments
|
|
exit 2
|
|
fi
|
|
|
|
WORKDIR=${1}
|
|
DOMAIN=${2}
|
|
VERSION=${3}
|
|
|
|
function findImages()
|
|
{
|
|
find ${1} -iname "${2}*.img"
|
|
}
|
|
|
|
sleep 5
|
|
|
|
for imageName in $(findImages ${WORKDIR} ${DOMAIN})
|
|
do
|
|
latestName=$(echo $imageName | sed "s/.img/_latest.img/g")
|
|
newName=$(echo $imageName | sed "s/.img/_${VERSION}.img/g")
|
|
virt-sparsify -x --compress --tmp ./ --format qcow2 ${imageName} ${newName}
|
|
if [[ $? -eq 0 ]]
|
|
then
|
|
ln -s ${newName} ${latestName}
|
|
rm -rf ${imageName}
|
|
fi
|
|
done
|