refactor(quickget): special case image processing shellcheck compliant

This commit is contained in:
Martin Wimpress 2024-05-07 10:58:08 +01:00 committed by Martin Wimpress
parent 31de07fb9c
commit 1e05e7a3b2
1 changed files with 30 additions and 26 deletions

View File

@ -3366,34 +3366,38 @@ function create_vm() {
#echo "${HASH}"
web_get "${URL}" "${VM_PATH}"
if [ -n "${HASH}" ]; then
check_hash "${ISO}" "${HASH}"
check_hash "${ISO}" "${HASH}"
fi
if [ ${OS} == "freedos" ] && [[ ${ISO} =~ ".zip" ]]; then
unzip ${VM_PATH}/${ISO} -d ${VM_PATH}
ISO=$(ls ${VM_PATH} | grep -i '.iso')
fi
if [[ ${OS} == "batocera" ]] && [[ ${ISO} =~ ".gz" ]]; then
gzip -d "${VM_PATH}/${ISO}"
ISO="${ISO/.gz/}"
fi
# Could be other OS iso files compressed with bzip2 or gzip
# but for now we'll keep this to know cases
if [[ ${OS} == "dragonflybsd" ]] && [[ ${ISO} =~ ".bz2" ]]; then
bzip2 -d "${VM_PATH}/${ISO}"
ISO="${ISO/.bz2/}"
fi
if [[ ${OS} == "easyos" ]] && [[ ${ISO} =~ ".img" ]]; then
qemu-img convert -f raw -O qcow2 "${VM_PATH}/${ISO}" "${VM_PATH}/disk.qcow2"
ISO="${ISO/.img/}"
fi
if [ ${OS} == "reactos" ] && [[ ${ISO} =~ ".zip" ]]; then
unzip ${VM_PATH}/${ISO} -d ${VM_PATH}
ISO=$(ls ${VM_PATH} | grep -i '.iso' | grep -v '.zip')
fi
case "${OS}" in
batocera)
if [[ ${ISO} = *".gz"* ]]; then
gzip -d "${VM_PATH}/${ISO}"
ISO="${ISO/.gz/}"
fi;;
dragonflybsd)
# Could be other OS iso files compressed with bzip2 or gzip
# but for now we'll keep this to know cases
if [[ ${ISO} = *".bz2"* ]]; then
bzip2 -d "${VM_PATH}/${ISO}"
ISO="${ISO/.bz2/}"
fi;;
easyos)
if [[ ${ISO} = *".img"* ]]; then
qemu-img convert -f raw -O qcow2 "${VM_PATH}/${ISO}" "${VM_PATH}/disk.qcow2"
ISO="${ISO/.img/}"
fi;;
freedos)
if [[ ${ISO} = *".zip"* ]]; then
unzip ${VM_PATH}/${ISO} -d ${VM_PATH}
ISO=$(ls ${VM_PATH} | grep -i '.iso')
fi;;
reactos)
if [[ ${ISO} = *".zip"* ]]; then
unzip ${VM_PATH}/${ISO} -d ${VM_PATH}
ISO=$(ls ${VM_PATH} | grep -i '.iso' | grep -v '.zip')
fi;;
esac
make_vm_config "${ISO}"
}