From bc6da6de9621b69d115b20b441836e0d545101af Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Apr 2024 14:25:22 +0200 Subject: [PATCH 1/5] fix: Check if ROM data is empty --- src/boot.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/boot.sh b/src/boot.sh index 7e8b1195..38deae6c 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -43,13 +43,13 @@ if [[ "${BOOT_MODE,,}" != "legacy" ]] && [[ "${BOOT_MODE,,}" != "windows_legacy" OVMF="/usr/share/OVMF" DEST="$STORAGE/${BOOT_MODE,,}" - if [ ! -f "$DEST.rom" ]; then - [ ! -f "$OVMF/$ROM" ] && error "UEFI boot file ($OVMF/$ROM) not found!" && exit 44 + if [ ! -s "$DEST.rom" ]; then + [ ! -s "$OVMF/$ROM" ] && error "UEFI boot file ($OVMF/$ROM) not found!" && exit 44 cp "$OVMF/$ROM" "$DEST.rom" fi - if [ ! -f "$DEST.vars" ]; then - [ ! -f "$OVMF/$VARS" ] && error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45 + if [ ! -s "$DEST.vars" ]; then + [ ! -s "$OVMF/$VARS" ] && error "UEFI vars file ($OVMF/$VARS) not found!" && exit 45 cp "$OVMF/$VARS" "$DEST.vars" fi From f4c09f5decb5d37e135d716ec67c86f1a5ffd67b Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Apr 2024 14:28:55 +0200 Subject: [PATCH 2/5] fix: Check if PID is not empty --- src/network.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network.sh b/src/network.sh index 7c027606..b9097271 100644 --- a/src/network.sh +++ b/src/network.sh @@ -223,7 +223,7 @@ closeNetwork() { else local pid="/var/run/dnsmasq.pid" - [ -f "$pid" ] && pKill "$(<"$pid")" + [ -s "$pid" ] && pKill "$(<"$pid")" ip link set "$VM_NET_TAP" down promisc off || true ip link delete "$VM_NET_TAP" || true @@ -251,7 +251,7 @@ getInfo() { if [ -z "$MAC" ]; then local file="$STORAGE/$PROCESS.mac" - [ -f "$file" ] && MAC=$(<"$file") + [ -s "$file" ] && MAC=$(<"$file") if [ -z "$MAC" ]; then # Generate MAC address based on Docker container ID in hostname MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/') From b5a4a4aad0520a5bcdbc941f6e38a95461cd8c22 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Apr 2024 14:31:11 +0200 Subject: [PATCH 3/5] fix: Check if file is not empty --- src/progress.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/progress.sh b/src/progress.sh index 007ce57b..d32e2725 100644 --- a/src/progress.sh +++ b/src/progress.sh @@ -21,7 +21,7 @@ fi while true do - if [ -f "$file" ]; then + if [ -s "$file" ]; then bytes=$(du -sb "$file" | cut -f1) if (( bytes > 1000 )); then size=$(echo "$bytes" | numfmt --to=iec --suffix=B | sed -r 's/([A-Z])/ \1/') From 1e9ee091e7b9b928079756d0c5dea6a18d726c58 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Apr 2024 14:32:22 +0200 Subject: [PATCH 4/5] fix: Check if download is not empty --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index f5109e96..17db3ab8 100644 --- a/src/install.sh +++ b/src/install.sh @@ -37,7 +37,7 @@ info "$MSG" && html "$MSG" fKill "progress.sh" (( rc != 0 )) && error "Failed to download $BOOT , reason: $rc" && exit 60 -[ ! -f "$TMP" ] && error "Failed to download $BOOT" && exit 61 +[ ! -s "$TMP" ] && error "Failed to download $BOOT" && exit 61 html "Download finished successfully..." From d7ead0f6324d63244a9d4de8dc17ec505413a1e7 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Apr 2024 14:45:12 +0200 Subject: [PATCH 5/5] fix: Check disk file is not empty --- src/disk.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/disk.sh b/src/disk.sh index a94d9f21..dea79c7c 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -399,7 +399,7 @@ addDisk () { FS=$(stat -f -c %T "$DIR") checkFS "$FS" "$DISK_FILE" "$DISK_DESC" || exit $? - if ! [ -f "$DISK_FILE" ] ; then + if ! [ -s "$DISK_FILE" ] ; then if [[ "${DISK_FMT,,}" != "raw" ]]; then PREV_FMT="raw" @@ -408,12 +408,12 @@ addDisk () { fi PREV_EXT=$(fmt2ext "$PREV_FMT") - if [ -f "$DISK_BASE.$PREV_EXT" ] ; then + if [ -s "$DISK_BASE.$PREV_EXT" ] ; then convertDisk "$DISK_BASE.$PREV_EXT" "$PREV_FMT" "$DISK_FILE" "$DISK_FMT" "$DISK_BASE" "$DISK_DESC" "$FS" || exit $? fi fi - if [ -f "$DISK_FILE" ]; then + if [ -s "$DISK_FILE" ]; then CUR_SIZE=$(getSize "$DISK_FILE")